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); } }
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); } }
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()); } }
public void Constructor_GivenNullDocumentSessionProvider_ThrowsArgumentNullException() { IDocumentSessionProvider documentSessionProvider = null; var fakeRespository = new FakeRepository(documentSessionProvider); }