protected async Task UpdateObjectTest(IStorage storage) { var originalPocoItem = new PocoItem() { Id = "1", Count = 1 }; // First write should work var dict = new Dictionary <string, object>() { { "PocoItem", originalPocoItem }, }; await storage.WriteAsync(dict); var loadedStoreItems = new Dictionary <string, object>(await storage.ReadAsync(new[] { "PocoItem" })); var updatePocoItem = loadedStoreItems["PocoItem"] as PocoItem; Assert.IsNotNull(updatePocoItem); Assert.AreEqual("1", updatePocoItem.Id, "UpdatePocoItem.Id should be 1"); Assert.AreEqual(1, updatePocoItem.Count, "UpdatePocoItem.Count should be 1"); // 2nd write should work. updatePocoItem.Count++; await storage.WriteAsync(loadedStoreItems); var reloadedStoreItems = new Dictionary <string, object>(await storage.ReadAsync(new[] { "PocoItem" })); var reloadedUpdatePocoItem = reloadedStoreItems["PocoItem"] as PocoItem; Assert.IsNotNull(reloadedUpdatePocoItem); Assert.AreEqual("1", reloadedUpdatePocoItem.Id, "ReloadedUpdatePocoItem.Id should be 1"); Assert.AreEqual(2, reloadedUpdatePocoItem.Count, "ReloadedUpdatePocoItem.Count should be 2"); }
protected async Task HandleCrazyKeys(IStorage storage) { var key = "\\Poc?oI/t#em 1"; var storeItem = new PocoItem() { Id = "1" }; var dictionary = new Dictionary <string, object>() { [key] = storeItem }; await storage.WriteAsync(dictionary); var storeItems = await storage.ReadAsync(new[] { key }); storeItem = storeItems.FirstOrDefault(si => si.Key == key).Value as PocoItem; Assert.IsNotNull(storeItem); Assert.AreEqual("1", storeItem.Id); }