public void Login_ShouldReturnBadRequest_IfWrongNameOrPass() { var context = GetContext(); var controller = new AccountController(context); context.Users.RegUser("ivan", "asd"); context.Users.RegUser("user", "user"); var result = controller.Login(new UserViewModel() { Name = "ivan", Pass = "******" }); var result2 = controller.Login(new UserViewModel() { Name = "userasdf", Pass = "******" }); Assert.IsInstanceOfType(result, typeof(BadRequestErrorMessageResult)); Assert.IsInstanceOfType(result2, typeof(BadRequestErrorMessageResult)); }
public void Login_ShouldReturnSession() { var context = GetContext(); context.Users.RegUser("ivan", "ivan"); var controller = new AccountController(context); var result = controller.Login(new UserViewModel() { Name = "ivan", Pass = "******" })as OkNegotiatedContentResult<SessionViewModel>; Assert.IsNotNull(result); Assert.IsNotNull(context.Sessions.Find(result.Content.Id)); }