Пример #1
0
        public void UsesCustomSerializerIfPossible()
        {
            var data = new MemoryStore();

            data.SetValue("name", "Foo");
            var gateway = EntityGateway <TestSerialized> .LoadFromObjectStore(new IObjectStore[] { data });

            var first = gateway.All().First();

            Assert.Equal(first.Name, "Foo");
        }
Пример #2
0
        public void CustomLoaderCanBeUsedToExpandAndInstantiateAGroupOfEntities()
        {
            var data = new MemoryStore();

            data.SetValue("loader", "Tests.Serialization.EntityGatewayTests+TestObjectLoader");
            var gateway = EntityGateway <TestObject> .LoadFromObjectStore(new IObjectStore[] { data });

            var all = gateway.All();

            Assert.Equal(3, all.Count());
            Assert.Equal("Loader 1", all.First().Name);
        }
Пример #3
0
        public EntityGatewayTests()
        {
            var data    = new List <IObjectStore>();
            var entity1 = new MemoryStore();

            entity1.SetValue("name", "prop1");
            var entity2 = new MemoryStore();

            entity2.SetValue("name", "prop2");
            data.Add(entity1);
            data.Add(entity2);

            subject = EntityGateway <TestObject> .LoadFromObjectStore(data);
        }
Пример #4
0
        public void ObjectsFlaggedAsAlwaysFreshShouldReloadEveryRequest()
        {
            var data = new MemoryStore();

            data.SetValue("name", "Foo");
            var data2 = new MemoryStore();

            data2.SetValue("name", "Bar");
            var gateway = EntityGateway <AlwaysFresh> .LoadFromObjectStore(new IObjectStore[] { data, data2 });

            var item = gateway.Find("Foo");

            item.SomeValue = false;

            var itemAgain = gateway.Find("Foo");

            Assert.True(itemAgain.SomeValue);
        }
Пример #5
0
        public void CustomImplementationForObjectIsAllowed()
        {
            SilverNeedle.ShortLog.DebugFormat("Running Tests");
            var data = new MemoryStore();

            data.SetValue("name", "Foo");
            data.SetValue("custom-implementation", "Tests.Serialization.EntityGatewayTests+TestObjectCustom");
            var data2 = new MemoryStore();

            data2.SetValue("name", "Bar");
            var gateway = EntityGateway <TestObject> .LoadFromObjectStore(new IObjectStore[] { data, data2 });

            var one = gateway.Find("Foo");

            Assert.IsType <TestObjectCustom>(one);
            var two = gateway.Find("Bar");

            Assert.IsType <TestObject>(two);
        }