本文整理汇总了C#中CustomerInfoValidator.ShouldHaveValidationErrorFor方法的典型用法代码示例。如果您正苦于以下问题:C# CustomerInfoValidator.ShouldHaveValidationErrorFor方法的具体用法?C# CustomerInfoValidator.ShouldHaveValidationErrorFor怎么用?C# CustomerInfoValidator.ShouldHaveValidationErrorFor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CustomerInfoValidator
的用法示例。
在下文中一共展示了CustomerInfoValidator.ShouldHaveValidationErrorFor方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 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: Should_have_error_when_email_is_null_or_empty
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);
}
示例3: Should_have_error_when_lastName_is_null_or_empty
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);
}
示例4: Should_have_error_when_firstName_is_null_or_empty
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);
}
示例5: Should_have_error_when_email_is_null_or_empty
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);
}
示例6: Should_have_error_when_email_is_wrong_format
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);
}
示例7: 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 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);
}
示例8: 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 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);
}
示例9: 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 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);
}
示例10: 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 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);
}