public UserManager(StoreConfiguration <TUser, TClaim, TLogin> storeCollection,
                    ValidationConfiguration <TUser> validationConfiguration, ILogger logger)
 {
     if (storeCollection == null)
     {
         throw new ArgumentNullException(nameof(storeCollection));
     }
     if (storeCollection.Validate() != null)
     {
         throw new ArgumentNullException(storeCollection.Validate());
     }
     if (validationConfiguration == null)
     {
         throw new ArgumentNullException(nameof(validationConfiguration));
     }
     if (validationConfiguration.Validate() != null)
     {
         throw new ArgumentNullException(validationConfiguration.Validate());
     }
     UserStore               = storeCollection.UserStore;
     PasswordStore           = storeCollection.PasswordStore;
     EmailStore              = storeCollection.EmailStore;
     ClaimStore              = storeCollection.ClaimStore;
     TokenStore              = storeCollection.TokenStore;
     LockoutStore            = storeCollection.LockoutStore;
     ValidationConfiguration = validationConfiguration;
     Logger = logger;
 }
        public void TestFixtureSetUp()
        {
            _testViewModel           = new TestViewModel();
            _validationConfiguration = new ValidationConfiguration();

            var convention0 = new DefaultPropertyConvention(x => !x.Name.StartsWith("Optional"));

            convention0.AddValidationRule <IsRequired <CanBeAnyViewModel> >();
            _validationConfiguration.DefaultPropertyConventions.AddDefaultPropertyConvention(convention0);

            var convention1 = new DefaultPropertyConvention(x => x.Name.Contains("Url"));

            convention1.AddValidationRule <IsUrl <CanBeAnyViewModel> >();
            _validationConfiguration.DefaultPropertyConventions.AddDefaultPropertyConvention(convention1);

            var convention2 = new DefaultPropertyConvention(x => x.Name.Contains("Email"));

            convention2.AddValidationRule <IsEmail <CanBeAnyViewModel> >();
            _validationConfiguration.DefaultPropertyConventions.AddDefaultPropertyConvention(convention2);

            _validationConfiguration.DiscoveredTypes.AddDiscoveredType <TestViewModel>();

            IValidationResults <TestViewModel> validationResults = _validationConfiguration.Validate(_testViewModel);

            _testViewModel.ValidationResults.CloneFrom(validationResults);

            _testView = new TestView();
            _testView.SetModel(_testViewModel);
        }
        public void Should_not_output_auto_navigation_script_when_view_mode_is_valid()
        {
            var model = new ValidTestViewModel();

            _validationConfiguration.Validate(model);
            _testView.SetModel(model);

            _testView.Validate()
            .NavigateHereWhenInvalid()
            .ToString()
            .ShouldEqual(string.Empty);
        }
        public void TestFixtureSetUp()
        {
            _testViewModel = new TestViewModel();
            _validationConfiguration = new ValidationConfiguration();

            var convention0 = new DefaultPropertyConvention(x => !x.Name.StartsWith("Optional"));
            convention0.AddValidationRule<IsRequired<CanBeAnyViewModel>>();
            _validationConfiguration.DefaultPropertyConventions.AddDefaultPropertyConvention(convention0);

            var convention1 = new DefaultPropertyConvention(x => x.Name.Contains("Url"));
            convention1.AddValidationRule<IsUrl<CanBeAnyViewModel>>();
            _validationConfiguration.DefaultPropertyConventions.AddDefaultPropertyConvention(convention1);

            var convention2 = new DefaultPropertyConvention(x => x.Name.Contains("Email"));
            convention2.AddValidationRule<IsEmail<CanBeAnyViewModel>>();
            _validationConfiguration.DefaultPropertyConventions.AddDefaultPropertyConvention(convention2);

            _validationConfiguration.DiscoveredTypes.AddDiscoveredType<TestViewModel>();

            IValidationResults<TestViewModel> validationResults = _validationConfiguration.Validate(_testViewModel);
            _testViewModel.ValidationResults.CloneFrom(validationResults);

            _testView = new TestView();
            _testView.SetModel(_testViewModel);
        }
Exemple #5
0
        public void Should_be_able_to_validate_a_view_model_that_implements_ICanBeValidated()
        {
            IValidationResults <TestViewModel> validationResults = _validationConfiguration.Validate(_testViewModel);

            validationResults.ShouldNotBeNull();
        }