コード例 #1
0
        public void Should_have_error_when_company_is_null_or_empty_based_on_required_setting()
        {
            var model = new CustomerInfoModel();

            //required
            var validator = new CustomerInfoValidator(_localizationService,
                new CustomerSettings()
                {
                    CompanyEnabled = true,
                    CompanyRequired = true
                });
            model.Company = null;
            validator.ShouldHaveValidationErrorFor(x => x.Company, model);
            model.Company = "";
            validator.ShouldHaveValidationErrorFor(x => x.Company, model);

            //not required
            validator = new CustomerInfoValidator(_localizationService,
                new CustomerSettings()
                {
                    CompanyEnabled = true,
                    CompanyRequired = false
                });
            model.Company = null;
            validator.ShouldNotHaveValidationErrorFor(x => x.Company, model);
            model.Company = "";
            validator.ShouldNotHaveValidationErrorFor(x => x.Company, model);
        }
コード例 #2
0
        public void Should_have_error_when_phone_is_null_or_empty_based_on_required_setting()
        {
            var model = new CustomerInfoModel();

            //required
            var validator = new CustomerInfoValidator(_localizationService,
                                                      new CustomerSettings()
            {
                PhoneEnabled  = true,
                PhoneRequired = true
            });

            model.Phone = null;
            validator.ShouldHaveValidationErrorFor(x => x.Phone, model);
            model.Phone = "";
            validator.ShouldHaveValidationErrorFor(x => x.Phone, model);

            //not required
            validator = new CustomerInfoValidator(_localizationService,
                                                  new CustomerSettings()
            {
                PhoneEnabled  = true,
                PhoneRequired = false
            });
            model.Phone = null;
            validator.ShouldNotHaveValidationErrorFor(x => x.Phone, model);
            model.Phone = "";
            validator.ShouldNotHaveValidationErrorFor(x => x.Phone, model);
        }
コード例 #3
0
        public void Should_have_error_when_streetaddress2_is_null_or_empty_based_on_required_setting()
        {
            var model = new CustomerInfoModel();

            //required
            var validator = new CustomerInfoValidator(_localizationService,
                                                      new CustomerSettings()
            {
                StreetAddress2Enabled  = true,
                StreetAddress2Required = true
            });

            model.StreetAddress2 = null;
            validator.ShouldHaveValidationErrorFor(x => x.StreetAddress2, model);
            model.StreetAddress2 = "";
            validator.ShouldHaveValidationErrorFor(x => x.StreetAddress2, model);

            //not required
            validator = new CustomerInfoValidator(_localizationService,
                                                  new CustomerSettings()
            {
                StreetAddress2Enabled  = true,
                StreetAddress2Required = false
            });
            model.StreetAddress2 = null;
            validator.ShouldNotHaveValidationErrorFor(x => x.StreetAddress2, model);
            model.StreetAddress2 = "";
            validator.ShouldNotHaveValidationErrorFor(x => x.StreetAddress2, model);
        }
コード例 #4
0
        public void Should_have_error_when_fax_is_null_or_empty_based_on_required_setting()
        {
            var model = new CustomerInfoModel();

            //required
            var validator = new CustomerInfoValidator(_localizationService, _stateProvinceService,
                                                      new CustomerSettings
            {
                FaxEnabled  = true,
                FaxRequired = true
            });

            model.Fax = null;
            validator.ShouldHaveValidationErrorFor(x => x.Fax, model);
            model.Fax = "";
            validator.ShouldHaveValidationErrorFor(x => x.Fax, model);


            //not required
            validator = new CustomerInfoValidator(_localizationService, _stateProvinceService,
                                                  new CustomerSettings
            {
                FaxEnabled  = true,
                FaxRequired = false
            });
            model.Fax = null;
            validator.ShouldNotHaveValidationErrorFor(x => x.Fax, model);
            model.Fax = "";
            validator.ShouldNotHaveValidationErrorFor(x => x.Fax, model);
        }
コード例 #5
0
        public void Should_have_error_when_zippostalcode_is_null_or_empty_based_on_required_setting()
        {
            var model = new CustomerInfoModel();

            //required
            var validator = new CustomerInfoValidator(_localizationService, _stateProvinceService,
                                                      new CustomerSettings
            {
                ZipPostalCodeEnabled  = true,
                ZipPostalCodeRequired = true
            });

            model.ZipPostalCode = null;
            validator.ShouldHaveValidationErrorFor(x => x.ZipPostalCode, model);
            model.ZipPostalCode = "";
            validator.ShouldHaveValidationErrorFor(x => x.ZipPostalCode, model);


            //not required
            validator = new CustomerInfoValidator(_localizationService, _stateProvinceService,
                                                  new CustomerSettings
            {
                ZipPostalCodeEnabled  = true,
                ZipPostalCodeRequired = false
            });
            model.ZipPostalCode = null;
            validator.ShouldNotHaveValidationErrorFor(x => x.ZipPostalCode, model);
            model.ZipPostalCode = "";
            validator.ShouldNotHaveValidationErrorFor(x => x.ZipPostalCode, model);
        }
        public void Should_have_error_when_lastName_is_null_or_empty()
        {
            var customerSettings = new CustomerSettings();
            var validator = new CustomerInfoValidator(_localizationService, customerSettings);

            var model = new CustomerInfoModel();
            model.LastName = null;
            validator.ShouldHaveValidationErrorFor(x => x.LastName, model);
            model.LastName = "";
            validator.ShouldHaveValidationErrorFor(x => x.LastName, model);
        }
