Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
qdraw committed Aug 21, 2024
1 parent 790d949 commit 2fa2bb6
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions starsky/starskytest/Controllers/AccountControllerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -886,5 +886,29 @@ public async Task ChangeSecret_ModelStateIsInvalid_ReturnsBadRequest()
// Assert
Assert.IsInstanceOfType<BadRequestObjectResult>(result);
}

[TestMethod]
public async Task LoginPost_ModelStateIsInvalid_ReturnsBadRequest()
{
// Arrange
var controller =
new AccountController(_userManager, _appSettings, _antiForgery, _selectorStorage)
{
ControllerContext =
{
HttpContext = new DefaultHttpContext
{
User = SetTestClaimsSet("test", "1")
}
}
};
controller.ModelState.AddModelError("Key", "ErrorMessage");

// Act
var result = await controller.LoginPost(new LoginViewModel());

// Assert
Assert.IsInstanceOfType<BadRequestObjectResult>(result);
}
}
}

0 comments on commit 2fa2bb6

Please sign in to comment.