public void Test_RepositoryException() { Mock <IPeopleRepository> peopleRepositoryMock = new Mock <IPeopleRepository>(); peopleRepositoryMock.Setup(k => k.GetAll(It.IsAny <string>())).Throws(new RestException("http://url", "error message")); var peopleDomain = new PeopleDomain(peopleRepositoryMock.Object, _loggerMock.Object); var ownerByDog = peopleDomain.GetOwnersByPetType("dog"); Assert.AreEqual(2, ownerByDog.Count); }
public void Test_OwnerByPetType_NullServiceResponse() { Mock <IPeopleRepository> peopleRepositoryMock = new Mock <IPeopleRepository>(); peopleRepositoryMock.Setup(k => k.GetAll(It.IsAny <string>())).Returns((List <Person>)null); var peopleDomain = new PeopleDomain(peopleRepositoryMock.Object, _loggerMock.Object); var ownerByDog = peopleDomain.GetOwnersByPetType("dog"); Assert.IsNull(ownerByDog); }
public void Test_OwnerByPetType_Dog() { Mock <IPeopleRepository> peopleRepositoryMock = new Mock <IPeopleRepository>(); peopleRepositoryMock.Setup(k => k.GetAll(It.IsAny <string>())).Returns(_personTestCollection); var peopleDomain = new PeopleDomain(peopleRepositoryMock.Object, _loggerMock.Object); var ownerByDog = peopleDomain.GetOwnersByPetType("dog"); Assert.AreEqual(2, ownerByDog.Count); }