Ejemplo n.º 1
0
        public async Task UpdateDefect_DefectNotFound_ReturnMapObject()
        {
            UpdateDefectDto updateDefectDto = new UpdateDefectDto()
            {
                Id          = 1,
                Description = "Broken door",
                Status      = Status.InRepair
            };

            mockDefectsRepository
            .Setup(p => p.FindDefectByIdAsync(updateDefectDto.Id))
            .ReturnsAsync(null as Defect);

            var services = new DefectService(mockUsersRepository.Object, mockCarsRepository.Object, mapper, mockDefectsRepository.Object);
            //Act
            var result = await services.UpdateDefectAsync(updateDefectDto);

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

            Assert.Equal(result.DefectId, updateDefectDto.Id);
            Assert.Equal(result.Description, updateDefectDto.Description);
            Assert.Equal(result.Status, updateDefectDto.Status);
        }
Ejemplo n.º 2
0
        public async Task UpdateDefect_CorrectObject_ReturnMapObject()
        {
            UpdateDefectDto updateDefectDto = new UpdateDefectDto()
            {
                Id          = 1,
                Description = "Broken door",
                Status      = Status.InRepair
            };
            Defect Defect = new Defect()
            {
                DefectId    = 1,
                Description = "Door Finished",
                Status      = Status.Finished
            };

            mockDefectsRepository
            .Setup(p => p.FindDefectByIdAsync(updateDefectDto.Id))
            .ReturnsAsync(new Defect()
            {
                DefectId    = 1,
                Description = "Door Finished",
                Status      = Status.Finished
            });
            mockDefectsRepository
            .Setup(s => s.SaveChangesAsync())
            .Verifiable();
            var services = new DefectService(mockUsersRepository.Object, mockCarsRepository.Object, mapper, mockDefectsRepository.Object);
            //Act
            var result = await services.UpdateDefectAsync(updateDefectDto);

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

            Assert.Equal(result.Description, updateDefectDto.Description);
            Assert.Equal(result.Status, updateDefectDto.Status);
        }