public void ValidatesUserExists()
        {
            var validator = new LoginCommandValidator(Session);
            var command = new LoginCommand { Username = "******", Password = DefaultUser.Password };

            validator.ShouldHaveValidationErrorFor(x => x.Username, command);
        }
        public void ValidatesRequiredFields()
        {
            var validator = new LoginCommandValidator(Session);

            validator.ShouldHaveValidationErrorFor(x => x.Username, string.Empty);
            validator.ShouldHaveValidationErrorFor(x => x.Password, string.Empty);
        }
        public void ValidatesPasswordCorrect()
        {
            var validator = new LoginCommandValidator(Session);
            var command = new LoginCommand { Username = DefaultUser.Username, Password = "******" };

            validator.ShouldHaveValidationErrorFor(x => x.Password, command);
        }
        public void SuccessfulValidation()
        {
            var validator = new LoginCommandValidator(Session);
            var command = new LoginCommand { Username = DefaultUser.Username, Password = DefaultUser.Password };

            validator.Validate(command).IsValid.ShouldBeTrue();
        }
Beispiel #5
0
 public AccountController(
     DatabaseContext ctx,
     LoginCommandValidator loginCmdValidator,
     RegisterCommandValidator registerCmdValidator
     ) : base(ctx)
 {
     _loginCmdValidator    = loginCmdValidator;
     _registerCmdValidator = registerCmdValidator;
 }
 public LoginValidatorTest()
 {
     var user = UserFactory.ValidUser();
     var consultant = ConsultantFactory.ValidConsultant();
     var mockRepo = new Mock<IAccountRepository>();
     mockRepo.Setup(db => db.GetByEmailAsync<Consultant>(consultant.Email).Result).Returns(consultant);
     mockRepo.Setup(db => db.GetByEmailAsync<User>(user.Email).Result).Returns(user);
     _validator = new LoginCommandValidator(mockRepo.Object);
 }
Beispiel #7
0
        public void CanValidateInputData(string email, string password, bool expectedResult)
        {
            // Arrange
            var sut = new LoginCommandValidator();

            _command.Email    = email;
            _command.Password = password;

            // Act
            var validationRes = sut.Validate(_command);

            // Assert
            Assert.Equal(expectedResult, validationRes.IsValid);
        }