public async void PostActivation_ReturnsBadRequestObjectResult_WhenModelStateIsInvalid() { // Arrange var activationPostDto = TestData.Activations.ContractActivationPostDto; ActivationsController.ModelState.AddModelError("Mock", "Error"); // Act var result = await ActivationsController.PostOneAsync(activationPostDto); // Assert Assert.IsType <BadRequestObjectResult>(result); }
public async void PostActivation_ReturnsBadRequestObjectResult_WhenServiceReturnsNull() { // Arrange var activationPostDto = TestData.Activations.ContractActivationPostDto; ActivationsServiceMock .Setup(x => x.CreateOneAsync(It.IsAny <Activation>())) .ReturnsAsync((Activation)null); // Act var result = await ActivationsController.PostOneAsync(activationPostDto); // Assert Assert.IsType <BadRequestResult>(result); }
public async void PostActivation_ReturnsCreatedAtActionResult_WhenServiceReturnsActivation() { // Arrange var activationPostDto = TestData.Activations.ContractActivationPostDto; var expectedActivation = TestData.Activations.ContractActivationPostDtoResponseMock; ActivationsServiceMock .Setup(x => x.CreateOneAsync(It.IsAny <Activation>())) .ReturnsAsync(expectedActivation); // Act var result = await ActivationsController.PostOneAsync(activationPostDto); // Assert var createdResult = Assert.IsType <ObjectResult>(result); Assert.True(createdResult.StatusCode == 201); }