public void Can_save_and_load_checkoutAttributeValue() { var cav = new CheckoutAttributeValue() { Name = "Name 2", PriceAdjustment = 1.1M, WeightAdjustment = 2.1M, IsPreSelected = true, DisplayOrder = 3, CheckoutAttribute = new CheckoutAttribute { Name = "Name 1", TextPrompt = "TextPrompt 1", IsRequired = true, ShippableProductRequired = true, IsTaxExempt = true, TaxCategoryId = 1, AttributeControlType = AttributeControlType.Datepicker, DisplayOrder = 2 } }; var fromDb = SaveAndLoadEntity(cav); fromDb.ShouldNotBeNull(); fromDb.Name.ShouldEqual("Name 2"); fromDb.PriceAdjustment.ShouldEqual(1.1M); fromDb.WeightAdjustment.ShouldEqual(2.1M); fromDb.IsPreSelected.ShouldEqual(true); fromDb.DisplayOrder.ShouldEqual(3); fromDb.CheckoutAttribute.ShouldNotBeNull(); fromDb.CheckoutAttribute.Name.ShouldEqual("Name 1"); }
public void UpdateValueLocales(CheckoutAttributeValue checkoutAttributeValue, CheckoutAttributeValueModel model) { foreach (var localized in model.Locales) { _localizedEntityService.SaveLocalizedValue(checkoutAttributeValue, x => x.Name, localized.Name, localized.LanguageId); } }
/// <summary> /// Updates the checkout attribute value /// </summary> /// <param name="checkoutAttributeValue">Checkout attribute value</param> public virtual void UpdateCheckoutAttributeValue(CheckoutAttributeValue checkoutAttributeValue) { if (checkoutAttributeValue == null) throw new ArgumentNullException("checkoutAttributeValue"); _checkoutAttributeValueRepository.Update(checkoutAttributeValue); _cacheManager.RemoveByPattern(CHECKOUTATTRIBUTES_PATTERN_KEY); _cacheManager.RemoveByPattern(CHECKOUTATTRIBUTEVALUES_PATTERN_KEY); //event notification _eventPublisher.EntityUpdated(checkoutAttributeValue); }
public static CheckoutAttributeValue ToEntity(this CheckoutAttributeValueModel model, CheckoutAttributeValue destination) { return Mapper.Map(model, destination); }
public new void SetUp() { #region Test data //color (dropdownlist) ca1 = new CheckoutAttribute { Id = 1, Name= "Color", TextPrompt = "Select color:", IsRequired = true, AttributeControlType = AttributeControlType.DropdownList, DisplayOrder = 1, }; cav1_1 = new CheckoutAttributeValue { Id = 11, Name = "Green", DisplayOrder = 1, CheckoutAttribute = ca1, CheckoutAttributeId = ca1.Id, }; cav1_2 = new CheckoutAttributeValue { Id = 12, Name = "Red", DisplayOrder = 2, CheckoutAttribute = ca1, CheckoutAttributeId = ca1.Id, }; ca1.CheckoutAttributeValues.Add(cav1_1); ca1.CheckoutAttributeValues.Add(cav1_2); //custom option (checkboxes) ca2 = new CheckoutAttribute { Id = 2, Name = "Custom option", TextPrompt = "Select custom option:", IsRequired = true, AttributeControlType = AttributeControlType.Checkboxes, DisplayOrder = 2, }; cav2_1 = new CheckoutAttributeValue { Id = 21, Name = "Option 1", DisplayOrder = 1, CheckoutAttribute = ca2, CheckoutAttributeId = ca2.Id, }; cav2_2 = new CheckoutAttributeValue { Id = 22, Name = "Option 2", DisplayOrder = 2, CheckoutAttribute = ca2, CheckoutAttributeId = ca2.Id, }; ca2.CheckoutAttributeValues.Add(cav2_1); ca2.CheckoutAttributeValues.Add(cav2_2); //custom text ca3 = new CheckoutAttribute { Id = 3, Name = "Custom text", TextPrompt = "Enter custom text:", IsRequired = true, AttributeControlType = AttributeControlType.MultilineTextbox, DisplayOrder = 3, }; #endregion _checkoutAttributeRepo = MockRepository.GenerateMock<IRepository<CheckoutAttribute>>(); _checkoutAttributeRepo.Expect(x => x.Table).Return(new List<CheckoutAttribute>() { ca1, ca2, ca3 }.AsQueryable()); _checkoutAttributeRepo.Expect(x => x.GetById(ca1.Id)).Return(ca1); _checkoutAttributeRepo.Expect(x => x.GetById(ca2.Id)).Return(ca2); _checkoutAttributeRepo.Expect(x => x.GetById(ca3.Id)).Return(ca3); _checkoutAttributeValueRepo = MockRepository.GenerateMock<IRepository<CheckoutAttributeValue>>(); _checkoutAttributeValueRepo.Expect(x => x.Table).Return(new List<CheckoutAttributeValue>() { cav1_1, cav1_2, cav2_1, cav2_2 }.AsQueryable()); _checkoutAttributeValueRepo.Expect(x => x.GetById(cav1_1.Id)).Return(cav1_1); _checkoutAttributeValueRepo.Expect(x => x.GetById(cav1_2.Id)).Return(cav1_2); _checkoutAttributeValueRepo.Expect(x => x.GetById(cav2_1.Id)).Return(cav2_1); _checkoutAttributeValueRepo.Expect(x => x.GetById(cav2_2.Id)).Return(cav2_2); var cacheManager = new NullCache(); _eventPublisher = MockRepository.GenerateMock<IEventPublisher>(); _eventPublisher.Expect(x => x.Publish(Arg<object>.Is.Anything)); _checkoutAttributeService = new CheckoutAttributeService(cacheManager, _checkoutAttributeRepo, _checkoutAttributeValueRepo, _eventPublisher); _checkoutAttributeParser = new CheckoutAttributeParser(_checkoutAttributeService); var workingLanguage = new Language(); _workContext = MockRepository.GenerateMock<IWorkContext>(); _workContext.Expect(x => x.WorkingLanguage).Return(workingLanguage); _currencyService = MockRepository.GenerateMock<ICurrencyService>(); _taxService = MockRepository.GenerateMock<ITaxService>(); _priceFormatter = MockRepository.GenerateMock<IPriceFormatter>(); _downloadService = MockRepository.GenerateMock<IDownloadService>(); _webHelper = MockRepository.GenerateMock<IWebHelper>(); _checkoutAttributeFormatter = new CheckoutAttributeFormatter(_workContext, _checkoutAttributeService, _checkoutAttributeParser, _currencyService, _taxService, _priceFormatter, _downloadService, _webHelper); }