public void TestGetOrCreateHomeWithExingHomeShouldReturnThatInstance() { var mockPersistance = new Moq.Mock<IPersistanceFramework>(); mockPersistance.Setup(m => m.CreateQueryContext<Home>()).Returns( TestHomes); var repository = new HomeRepository(mockPersistance.Object); var results = repository.GetOrCreateHome("first address",1,1); Assert.AreEqual(TestHomes.First().Id, results.Id); mockPersistance.VerifyAll(); }
public void TestGetOrCreateHomeWithNewHomeShouldCreateANewHome() { var mockPersistance = new Moq.Mock<IPersistanceFramework>(); mockPersistance.Setup(m => m.CreateQueryContext<Home>()).Returns( TestHomes); var homeToBeCreated = new Home(); mockPersistance.Setup(m => m.Create<Home>()).Returns(homeToBeCreated); var repository = new HomeRepository(mockPersistance.Object); var results = repository.GetOrCreateHome("new address", 1, 1); Assert.AreNotEqual(TestHomes.First().Id, results.Id); homeToBeCreated.AddressFull = "new address"; mockPersistance.VerifyAll(); }