public void Can_get_customer_timeZone_with_customTimeZones_enabled() { _dateTimeSettings.AllowCustomersToSetTimeZone = true; _dateTimeSettings.DefaultStoreTimeZoneId = "E. Europe Standard Time"; //(GMT+02:00) Minsk; var customer = new Customer() { Id = 10 }; _genericAttributeService.Expect(x => x.GetAttributesForEntity(customer.Id, "Customer")) .Return(new List <GenericAttribute>() { new GenericAttribute() { StoreId = 0, EntityId = customer.Id, Key = SystemCustomerAttributeNames.TimeZoneId, KeyGroup = "Customer", Value = "Russian Standard Time" //(GMT+03:00) Moscow, St. Petersburg, Volgograd } }); var timeZone = _dateTimeHelper.GetCustomerTimeZone(customer); timeZone.ShouldNotBeNull(); timeZone.Id.ShouldEqual("Russian Standard Time"); }
public void Should_accept_valid_discount_code() { var discount = new Discount { DiscountType = DiscountType.AssignedToSkus, Name = "Discount 2", UsePercentage = false, DiscountPercentage = 0, DiscountAmount = 5, RequiresCouponCode = true, CouponCode = "CouponCode 1", DiscountLimitation = DiscountLimitationType.Unlimited, }; var customer = new Customer { CustomerGuid = Guid.NewGuid(), AdminComment = "", Active = true, Deleted = false, CreatedOnUtc = new DateTime(2010, 01, 01), LastActivityDateUtc = new DateTime(2010, 01, 02) }; _genericAttributeService.Expect(x => x.GetAttribute <string>(nameof(Customer), customer.Id, SystemCustomerAttributeNames.DiscountCouponCode, 0)) .Return("CouponCode 1"); var result1 = _discountService.IsDiscountValid(discount, customer); result1.ShouldEqual(true); }
public void Should_accept_valid_discount_code() { var discount = new Discount { DiscountType = DiscountType.AssignedToSkus, Name = "Discount 2", UsePercentage = false, DiscountPercentage = 0, DiscountAmount = 5, RequiresCouponCode = true, CouponCode = "CouponCode 1", DiscountLimitation = DiscountLimitationType.Unlimited, }; var customer = new Customer { CustomerGuid = Guid.NewGuid(), AdminComment = "", Active = true, Deleted = false, CreatedOnUtc = new DateTime(2010, 01, 01), LastActivityDateUtc = new DateTime(2010, 01, 02) }; _genericAttributeService.Expect(x => x.GetAttributesForEntity(customer.Id, "Customer")) .Return(new List <GenericAttribute> { new GenericAttribute { EntityId = customer.Id, Key = SystemCustomerAttributeNames.DiscountCouponCode, KeyGroup = "Customer", Value = "CouponCode 1" } }); //UNDONE: little workaround here //we have to register "nop_cache_static" cache manager (null manager) from DependencyRegistrar.cs //because DiscountService right now dynamically Resolve<ICacheManager>("nop_cache_static") //we cannot inject it because DiscountService already has "per-request" cache manager injected EngineContext.Initialize(false); //EngineContext.Current.ContainerManager.Expect(x => x.Resolve<ICacheManager>("nop_cache_static")).Return(new NopNullCache()); _discountService.ValidateDiscount(discount, customer).IsValid.ShouldEqual(true); }
public void Can_get_customer_timeZone_with_customTimeZones_enabled() { _dateTimeSettings.AllowCustomersToSetTimeZone = true; _dateTimeSettings.DefaultStoreTimeZoneId = "E. Europe Standard Time"; // (GMT+02:00) Minsk; var customer = new Customer { Id = 10 }; _genericAttributeService .Expect(x => x.GetAttribute <string>(nameof(Customer), customer.Id, SystemCustomerAttributeNames.TimeZoneId, 0)) .Return("Russian Standard Time"); // (GMT+03:00) Moscow, St. Petersburg, Volgograd var timeZone = _dateTimeHelper.GetCustomerTimeZone(customer); timeZone.ShouldNotBeNull(); timeZone.Id.ShouldEqual("Russian Standard Time"); }
public void Should_accept_valid_discount_code() { var discount = new Discount { DiscountType = DiscountType.AssignedToSkus, Name = "Discount 2", UsePercentage = false, DiscountPercentage = 0, DiscountAmount = 5, RequiresCouponCode = true, CouponCode = "CouponCode 1", DiscountLimitation = DiscountLimitationType.Unlimited, }; var customer = new Customer { CustomerGuid = Guid.NewGuid(), AdminComment = "", Active = true, Deleted = false, CreatedOnUtc = new DateTime(2010, 01, 01), LastActivityDateUtc = new DateTime(2010, 01, 02) }; _genericAttributeService.Expect(x => x.GetAttributesForEntity(customer.Id, "Customer")) .Return(new List <GenericAttribute> { new GenericAttribute { EntityId = customer.Id, Key = SystemCustomerAttributeNames.DiscountCouponCode, KeyGroup = "Customer", Value = "CouponCode 1" } }); _discountService.ValidateDiscount(discount, customer).IsValid.ShouldEqual(true); }
public new void SetUp() { _pictureService = MockRepository.GenerateMock <IPictureService>(); _authenticationService = MockRepository.GenerateMock <IAuthenticationService>(); _localizationService = MockRepository.GenerateMock <ILocalizationService>(); _workContext = MockRepository.GenerateMock <IWorkContext>(); _vendorService = MockRepository.GenerateMock <IVendorService>(); _productTemplateService = MockRepository.GenerateMock <IProductTemplateService>(); _dateRangeService = MockRepository.GenerateMock <IDateRangeService>(); _genericAttributeService = MockRepository.GenerateMock <IGenericAttributeService>(); _storeService = MockRepository.GenerateMock <IStoreService>(); _productAttributeService = MockRepository.GenerateMock <IProductAttributeService>(); _taxCategoryService = MockRepository.GenerateMock <ITaxCategoryService>(); _measureService = MockRepository.GenerateMock <IMeasureService>(); _catalogSettings = new CatalogSettings(); _specificationAttributeService = MockRepository.GenerateMock <ISpecificationAttributeService>(); _orderSettings = new OrderSettings(); _categoryService = MockRepository.GenerateMock <ICategoryService>(); _manufacturerService = MockRepository.GenerateMock <IManufacturerService>(); _customerService = MockRepository.GenerateMock <ICustomerService>(); _newsLetterSubscriptionService = MockRepository.GenerateMock <INewsLetterSubscriptionService>(); _productEditorSettings = new ProductEditorSettings(); _customerAttributeFormatter = MockRepository.GenerateMock <ICustomerAttributeFormatter>(); var httpContextAccessor = MockRepository.GenerateMock <IHttpContextAccessor>(); var nopEngine = MockRepository.GenerateMock <NopEngine>(); var serviceProvider = MockRepository.GenerateMock <IServiceProvider>(); var urlRecordService = MockRepository.GenerateMock <IUrlRecordService>(); var picture = new Picture { Id = 1, SeoFilename = "picture" }; _genericAttributeService.Expect(p => p.GetAttributesForEntity(1, "Customer")) .Return(new List <GenericAttribute> { new GenericAttribute { EntityId = 1, Key = "manufacturer-advanced-mode", KeyGroup = "Customer", StoreId = 0, Value = "true" } }); _authenticationService.Expect(p => p.GetAuthenticatedCustomer()).Return(GetTestCustomer()); _pictureService.Expect(p => p.GetPictureById(1)).Return(picture); _pictureService.Expect(p => p.GetThumbLocalPath(picture)).Return(@"c:\temp\picture.png"); _pictureService.Expect(p => p.GetPicturesByProductId(1, 3)).Return(new List <Picture> { picture }); _productTemplateService.Expect(p => p.GetAllProductTemplates()).Return(new List <ProductTemplate> { new ProductTemplate { Id = 1 } }); _dateRangeService.Expect(d => d.GetAllDeliveryDates()).Return(new List <DeliveryDate> { new DeliveryDate { Id = 1 } }); _dateRangeService.Expect(d => d.GetAllProductAvailabilityRanges()).Return(new List <ProductAvailabilityRange> { new ProductAvailabilityRange { Id = 1 } }); _taxCategoryService.Expect(t => t.GetAllTaxCategories()).Return(new List <TaxCategory> { new TaxCategory() }); _vendorService.Expect(v => v.GetAllVendors(showHidden: true)).Return(new PagedList <Vendor>(new List <Vendor> { new Vendor { Id = 1 } }, 0, 10)); _measureService.Expect(m => m.GetAllMeasureWeights()).Return(new List <MeasureWeight> { new MeasureWeight() }); _categoryService.Expect(c => c.GetProductCategoriesByProductId(1, true)).Return(new List <ProductCategory>()); _manufacturerService.Expect(m => m.GetProductManufacturersByProductId(1, true)).Return(new List <ProductManufacturer>()); nopEngine.Expect(x => x.ServiceProvider).Return(serviceProvider); serviceProvider.Expect(x => x.GetRequiredService(typeof(IGenericAttributeService))).Return(_genericAttributeService); serviceProvider.Expect(x => x.GetRequiredService(typeof(IUrlRecordService))).Return(urlRecordService); serviceProvider.Expect(x => x.GetRequiredService(typeof(ILocalizationService))).Return(_localizationService); serviceProvider.Expect(x => x.GetRequiredService(typeof(IWorkContext))).Return(_workContext); serviceProvider.Expect(x => x.GetRequiredService(typeof(IHttpContextAccessor))).Return(httpContextAccessor); EngineContext.Replace(nopEngine); _exportManager = new ExportManager(_categoryService, _manufacturerService, _customerService, _productAttributeService, _pictureService, _newsLetterSubscriptionService, _storeService, _workContext, _productEditorSettings, _vendorService, _productTemplateService, _dateRangeService, _taxCategoryService, _measureService, _catalogSettings, _genericAttributeService, _customerAttributeFormatter, _orderSettings, _specificationAttributeService, _localizedEntityService); }