当前位置: 首页>>代码示例>>C#>>正文


C# AddressValidator.ShouldHaveValidationErrorFor方法代码示例

本文整理汇总了C#中AddressValidator.ShouldHaveValidationErrorFor方法的典型用法代码示例。如果您正苦于以下问题:C# AddressValidator.ShouldHaveValidationErrorFor方法的具体用法?C# AddressValidator.ShouldHaveValidationErrorFor怎么用?C# AddressValidator.ShouldHaveValidationErrorFor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AddressValidator的用法示例。


在下文中一共展示了AddressValidator.ShouldHaveValidationErrorFor方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Should_have_error_when_company_is_null_or_empty_based_on_required_setting

        public void Should_have_error_when_company_is_null_or_empty_based_on_required_setting()
        {
            var model = new AddressModel();

            //required
            var validator = new AddressValidator(_localizationService,
                new AddressSettings()
                {
                    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 AddressValidator(_localizationService,
                new AddressSettings()
                {
                    CompanyEnabled = true,
                    CompanyRequired = false
                });
            model.Company = null;
            validator.ShouldNotHaveValidationErrorFor(x => x.Company, model);
            model.Company = "";
            validator.ShouldNotHaveValidationErrorFor(x => x.Company, model);
        }
开发者ID:emretiryaki,项目名称:paymill-nopcommerce,代码行数:28,代码来源:AddressValidatorTests.cs

示例2: Should_have_error_when_firstName_is_null_or_empty

        public void Should_have_error_when_firstName_is_null_or_empty()
        {
            var validator = new AddressValidator(_localizationService, _stateProvinceService,
                new AddressSettings());

            var model = new AddressModel();
            model.FirstName = null;
            validator.ShouldHaveValidationErrorFor(x => x.FirstName, model);
            model.FirstName = "";
            validator.ShouldHaveValidationErrorFor(x => x.FirstName, model);
        }
开发者ID:nvolpe,项目名称:raver,代码行数:11,代码来源:AddressValidatorTests.cs

示例3: Should_have_error_when_email_is_null_or_empty

        public void Should_have_error_when_email_is_null_or_empty()
        {
            var validator = new AddressValidator(_localizationService,
                new AddressSettings());

            var model = new AddressModel();
            model.Email = null;
            validator.ShouldHaveValidationErrorFor(x => x.Email, model);
            model.Email = "";
            validator.ShouldHaveValidationErrorFor(x => x.Email, model);
        }
开发者ID:JeffersonNascimento,项目名称:SmartStoreNET,代码行数:11,代码来源:AddressValidatorTests.cs

示例4: Should_have_error_when_email_is_wrong_format

        public void Should_have_error_when_email_is_wrong_format()
        {
            var validator = new AddressValidator(_localizationService, _stateProvinceService,
                new AddressSettings());

            var model = new AddressModel();
            model.Email = "adminexample.com";
            validator.ShouldHaveValidationErrorFor(x => x.Email, model);
        }
开发者ID:nvolpe,项目名称:raver,代码行数:9,代码来源:AddressValidatorTests.cs

示例5: Should_have_error_when_fax_is_null_or_empty_based_on_required_setting

        public void Should_have_error_when_fax_is_null_or_empty_based_on_required_setting()
        {
            var model = new AddressModel();

            //required
            var validator = new AddressValidator(_localizationService, _stateProvinceService,
                new AddressSettings
                {
                    FaxEnabled = true,
                    FaxRequired = true
                });
            model.FaxNumber = null;
            validator.ShouldHaveValidationErrorFor(x => x.FaxNumber, model);
            model.FaxNumber = "";
            validator.ShouldHaveValidationErrorFor(x => x.FaxNumber, model);


            //not required
            validator = new AddressValidator(_localizationService, _stateProvinceService,
                new AddressSettings
                {
                    FaxEnabled = true,
                    FaxRequired = false
                });
            model.FaxNumber = null;
            validator.ShouldNotHaveValidationErrorFor(x => x.FaxNumber, model);
            model.FaxNumber = "";
            validator.ShouldNotHaveValidationErrorFor(x => x.FaxNumber, model);
        }
开发者ID:nvolpe,项目名称:raver,代码行数:29,代码来源:AddressValidatorTests.cs

示例6: Should_have_error_when_zippostalcode_is_null_or_empty_based_on_required_setting

        public void Should_have_error_when_zippostalcode_is_null_or_empty_based_on_required_setting()
        {
            var model = new AddressModel();

            //required
            var validator = new AddressValidator(_localizationService, _stateProvinceService,
                new AddressSettings
                {
                    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 AddressValidator(_localizationService, _stateProvinceService,
                new AddressSettings
                {
                    ZipPostalCodeEnabled = true,
                    ZipPostalCodeRequired = false
                });
            model.ZipPostalCode = null;
            validator.ShouldNotHaveValidationErrorFor(x => x.ZipPostalCode, model);
            model.ZipPostalCode = "";
            validator.ShouldNotHaveValidationErrorFor(x => x.ZipPostalCode, model);
        }
开发者ID:nvolpe,项目名称:raver,代码行数:29,代码来源:AddressValidatorTests.cs

示例7: Should_have_error_when_streetaddress_is_null_or_empty_based_on_required_setting

        public void Should_have_error_when_streetaddress_is_null_or_empty_based_on_required_setting()
        {
            var model = new AddressModel();

            //required
            var validator = new AddressValidator(_localizationService,
                new AddressSettings()
                {
                    StreetAddressEnabled = true,
                    StreetAddressRequired = true
                });
            model.Address1 = null;
            validator.ShouldHaveValidationErrorFor(x => x.Address1, model);
            model.Address1 = "";
            validator.ShouldHaveValidationErrorFor(x => x.Address1, model);

            //not required
            validator = new AddressValidator(_localizationService,
                new AddressSettings()
                {
                    StreetAddressEnabled = true,
                    StreetAddressRequired = false
                });
            model.Address1 = null;
            validator.ShouldNotHaveValidationErrorFor(x => x.Address1, model);
            model.Address1 = "";
            validator.ShouldNotHaveValidationErrorFor(x => x.Address1, model);
        }
开发者ID:emretiryaki,项目名称:paymill-nopcommerce,代码行数:28,代码来源:AddressValidatorTests.cs

示例8: Should_have_error_when_phone_is_null_or_empty_based_on_required_setting

        public void Should_have_error_when_phone_is_null_or_empty_based_on_required_setting()
        {
            var model = new AddressModel();

            //required
            var validator = new AddressValidator(_localizationService,
                new AddressSettings()
                {
                    PhoneEnabled = true,
                    PhoneRequired = true
                });
            model.PhoneNumber = null;
            validator.ShouldHaveValidationErrorFor(x => x.PhoneNumber, model);
            model.PhoneNumber = "";
            validator.ShouldHaveValidationErrorFor(x => x.PhoneNumber, model);

            //not required
            validator = new AddressValidator(_localizationService,
                new AddressSettings()
                {
                    PhoneEnabled = true,
                    PhoneRequired = false
                });
            model.PhoneNumber = null;
            validator.ShouldNotHaveValidationErrorFor(x => x.PhoneNumber, model);
            model.PhoneNumber = "";
            validator.ShouldNotHaveValidationErrorFor(x => x.PhoneNumber, model);
        }
开发者ID:emretiryaki,项目名称:paymill-nopcommerce,代码行数:28,代码来源:AddressValidatorTests.cs


注:本文中的AddressValidator.ShouldHaveValidationErrorFor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。