public T GetObject <T>(int id) { if (memoryStore.HasObject(id)) { return(memoryStore.GetObject <T>(id)); } else { return(fileStore.GetObject <T>(id)); } }
public void GetReturnsPutObjects() { var index = new IndexStore("GetAndPut"); var fs = new FileDataStore("GetAndPut", index); var journal = new FileJournal("GetAndPut", fs); var store = new InMemoryDataStore(fs, journal.DirectoryPath); try { var sword = new Sword("Lego Sword", 13); var car = new Car("Kia", "Eeep", "Black"); store.PutObject(sword, 1); store.PutObject(car, 3); Assert.AreEqual(sword, store.GetObject <Sword>(1)); Assert.AreEqual(car, store.GetObject <Car>(3)); } finally { Directory.Delete("GetAndPut", true); } }