Exemplo n.º 1
0
        public async Task <IActionResult> Delete([FromRoute] int id)
        {
            var sector = await sectorService.DeleteSectorByIdAsync(id);

            if (sector == null)
            {
                return(NotFound());
            }
            else
            {
                return(Ok(sector));
            }
        }
        public async Task DeleteSector_InputIsSectorData_OneSectorDeleted(int id)
        {
            //Arrange
            sectorRepositoryMock.Setup(sectorRepository => sectorRepository.DeleteEntityByIdAsync(It.IsAny <int>()))
            .ReturnsAsync((int id) =>
            {
                var foundSector = sectorsContext.Find(sector => sector.Id == id);
                sectorsContext.Remove(foundSector);
                return(foundSector);
            });
            int sectorContextLength = sectorsContext.Count;
            //Act
            var resultSectorDTO = (await sectorService.DeleteSectorByIdAsync(id)) as SectorDTO;

            //Assert
            Assert.IsNotNull(resultSectorDTO);
            Assert.AreEqual(sectorContextLength - 1, sectorsContext.Count);
        }