public async void Should_return_BadRequest_when_model_is_null() { // Arrange var key = "User_StatusCode_400_BadRequest"; var localizedString = new LocalizedString(key, "Bad Request"); LocalizerMock .Setup(_ => _[key]) .Returns(localizedString); // Act var result = await ControllerUnderTest.CreateUser(null); // Assert Assert.IsType <BadRequestObjectResult>(result); }
public async void Should_return_CreatedResult_when_model_Is_valid() { // Arrange var user = Data; var resultObject = new { Id = 1, AuthRefId = "cfd5935c-7a60-40ea-8a27-e7452e50fa5f", PhotoUri = "http://photouri/23298873" }; UserServiceMock .Setup(x => x.CreateAsync(user)) .ReturnsAsync(resultObject); //Act var result = await ControllerUnderTest.CreateUser(user); //Assert var okResult = Assert.IsType <CreatedResult>(result); Assert.Same(resultObject, okResult.Value); }