Ejemplo n.º 1
0
        public void find_by()
        {
            var persistor = new InMemoryPersistor();

            persistor.Persist(new User());
            persistor.Persist(new User
            {
                FirstName = "Jeremy"
            });
            persistor.Persist(new User());

            persistor.FindBy <User>(x => x.FirstName == "Jeremy").FirstName.ShouldBe("Jeremy");
        }
Ejemplo n.º 2
0
        public void find_by()
        {
            var persistor = new InMemoryPersistor();

            persistor.Persist(new User());
            persistor.Persist(new User
            {
                FirstName = "Jeremy"
            });
            persistor.Persist(new User());

            persistor.FindBy<User>(x => x.FirstName == "Jeremy").FirstName.ShouldEqual("Jeremy");
        }
Ejemplo n.º 3
0
        public void remove()
        {
            var persistor = new InMemoryPersistor();

            persistor.Persist(new User());
            var user1 = new User();
            persistor.Persist(user1);
            persistor.Persist(new User());

            persistor.Remove(user1);

            persistor.LoadAll<User>().Count().ShouldEqual(2);
            persistor.LoadAll<User>().ShouldNotContain(user1);
        }
Ejemplo n.º 4
0
        public void remove()
        {
            var persistor = new InMemoryPersistor();

            persistor.Persist(new User());
            var user1 = new User();

            persistor.Persist(user1);
            persistor.Persist(new User());

            persistor.Remove(user1);

            persistor.LoadAll <User>().Count().ShouldBe(2);
            persistor.LoadAll <User>().ShouldNotContain(user1);
        }
Ejemplo n.º 5
0
        public void persist()
        {
            var entity    = new OtherEntity();
            var persistor = new InMemoryPersistor();

            persistor.Persist(entity);

            persistor.LoadAll <OtherEntity>().Single().ShouldBeTheSameAs(entity);
        }
Ejemplo n.º 6
0
        public void persist()
        {
            var entity = new OtherEntity();
            var persistor = new InMemoryPersistor();

            persistor.Persist(entity);

            persistor.LoadAll<OtherEntity>().Single().ShouldBeTheSameAs(entity);
        }
Ejemplo n.º 7
0
        public void load_all()
        {
            var persistor = new InMemoryPersistor();

            persistor.Persist(new User());
            persistor.Persist(new User());
            persistor.Persist(new User());
            persistor.Persist(new OtherEntity());
            persistor.Persist(new OtherEntity());
            persistor.Persist(new ThirdEntity());

            persistor.LoadAll <User>().Count().ShouldBe(3);
            persistor.LoadAll <OtherEntity>().Count().ShouldBe(2);
            persistor.LoadAll <ThirdEntity>().Count().ShouldBe(1);
        }
Ejemplo n.º 8
0
        public void load_all()
        {
            var persistor = new InMemoryPersistor();

            persistor.Persist(new User());
            persistor.Persist(new User());
            persistor.Persist(new User());
            persistor.Persist(new OtherEntity());
            persistor.Persist(new OtherEntity());
            persistor.Persist(new ThirdEntity());

            persistor.LoadAll<User>().Count().ShouldEqual(3);
            persistor.LoadAll<OtherEntity>().Count().ShouldEqual(2);
            persistor.LoadAll<ThirdEntity>().Count().ShouldEqual(1);
        }
Ejemplo n.º 9
0
        public void delete_all()
        {
            var persistor = new InMemoryPersistor();

            persistor.Persist(new User());
            persistor.Persist(new User());
            persistor.Persist(new User());
            persistor.Persist(new OtherEntity());
            persistor.Persist(new OtherEntity());
            persistor.Persist(new ThirdEntity());

            persistor.DeleteAll <ThirdEntity>();

            persistor.LoadAll <User>().Count().ShouldEqual(3);
            persistor.LoadAll <OtherEntity>().Count().ShouldEqual(2);
            persistor.LoadAll <ThirdEntity>().Count().ShouldEqual(0);
        }
Ejemplo n.º 10
0
        public void delete_all()
        {
            var persistor = new InMemoryPersistor();

            persistor.Persist(new User());
            persistor.Persist(new User());
            persistor.Persist(new User());
            persistor.Persist(new OtherEntity());
            persistor.Persist(new OtherEntity());
            persistor.Persist(new ThirdEntity());

            persistor.DeleteAll<ThirdEntity>();

            persistor.LoadAll<User>().Count().ShouldBe(3);
            persistor.LoadAll<OtherEntity>().Count().ShouldBe(2);
            persistor.LoadAll<ThirdEntity>().Count().ShouldBe(0);
        }
        public void clear_all_state()
        {
            var persister = new InMemoryPersistor();
            persister.Persist(new City());
            persister.Persist(new City());
            persister.Persist(new City());
            persister.Persist(new City());
            persister.Persist(new City());
            persister.Persist(new City());

            var reset = new InMemoryPersistenceReset(persister);

            persister.LoadAll<City>().Any().ShouldBeTrue();

            reset.ClearPersistedState();

            persister.LoadAll<City>().Any().ShouldBeFalse();
        }
Ejemplo n.º 12
0
        public void clear_all_state()
        {
            var persister = new InMemoryPersistor();

            persister.Persist(new City());
            persister.Persist(new City());
            persister.Persist(new City());
            persister.Persist(new City());
            persister.Persist(new City());
            persister.Persist(new City());

            var reset = new InMemoryPersistenceReset(persister);

            persister.LoadAll <City>().Any().ShouldBeTrue();

            reset.ClearPersistedState();

            persister.LoadAll <City>().Any().ShouldBeFalse();
        }
        public void soft_deleted_entities_are_not_available_from_All()
        {
            var c1 = new SoftDeletedEntity();
            var c2 = new SoftDeletedEntity {
                Deleted = new Milestone(DateTime.Now)
            };
            var c3 = new SoftDeletedEntity();
            var c4 = new SoftDeletedEntity {
                Deleted = new Milestone(DateTime.Now)
            };

            thePersistor.Persist(c1);
            thePersistor.Persist(c2);
            thePersistor.Persist(c3);
            thePersistor.Persist(c4);

            thePersistor.Persist(c2);
            thePersistor.Persist(c4);

            ClassUnderTest.All().ShouldHaveTheSameElementsAs(c1, c3);
        }