コード例 #7
0
        public void Should_have_error_when_email_is_null_or_empty()
        {
            var validator = new CustomerInfoValidator(new CustomerSettings());

            var model = new CustomerInfoModel();

            model.Email = null;
            validator.ShouldHaveValidationErrorFor(x => x.Email, model);
            model.Email = "";
            validator.ShouldHaveValidationErrorFor(x => x.Email, model);
        }
コード例 #8
0
        public void Should_have_error_when_email_is_null_or_empty()
        {
            var validator = new CustomerInfoValidator(_localizationService,
                new CustomerSettings());

            var model = new CustomerInfoModel();
            model.Email = null;
            validator.ShouldHaveValidationErrorFor(x => x.Email, model);
            model.Email = "";
            validator.ShouldHaveValidationErrorFor(x => x.Email, model);
        }
コード例 #9
0
        public void Should_have_error_when_firstName_is_null_or_empty()
        {
            var validator = new CustomerInfoValidator(_localizationService, _stateProvinceService, 
                new CustomerSettings());

            var model = new CustomerInfoModel();
            model.FirstName = null;
            validator.ShouldHaveValidationErrorFor(x => x.FirstName, model);
            model.FirstName = "";
            validator.ShouldHaveValidationErrorFor(x => x.FirstName, model);
        }
コード例 #10
0
        public void Should_have_error_when_firstName_is_null_or_empty()
        {
            var validator = new CustomerInfoValidator(_localizationService, _stateProvinceService,
                                                      new CustomerSettings());

            var model = new CustomerInfoModel();

            model.FirstName = null;
            validator.ShouldHaveValidationErrorFor(x => x.FirstName, model);
            model.FirstName = "";
            validator.ShouldHaveValidationErrorFor(x => x.FirstName, model);
        }
コード例 #11
0
        public void Should_have_error_when_lastName_is_null_or_empty()
        {
            var customerSettings = new CustomerSettings();
            var validator        = new CustomerInfoValidator(_localizationService, customerSettings);

            var model = new CustomerInfoModel();

            model.LastName = null;
            validator.ShouldHaveValidationErrorFor(x => x.LastName, model);
            model.LastName = "";
            validator.ShouldHaveValidationErrorFor(x => x.LastName, model);
        }
コード例 #12
0
        public void Should_have_error_when_email_is_null_or_empty()
        {
            _stateProvinceService = MockRepository.GenerateMock<IStateProvinceService>();

            var validator = new CustomerInfoValidator(_localizationService, _stateProvinceService, new CustomerSettings());

            var model = new CustomerInfoModel();
            model.Email = null;
            validator.ShouldHaveValidationErrorFor(x => x.Email, model);
            model.Email = "";
            validator.ShouldHaveValidationErrorFor(x => x.Email, model);
        }
コード例 #13
0
        public void Should_have_error_when_email_is_null_or_empty()
        {
            _stateProvinceService = MockRepository.GenerateMock <IStateProvinceService>();

            var validator = new CustomerInfoValidator(_localizationService, _stateProvinceService, new CustomerSettings());

            var model = new CustomerInfoModel();

            model.Email = null;
            validator.ShouldHaveValidationErrorFor(x => x.Email, model);
            model.Email = "";
            validator.ShouldHaveValidationErrorFor(x => x.Email, model);
        }
コード例 #14
0
        public void ShouldHaveErrorWhenFirstNameIsNullOrEmpty()
        {
            var validator = new CustomerInfoValidator(_localizationService, _stateProvinceService,
                                                      new CustomerSettings
            {
                FirstNameEnabled  = true,
                FirstNameRequired = true
            });

            var model = new CustomerInfoModel
            {
                FirstName = null
            };

            validator.ShouldHaveValidationErrorFor(x => x.FirstName, model);
            model.FirstName = string.Empty;
            validator.ShouldHaveValidationErrorFor(x => x.FirstName, model);
        }
コード例 #15
0
        public void Should_have_error_when_email_is_wrong_format()
        {
            var validator = new CustomerInfoValidator(new CustomerSettings());

            var model = new CustomerInfoModel();

            model.Email = "adminexample.com";
            validator.ShouldHaveValidationErrorFor(x => x.Email, model);
        }
コード例 #16
0
        public void Should_have_error_when_email_is_wrong_format()
        {
            var validator = new CustomerInfoValidator(_localizationService, 
                new CustomerSettings());

            var model = new CustomerInfoModel();
            model.Email = "adminexample.com";
            validator.ShouldHaveValidationErrorFor(x => x.Email, model);
        }
