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);
        }
Пример #2
0
 public CheckoutShippingAddressModel()
 {
     Warnings = new List<string>();
     ExistingAddresses = new List<AddressModel>();
     NewAddress = new AddressModel();
     PickupPoints = new List<CheckoutPickupPointModel>();
 }
 public void Should_have_error_when_lastName_is_null_or_empty()
 {
     var model = new AddressModel();
     model.LastName = null;
     _validator.ShouldHaveValidationErrorFor(x => x.LastName, model);
     model.LastName = "";
     _validator.ShouldHaveValidationErrorFor(x => x.LastName, model);
 }
 public void Should_have_error_when_email_is_null_or_empty()
 {
     var model = new AddressModel();
     model.Email = null;
     _validator.ShouldHaveValidationErrorFor(x => x.Email, model);
     model.Email = "";
     _validator.ShouldHaveValidationErrorFor(x => x.Email, model);
 }
Пример #5
0
        public void Should_not_have_error_when_email_is_correct_format()
        {
            var validator = new AddressValidator(_localizationService, _stateProvinceService,
                new AddressSettings());

            var model = new AddressModel();
            model.Email = "*****@*****.**";
            validator.ShouldNotHaveValidationErrorFor(x => x.Email, model);
        }
Пример #6
0
        public void Should_not_have_error_when_lastName_is_specified()
        {
            var validator = new AddressValidator(_localizationService,
                new AddressSettings());

            var model = new AddressModel();
            model.LastName = "Smith";
            validator.ShouldNotHaveValidationErrorFor(x => x.LastName, model);
        }
Пример #7
0
        public void Should_not_have_error_when_firstName_is_specified()
        {
            var validator = new AddressValidator(_localizationService, _stateProvinceService,
                new AddressSettings());

            var model = new AddressModel();
            model.FirstName = "John";
            validator.ShouldNotHaveValidationErrorFor(x => x.FirstName, model);
        }
Пример #8
0
        public void Should_have_error_when_email_is_wrong_format()
        {
            var validator = new AddressValidator(_localizationService,
                new AddressSettings());

            var model = new AddressModel();
            model.Email = "adminexample.com";
            validator.ShouldHaveValidationErrorFor(x => x.Email, model);
        }
        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);
        }
Пример #10
0
        public void Should_have_error_when_lastName_is_null_or_empty()
        {
            var validator = new AddressValidator(_localizationService, _stateProvinceService,
                new AddressSettings());

            var model = new AddressModel();
            model.LastName = null;
            validator.ShouldHaveValidationErrorFor(x => x.LastName, model);
            model.LastName = "";
            validator.ShouldHaveValidationErrorFor(x => x.LastName, model);
        }
Пример #11
0
        public OrderDetailsModel()
        {
            TaxRates = new List<TaxRate>();
            GiftCards = new List<GiftCard>();
            Items = new List<OrderItemModel>();
            OrderNotes = new List<OrderNote>();
            Shipments = new List<ShipmentBriefModel>();

            BillingAddress = new AddressModel();
            ShippingAddress = new AddressModel();
        }
Пример #12
0
        public OrderDetailsModel()
        {
            TaxRates = new List<TaxRate>();
            GiftCards = new List<GiftCard>();
            Items = new List<OrderItemModel>();
            OrderNotes = new List<OrderNote>();
            Shipments = new List<ShipmentBriefModel>();

            BillingAddress = new AddressModel();
            ShippingAddress = new AddressModel();

            CustomValues = new Dictionary<string, object>();
        }
 public void Should_not_have_error_when_faxNumber_is_not_specified()
 {
     var model = new AddressModel();
     model.FaxNumber = null;
     _validator.ShouldNotHaveValidationErrorFor(x => x.FaxNumber, model);
 }
 public void Should_not_have_error_when_phoneNumber_is_specified()
 {
     var model = new AddressModel();
     model.PhoneNumber = "123456789";
     _validator.ShouldNotHaveValidationErrorFor(x => x.PhoneNumber, model);
 }
 public void Should_have_error_when_phoneNumber_is_null_or_empty()
 {
     var model = new AddressModel();
     model.PhoneNumber = null;
     _validator.ShouldHaveValidationErrorFor(x => x.PhoneNumber, model);
     model.PhoneNumber = "";
     _validator.ShouldHaveValidationErrorFor(x => x.PhoneNumber, model);
 }
 public void Should_not_have_error_when_zipPostalCode_is_specified()
 {
     var model = new AddressModel();
     model.ZipPostalCode = "10001";
     _validator.ShouldNotHaveValidationErrorFor(x => x.ZipPostalCode, model);
 }
 public void Should_have_error_when_country_is_null()
 {
     var model = new AddressModel();
     model.CountryId = null;
     _validator.ShouldHaveValidationErrorFor(x => x.CountryId, model);
 }
 public void Should_not_have_error_when_email_is_correct_format()
 {
     var model = new AddressModel();
     model.Email = "*****@*****.**";
     _validator.ShouldNotHaveValidationErrorFor(x => x.Email, model);
 }
