Esempio n. 1
0
        public void GetAdoptableCats_ShouldReturnOnlyAdoptableCats()
        {
            // Arrange
            repositoryMock.Setup(x => x.GetAllCats()).Returns(CatMocks.GetCatList());

            // Act
            var result = catService.GetAdoptableCats();

            // Assert
            Assert.IsTrue(result.All(x => x.CanBeAdopted));
        }
Esempio n. 2
0
        public void GetAllCats_ShouldReturnAllCats()
        {
            // Arrange
            var listMock = CatMocks.GetCatList();
            var expected = listMock.Select(x => Mapper.CatDtoFromDataModel(x, Constants.CatService.ADOPTION_TRESHOLD_DAYS, dateProviderMock.Object));

            repositoryMock.Setup(x => x.GetAllCats()).Returns(listMock);

            // Act
            var result = catService.GetAllCats();

            // Assert
            CollectionAssert.AreEqual(expected.Select(x => x.Id).ToList(), result.Select(x => x.Id).ToList());
        }
Esempio n. 3
0
        public void GetCatById_ShouldReturnCorrectCat()
        {
            // Arrange
            var cat = CatMocks.GetCatList().First();

            repositoryMock.Setup(x => x.GetCatById(cat.Id)).Returns(cat);
            var expected = Mapper.CatDtoFromDataModel(cat, Constants.CatService.ADOPTION_TRESHOLD_DAYS, dateProviderMock.Object);

            // Act
            var result = catService.GetCatById(cat.Id);

            // Result
            Assert.AreEqual(expected.Id, result.Id);
            Assert.AreEqual(expected.Name, result.Name);
        }