コード例 #17
0
        public void Should_have_error_when_email_is_wrong_format()
        {
            var validator = new CustomerInfoValidator(_localizationService, _stateProvinceService,
                                                      new CustomerSettings());

            var model = new CustomerInfoModel
            {
                Email = "adminexample.com"
            };

            validator.ShouldHaveValidationErrorFor(x => x.Email, model);
        }
コード例 #18
0
        public void Should_have_error_when_city_is_null_or_empty_based_on_required_setting()
        {
            var customerSettings = new CustomerSettings()
            {
                CityEnabled = true
            };
            var validator = new CustomerInfoValidator(_localizationService, customerSettings);

            var model = new CustomerInfoModel();

            //required
            customerSettings.CityRequired = true;
            model.City = null;
            validator.ShouldHaveValidationErrorFor(x => x.City, model);
            model.City = "";
            validator.ShouldHaveValidationErrorFor(x => x.City, model);
            //not required
            customerSettings.CityRequired = false;
            model.City = null;
            validator.ShouldNotHaveValidationErrorFor(x => x.City, model);
            model.City = "";
            validator.ShouldNotHaveValidationErrorFor(x => x.City, model);
        }
        public void Should_have_error_when_fax_is_null_or_empty_based_on_required_setting()
        {
            var customerSettings = new CustomerSettings()
            {
                FaxEnabled = true
            };
            var validator = new CustomerInfoValidator(_localizationService, customerSettings);

            var model = new CustomerInfoModel();
            //required
            customerSettings.FaxRequired = true;
            model.Fax = null;
            validator.ShouldHaveValidationErrorFor(x => x.Fax, model);
            model.Fax = "";
            validator.ShouldHaveValidationErrorFor(x => x.Fax, model);
            //not required
            customerSettings.FaxRequired = false;
            model.Fax = null;
            validator.ShouldNotHaveValidationErrorFor(x => x.Fax, model);
            model.Fax = "";
            validator.ShouldNotHaveValidationErrorFor(x => x.Fax, model);
        }
コード例 #20
0
        public void Should_have_error_when_zippostalcode_is_null_or_empty_based_on_required_setting()
        {
            var model = new CustomerInfoModel();

            //required
            var validator = new CustomerInfoValidator(_localizationService,
                new CustomerSettings()
                {
                    ZipPostalCodeEnabled = true,
                    ZipPostalCodeRequired = true
                });
            model.ZipPostalCode = null;
            validator.ShouldHaveValidationErrorFor(x => x.ZipPostalCode, model);
            model.ZipPostalCode = "";
            validator.ShouldHaveValidationErrorFor(x => x.ZipPostalCode, model);

            //not required
            validator = new CustomerInfoValidator(_localizationService,
                new CustomerSettings()
                {
                    ZipPostalCodeEnabled = true,
                    ZipPostalCodeRequired = false
                });
            model.ZipPostalCode = null;
            validator.ShouldNotHaveValidationErrorFor(x => x.ZipPostalCode, model);
            model.ZipPostalCode = "";
            validator.ShouldNotHaveValidationErrorFor(x => x.ZipPostalCode, model);
        }
コード例 #21
0
        public void Should_have_error_when_streetaddress_is_null_or_empty_based_on_required_setting()
        {
            var model = new CustomerInfoModel();

            //required
            var validator = new CustomerInfoValidator(_localizationService,
                new CustomerSettings()
                {
                    StreetAddressEnabled = true,
                    StreetAddressRequired = true
                });
            model.StreetAddress = null;
            validator.ShouldHaveValidationErrorFor(x => x.StreetAddress, model);
            model.StreetAddress = "";
            validator.ShouldHaveValidationErrorFor(x => x.StreetAddress, model);

            //not required
            validator = new CustomerInfoValidator(_localizationService,
                new CustomerSettings()
                {
                    StreetAddressEnabled = true,
                    StreetAddressRequired = false
                });
            model.StreetAddress = null;
            validator.ShouldNotHaveValidationErrorFor(x => x.StreetAddress, model);
            model.StreetAddress = "";
            validator.ShouldNotHaveValidationErrorFor(x => x.StreetAddress, model);
        }
コード例 #22
0
        public void Should_have_error_when_phone_is_null_or_empty_based_on_required_setting()
        {
            var model = new CustomerInfoModel();

            //required
            var validator = new CustomerInfoValidator(_localizationService, _stateProvinceService,
                new CustomerSettings
                {
                    PhoneEnabled = true,
                    PhoneRequired = true
                });
            model.Phone = null;
            validator.ShouldHaveValidationErrorFor(x => x.Phone, model);
            model.Phone = "";
            validator.ShouldHaveValidationErrorFor(x => x.Phone, model);

            //not required
            validator = new CustomerInfoValidator(_localizationService, _stateProvinceService,
                new CustomerSettings
                {
                    PhoneEnabled = true,
                    PhoneRequired = false
                });
            model.Phone = null;
            validator.ShouldNotHaveValidationErrorFor(x => x.Phone, model);
            model.Phone = "";
            validator.ShouldNotHaveValidationErrorFor(x => x.Phone, model);
        }