Пример #1
0
        public async Task ShouldReturnListOfCatsByOwnersGender()
        {
            // arrange
            var personLogic    = new Mock <IPersonLogic>();
            var catLogic       = new Mock <ICatLogic>();
            var personDao      = new Mock <IPersonDao>();
            var configuration  = new Mock <IConfiguration>();
            var catsController = new CatsController(personLogic.Object, catLogic.Object);

            personLogic.Setup(p => p.GetPeople()).Returns(Task.FromResult(peopleList));
            personDao.Setup(p => p.GetPeople()).Returns(Task.FromResult(peopleList));

            catLogic.Setup(p => p.GetCatsByOwnerGender(peopleList)).Returns(catsList);

            var cats = await catsController.GetCats();

            // assert
            Assert.AreEqual(catsList, ((OkObjectResult)cats.Result).Value);
        }
Пример #2
0
        public async Task ShouldReturnNotFoundWhenThereAreNoPeople()
        {
            // arrange
            var personLogic    = new Mock <IPersonLogic>();
            var catLogic       = new Mock <ICatLogic>();
            var personDao      = new Mock <IPersonDao>();
            var configuration  = new Mock <IConfiguration>();
            var catsController = new CatsController(personLogic.Object, catLogic.Object);
            IEnumerable <Person>            emptyPerson = new List <Person>();
            IEnumerable <CatsByOwnerGender> emptyCats   = new List <CatsByOwnerGender>();

            personLogic.Setup(p => p.GetPeople()).Returns(Task.FromResult(emptyPerson));
            personDao.Setup(p => p.GetPeople()).Returns(Task.FromResult(emptyPerson));

            catLogic.Setup(p => p.GetCatsByOwnerGender(peopleList)).Returns(emptyCats);

            var cats = await catsController.GetCats();

            // assert
            Assert.AreEqual(404, ((NotFoundResult)cats.Result).StatusCode);
        }