Пример #1
0
        public async Task GetDefectAsync_IdNotExciting_ReturnNullDefect()
        {
            //Arrange
            int DefectId = 1;

            mockDefectsRepository
            .Setup(p => p.FindDefectByIdAsync(DefectId))
            .ReturnsAsync(null as Defect);
            var services = new DefectService(mockUsersRepository.Object, mockCarsRepository.Object, mapper, mockDefectsRepository.Object);
            //Act
            var result = await services.GetDefectAsync(DefectId);

            //Assert
            Assert.Null(result);
        }
Пример #2
0
        public async Task GetDefectAsync_ExcitingId_ReturnDefect()
        {
            //Arrange
            int DefectId = 1;

            mockDefectsRepository
            .Setup(p => p.FindDefectByIdAsync(DefectId))
            .ReturnsAsync(new Defect {
                DefectId = 1
            });
            var services = new DefectService(mockUsersRepository.Object, mockCarsRepository.Object, mapper, mockDefectsRepository.Object);
            //Act
            var result = await services.GetDefectAsync(DefectId);

            //Assert
            var assertResult = Assert.IsType <DefectDto>(result);

            Assert.Equal(DefectId, assertResult.DefectId);
        }