示例#1
0
        public void MakePersistent_AddNewEntity_Succeed()
        {
            var fakeEntity = new FakeEntity {
                Name = "Fake"
            };
            var documentSessionProvider = new DocumentSessionProvider(Store);
            var fakeRespository         = new FakeRepository(documentSessionProvider);

            fakeRespository.MakePersistent(fakeEntity);
            fakeRespository.SaveChanges();

            using (var session = Store.OpenSession())
            {
                var fakeEntity2 = session.Load <FakeEntity> (fakeEntity.Id);
                Assert.IsNotNull(fakeEntity2);
            }
        }
示例#2
0
        public void MakePersistent_UpdateEntity_Succeed()
        {
            var fakeEntity = CreateFakeEntity();
            var documentSessionProvider = new DocumentSessionProvider(Store);
            var fakeRepository          = new FakeRepository(documentSessionProvider);

            fakeEntity.Name = "Changed";
            fakeRepository.MakePersistent(fakeEntity);
            fakeRepository.SaveChanges();

            using (var session = Store.OpenSession())
            {
                var fakeEntity2 = session.Load <FakeEntity> (fakeEntity.Id);

                Assert.AreEqual("Changed", fakeEntity2.Name);
            }
        }
示例#3
0
        public void MakeTransient_WithValidEntity_Succeed()
        {
            var fakeEntity = CreateFakeEntity();


            var documentSessionProvider = new DocumentSessionProvider(Store);
            var fakeRepository          = new FakeRepository(documentSessionProvider);
            var deletingEntity          = fakeRepository.GetById(fakeEntity.Id);

            fakeRepository.MakeTransient(deletingEntity);
            fakeRepository.SaveChanges();

            using (var session = Store.OpenSession())
            {
                var entities = session.Query <FakeEntity> ();

                Assert.AreEqual(0, entities.Count());
            }
        }
示例#4
0
 public void Constructor_GivenNullDocumentSessionProvider_ThrowsArgumentNullException()
 {
     IDocumentSessionProvider documentSessionProvider = null;
     var fakeRespository = new FakeRepository(documentSessionProvider);
 }