Пример #19
0
        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);
        }
Пример #20
0
        public void Should_not_have_error_when_fax_is_specified()
        {
            var validator = new AddressValidator(_localizationService, _stateProvinceService,
                new AddressSettings
                {
                    FaxEnabled = true
                });

            var model = new AddressModel();
            model.FaxNumber = "Fax";
            validator.ShouldNotHaveValidationErrorFor(x => x.FaxNumber, model);
        }
 public void Should_not_have_error_when_lastName_is_specified()
 {
     var model = new AddressModel();
     model.LastName = "Smith";
     _validator.ShouldNotHaveValidationErrorFor(x => x.LastName, model);
 }
        public ActionResult Addresses()
        {
            if (!IsCurrentUserRegistered())
                return new HttpUnauthorizedResult();

            var customer = _workContext.CurrentCustomer;

            var model = new CustomerAddressListModel();
            model.NavigationModel = GetCustomerNavigationModel(customer);
            model.NavigationModel.SelectedTab = CustomerNavigationEnum.Addresses;
            foreach (var address in customer.Addresses)
            {
                var addressModel = new AddressModel();
                addressModel.PrepareModel(address, false, _addressSettings, _localizationService,
                    _stateProvinceService, () => _countryService.GetAllCountries());
                model.Addresses.Add(addressModel);
            }
            return View(model);
        }
 public void Should_have_error_when_email_is_wrong_format()
 {
     var model = new AddressModel();
     model.Email = "adminexample.com";
     _validator.ShouldHaveValidationErrorFor(x => x.Email, model);
 }
Пример #24
0
        protected CheckoutShippingAddressModel PrepareShippingAddressModel(int? selectedCountryId = null)
        {
            var model = new CheckoutShippingAddressModel();
            //existing addresses
            var addresses = _workContext.CurrentCustomer.Addresses.Where(a => a.Country == null || a.Country.AllowsShipping).ToList();
            foreach (var address in addresses)
            {
                var addressModel = new AddressModel();
                addressModel.PrepareModel(address,
                    false,
                    _addressSettings);
                model.ExistingAddresses.Add(addressModel);
            }

            //new address
            model.NewAddress.CountryId = selectedCountryId;
            model.NewAddress.PrepareModel(null,
                false,
                _addressSettings,
                _localizationService,
                _stateProvinceService,
                () => _countryService.GetAllCountriesForShipping());
            return model;
        }
 public void Should_not_have_error_when_company_is_not_specified()
 {
     var model = new AddressModel();
     model.Company = null;
     _validator.ShouldNotHaveValidationErrorFor(x => x.Company, model);
 }
 public void Should_not_have_error_when_stateProvince_is_not_specified()
 {
     var model = new AddressModel();
     model.StateProvinceId = null;
     _validator.ShouldNotHaveValidationErrorFor(x => x.StateProvinceId, model);
 }
 public void Should_not_have_error_when_country_is_specifed()
 {
     var model = new AddressModel();
     model.CountryId = 1;
     _validator.ShouldNotHaveValidationErrorFor(x => x.CountryId, model);
 }
 public void Should_not_have_error_when_address1_is_specified()
 {
     var model = new AddressModel();
     model.Address1 = "New York";
     _validator.ShouldNotHaveValidationErrorFor(x => x.Address1, model);
 }
Пример #29
0
        public ActionResult Addresses()
        {
            if (!_workContext.CurrentCustomer.IsRegistered())
                return new HttpUnauthorizedResult();

            var customer = _workContext.CurrentCustomer;

            var model = new CustomerAddressListModel();
            var addresses = customer.Addresses
                //enabled for the current store
                .Where(a => a.Country == null || _storeMappingService.Authorize(a.Country))
                .ToList();
            foreach (var address in addresses)
            {
                var addressModel = new AddressModel();
                addressModel.PrepareModel(
                    address: address,
                    excludeProperties: false,
                    addressSettings: _addressSettings,
                    localizationService: _localizationService,
                    stateProvinceService: _stateProvinceService,
                    addressAttributeFormatter: _addressAttributeFormatter,
                    loadCountries: () => _countryService.GetAllCountries(_workContext.WorkingLanguage.Id));
                model.Addresses.Add(addressModel);
            }
            return View(model);
        }
 public void Should_have_error_when_zipPostalCode_is_null_or_empty()
 {
     var model = new AddressModel();
     model.ZipPostalCode = null;
     _validator.ShouldHaveValidationErrorFor(x => x.ZipPostalCode, model);
     model.ZipPostalCode = "";
     _validator.ShouldHaveValidationErrorFor(x => x.ZipPostalCode, model);
 }