public void Validate_GivenEmailAddressInUse_ShouldHaveError()
            {
                var fakeUserManager = new Mock <IUserManager>();

                fakeUserManager.Setup(x => x.GetUserIdForEmailAddress("*****@*****.**")).Returns(123);
                _fixture.Inject(fakeUserManager.Object);
                RegisterViewModelValidator subject = _fixture.Create <RegisterViewModelValidator>();

                subject.ShouldHaveValidationErrorFor(x => x.EmailAddress, "*****@*****.**");
            }
            public void Validate_GivenPopulatedPasswordButDifferentConfirmPassword_ShouldHaveError()
            {
                RegisterViewModelValidator subject   = _fixture.Create <RegisterViewModelValidator>();
                RegisterViewModel          viewModel = new RegisterViewModel();

                viewModel.Password        = "******";
                viewModel.ConfirmPassword = "******";

                subject.ShouldHaveValidationErrorFor(x => x.ConfirmPassword, viewModel);
            }
        public async Task Validate__Given_role_does_not_exist_in_db__should_be_invalid()
        {
            using (var factory = new DbContextFactory())
            {
                using (var context = await factory.CreateContextAsync())
                {
                    context.Roles.RemoveRange(await context.Roles.ToArrayAsync());
                    await context.SaveChangesAsync();
                }

                using (var context = await factory.CreateContextAsync())
                {
                    var invalidRegisterVM = new RegisterViewModel {
                        Role = "adasd"
                    };
                    var validator = new RegisterViewModelValidator(context);

                    validator.ShouldHaveValidationErrorFor(x => x.Role, invalidRegisterVM);
                }
            }
        }
        public void Validate__Role_is_null_or_empty__Should_be_invalid([Values(null, "")] string role)
        {
            var invalidRegisterVM = new RegisterViewModel {
                Role = role
            };

            _validator.ShouldHaveValidationErrorFor(x => x.EmailAddress, invalidRegisterVM);
        }
            public void Validate_GivenOnlyLetters_ShouldHaveError()
            {
                RegisterViewModelValidator subject = _fixture.Create <RegisterViewModelValidator>();

                subject.ShouldHaveValidationErrorFor(x => x.Password, "superawesomepassword");
            }
            public void Validate_GivenOnlyNumbers_ShouldHaveError()
            {
                RegisterViewModelValidator subject = _fixture.Create <RegisterViewModelValidator>();

                subject.ShouldHaveValidationErrorFor(x => x.Password, "1234567890");
            }
            public void Validate_GivenFewerThan7Characters_ShouldHaveError()
            {
                RegisterViewModelValidator subject = _fixture.Create <RegisterViewModelValidator>();

                subject.ShouldHaveValidationErrorFor(x => x.Password, "p4ss");
            }
            public void Validate_GivenEmptyPassword_ShouldHaveError()
            {
                RegisterViewModelValidator subject = _fixture.Create <RegisterViewModelValidator>();

                subject.ShouldHaveValidationErrorFor(x => x.Password, null as string);
            }
            public void Validate_GivenInvalidEmailAddress_ShouldHaveError()
            {
                RegisterViewModelValidator subject = _fixture.Create <RegisterViewModelValidator>();

                subject.ShouldHaveValidationErrorFor(x => x.EmailAddress, "invalid email address");
            }
            public void Validate_GivenInvalidPhoneNumber_ShouldHaveError()
            {
                RegisterViewModelValidator subject = _fixture.Create <RegisterViewModelValidator>();

                subject.ShouldHaveValidationErrorFor(x => x.PhoneNumber, "123 Invalid 456 Phone Number");
            }
            public void Validate_GivenInvalidAccounttype_ShouldHaveError()
            {
                RegisterViewModelValidator subject = _fixture.Create <RegisterViewModelValidator>();

                subject.ShouldHaveValidationErrorFor(x => x.AccountType, "NotAValidAccounType");
            }