コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }