Last active
July 17, 2017 13:55
-
-
Save hudo/b80ba41ea54f451986b07736bdf4d665 to your computer and use it in GitHub Desktop.
Unit tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void User_can_write_story_when_authenticated() | |
{ | |
var controller = new HomeController(); | |
controller.ControllerContext = new ControllerContext | |
{ | |
HttpContext = new DefaultHttpContext | |
{ | |
User = new ClaimsPrincipal(new ClaimsIdentity(new Claim[] | |
{ | |
new Claim(ClaimTypes.Name, "username") | |
}, "someAuthTypeName")) | |
} | |
}; | |
var actionResult = controller.Index(); | |
var viewResult = Assert.IsType<ViewResult>(actionResult); | |
var model = Assert.IsType<HomePageViewModel>(viewResult.Model); | |
Assert.True(model.CanWriteStory); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment