Ejemplo n.º 1
0
        protected async Task _typedSerialization(IStorage storage)
        {
            string  key        = "typed";
            var     storeItems = new StoreItems();
            dynamic testItem   = new TestItem()
            {
                Id = "1"
            };

            testItem.x = new TypedObject()
            {
                Name = "test"
            };
            storeItems[key] = testItem;

            await storage.Write(storeItems);

            dynamic result = await storage.Read(key);

            Assert.IsNotNull(result[key], $"result['{key}'] should not be null");
            Assert.AreEqual(result[key].x.Name, "test", "typed object property should be 'test'");
            Assert.AreEqual(result[key].x.GetType(), typeof(TypedObject), "typed object type should be same");
        }
Ejemplo n.º 2
0
        protected async Task _createObjectTest(IStorage storage)
        {
            var storeItems = new StoreItems();

            storeItems["create1"] = new TestItem()
            {
                Id = "1"
            };
            dynamic newItem2 = new StoreItem();

            newItem2.Id           = "2";
            newItem2.dyno         = "dynamicStuff";
            storeItems["create2"] = newItem2;

            await storage.Write(storeItems);

            dynamic result = await storage.Read(new string[] { "create1", "create2" });

            Assert.IsNotNull(result.create1, "create1 should not be null");
            Assert.AreEqual(result.create1.Id, "1", "strong create1.id should be 1");
            Assert.IsNotNull(result.create2, "create2 should not be null");
            Assert.AreEqual(result.create2.Id, "2", "create2.id should be 2");
            Assert.AreEqual(result.create2.dyno, "dynamicStuff", "create2.dyno should be dynoStuff");
        }