public void SignUp_ShouldRegUser() { var context = GetContext(); var controller = new AccountController(context); controller.SignUp(new Models.ViewModels.UserViewModel() { Name = "ivan", Pass = "******" }); var user = context.Users.Auth("ivan", "ivan"); Assert.IsNotNull(user); }
public void SignUp_ShouldReturnBadRequest_IfNameAlreadyExists() { var context = GetContext(); var controller = new AccountController(context); context.Users.RegUser("ivan","asd"); var result = controller.SignUp(new UserViewModel() { Name = "ivan", Pass = "******" }); Assert.IsInstanceOfType(result, 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)); }
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)); }