public void AddDeleteNewPilotTest_Returns_CreatedResult_And_Pilot_ShoudBe_AddedTo_Database_And_Then_ShouldBe_Deleted() { // Arrange MSSQLContext context = new MSSQLContext(); CrewsRepository crewsRepository = new CrewsRepository(); PilotsRepository pilotsRepository = new PilotsRepository(); StewardessesRepository stewardessesRepository = new StewardessesRepository(); CrewingUnitOfWork uow = new CrewingUnitOfWork(crewsRepository, pilotsRepository, stewardessesRepository, context); CrewingService service = new CrewingService(uow); PilotsController controller = new PilotsController(mapper.GetDefaultMapper(), service); // add act var newPilotDTO = new PilotDTO() { Birth = new DateTime(1985, 5, 12, 0, 0, 0), ExperienceYears = 15, Name = "Grisha", Surname = "Kramer" }; var addResult = controller.AddPilot(newPilotDTO); // add assert Assert.IsInstanceOf <CreatedResult>(addResult); Assert.IsInstanceOf <PilotDTO>((addResult as CreatedResult).Value); // delete act var addedPilotDTO = (addResult as CreatedResult).Value as PilotDTO; var deleteResult = controller.DeletePilot(addedPilotDTO.Id); // delete assert Assert.IsInstanceOf <OkResult>(deleteResult); Assert.IsInstanceOf <NotFoundObjectResult>(controller.GetPilot(addedPilotDTO.Id)); }