public async Task Delete_IdIsZero_ReturnsBadRequest() { var mockMakerService = new Mock <IMakerService>(); var makerController = new MakerController(mockMakerService.Object); var response = await makerController.Delete(0).ConfigureAwait(false); response.Should().BeOfType <BadRequestResult>(); }
public async Task Delete_IdNotFound_ReturnsNotFound() { var mockMakerService = new Mock <IMakerService>(); mockMakerService.Setup(x => x.Get(It.IsAny <int>())).ReturnsAsync(() => null); var makerController = new MakerController(mockMakerService.Object); var response = await makerController.Delete(1).ConfigureAwait(false); mockMakerService.Verify(x => x.Get(It.IsAny <int>())); response.Should().BeOfType <NotFoundResult>(); }
public async Task Delete_NoCondition_Calls_MakersService_Delete() { var mockMakerService = new Mock <IMakerService>(); var expectedMakerId = 111; var expectedMaker = new Maker { Id = expectedMakerId, Name = "maker name" }; mockMakerService.Setup(x => x.Get(expectedMakerId)).ReturnsAsync(() => expectedMaker); var makerController = new MakerController(mockMakerService.Object); var response = await makerController.Delete(expectedMakerId).ConfigureAwait(false); mockMakerService.Verify(x => x.Remove(It.IsAny <int>())); response.Should().BeOfType <OkResult>(); }