public void GetObjectData(object obj, SerializationInfo info, StreamingContext context) { info.SetType(typeof(HttpTileProviderRef)); var wp = (HttpTileProvider)obj; var request = Utility.GetFieldValue <IRequest>(wp, "_request"); info.AddValue("_requestType", request.GetType()); info.AddValue("_request", request); var fetchTile = Utility.GetFieldValue(wp, "_fetchTile", BindingFlags.NonPublic | BindingFlags.Instance, (Func <Uri, byte[]>)null); info.AddValue("_fetchTileType", fetchTile.GetType()); info.AddValue("_fetchTile", null); IPersistentCache <byte[]> defaultCache = new NullCache(); var cache = Utility.GetPropertyValue(wp, "PersistentCache", BindingFlags.Public | BindingFlags.Instance, defaultCache); if (cache == null) { cache = new NullCache(); } info.AddValue("_persistentCacheType", cache.GetType()); info.AddValue("_persistentCache", cache); var httpClient = Utility.GetFieldValue <HttpClient>(obj, "_httpClient", BindingFlags.NonPublic | BindingFlags.Instance); var userAgent = httpClient.DefaultRequestHeaders.UserAgent; /* * info.AddValue("userAgent", Utility.GetPropertyValue(obj, "UserAgent", BindingFlags.NonPublic | BindingFlags.Instance, string.Empty)); * info.AddValue("referer", Utility.GetPropertyValue(obj, "Referer", BindingFlags.NonPublic | BindingFlags.Instance, string.Empty)); */ }
public void ShouldLoadResourcesWithPrecompilationAndWithoutCache() { var reactCoreAssembly = typeof(JavaScriptEngineFactory).GetTypeInfo().Assembly; var jsEngine = new Mock <IJsEngine>(); jsEngine.Setup(x => x.SupportsScriptPrecompilation).Returns(true); jsEngine.Setup(x => x.Evaluate <int>("1 + 1")).Returns(2); var config = new Mock <IReactSiteConfiguration>(); config.Setup(x => x.AllowJavaScriptPrecompilation).Returns(true); config.Setup(x => x.UseServerSideRendering).Returns(true); config.Setup(x => x.LoadReact).Returns(true); var cache = new NullCache(); var fileSystem = new Mock <IFileSystem>(); var factory = CreateFactory(config.Object, cache, fileSystem.Object, () => jsEngine.Object); factory.GetEngineForCurrentThread(); jsEngine.Verify(x => x.ExecuteResource("React.Core.Resources.shims.js", reactCoreAssembly)); jsEngine.Verify(x => x.ExecuteResource("React.Core.Resources.react.generated.min.js", reactCoreAssembly)); }
public void IsNull_WithNullCache_ReturnsTrue() { var cache = new NullCache <object, string>(); var decorator = new InvalidationTokenBasedCacheDecorator <object, string> (cache, InvalidationToken.Create()); Assert.That(((ICache <object, string>)decorator).IsNull, Is.True); }
public void TestNullCache() { var srcS = new NullCache(); var srcD = SandD(srcS); Assert.IsNotNull(srcD); }
public void ShouldLoadFilesThatDoNotRequireTransformWithPrecompilationAndWithoutCache() { var jsEngine = new Mock <IJsEngine>(); jsEngine.Setup(x => x.SupportsScriptPrecompilation).Returns(true); jsEngine.Setup(x => x.Evaluate <int>("1 + 1")).Returns(2); var config = new Mock <IReactSiteConfiguration>(); config.Setup(x => x.ScriptsWithoutTransform).Returns(new List <string> { "First.js", "Second.js" }); config.Setup(x => x.AllowJavaScriptPrecompilation).Returns(true); config.Setup(x => x.UseServerSideRendering).Returns(true); config.Setup(x => x.LoadReact).Returns(true); var cache = new NullCache(); var fileSystem = new Mock <IFileSystem>(); fileSystem.Setup(x => x.ReadAsString(It.IsAny <string>())).Returns <string>(path => "CONTENTS_" + path); var factory = CreateFactory(config.Object, cache, fileSystem.Object, () => jsEngine.Object); factory.GetEngineForCurrentThread(); jsEngine.Verify(x => x.Execute("CONTENTS_First.js", "First.js")); jsEngine.Verify(x => x.Execute("CONTENTS_Second.js", "Second.js")); }
public new void SetUp() { _languageRepo = MockRepository.GenerateMock<IRepository<Language>>(); var lang1 = new Language { Name = "English", LanguageCulture = "en-Us", FlagImageFileName = "us.png", Published = true, DisplayOrder = 1 }; var lang2 = new Language { Name = "Russian", LanguageCulture = "ru-Ru", FlagImageFileName = "ru.png", Published = true, DisplayOrder = 2 }; _languageRepo.Expect(x => x.Table).Return(new List<Language>() { lang1, lang2 }.AsQueryable()); _storeMappingService = MockRepository.GenerateMock<IStoreMappingService>(); var cacheManager = new NullCache(); _settingService = MockRepository.GenerateMock<ISettingService>(); _eventPublisher = MockRepository.GenerateMock<IEventPublisher>(); _eventPublisher.Expect(x => x.Publish(Arg<object>.Is.Anything)); _localizationSettings = new LocalizationSettings(); _languageService = new LanguageService(cacheManager, _languageRepo, _settingService, _localizationSettings, _eventPublisher, _storeMappingService); }
public void GetObjectData(object obj, SerializationInfo info, StreamingContext context) { var wp = (WebTileProvider)obj; var request = Utility.GetFieldValue <IRequest>(wp, "_request"); info.AddValue("_requestType", request.GetType()); info.AddValue("_request", request); Func <Uri, HttpWebRequest> defaultWebRequestFactory = (uri => (HttpWebRequest)WebRequest.Create(uri)); var webRequestFactory = Utility.GetFieldValue(wp, "_webRequestFactory", BindingFlags.NonPublic | BindingFlags.Instance, defaultWebRequestFactory); info.AddValue("_webRequestFactoryType", webRequestFactory.GetType()); info.AddValue("_webRequestFactory", webRequestFactory); IPersistentCache <byte[]> defaultCache = new NullCache(); var cache = Utility.GetFieldValue(wp, "_persistentCache", BindingFlags.Public | BindingFlags.Instance, defaultCache); if (cache == null) { cache = new NullCache(); } info.AddValue("_persistentCacheType", cache.GetType()); info.AddValue("_persistentCache", cache); info.AddValue("userAgent", Utility.GetPropertyValue(obj, "UserAgent", BindingFlags.NonPublic | BindingFlags.Instance, string.Empty)); info.AddValue("referer", Utility.GetPropertyValue(obj, "Referer", BindingFlags.NonPublic | BindingFlags.Instance, string.Empty)); }
static Nested() { try { var cacheConfig = App.Config.Sys.Cache; if (null == Config) { Config = new MdCacheConfig(cacheConfig.Identifier, cacheConfig.CacheName, cacheConfig.AuthorizationToken); } if (MasterConfig.ConfigStorageConnectionString != null) { Trace.TraceInformation("[MdCache] Attaching to BlobCache {0}", MasterConfig.ConfigStorageConnectionString); _instance = new AzureBlobCache(MasterConfig.ConfigStorageConnectionString); } else if (!string.IsNullOrWhiteSpace(cacheConfig.LocalCacheDir)) { Trace.TraceInformation("[MdCache] Attaching to LocalCache"); _instance = new LocalMdCache(); } else if (Config.CacheName != null) { _instance = new AzureMdCache(Config); } else { _instance = new NullCache(); } } catch (Exception e) { Trace.TraceError("[MdCache] Nested.Nested() failed. {0}", e); throw; } }
public void ShouldThrowIfPrecompilationOfResourcesIsPerformedWithoutCache() { var reactCoreAssembly = typeof(JavaScriptEngineFactory).GetTypeInfo().Assembly; var jsEngine = new Mock <IJsEngine>(); jsEngine.Setup(x => x.SupportsScriptPrecompilation).Returns(true); jsEngine.Setup(x => x.Evaluate <int>("1 + 1")).Returns(2); var config = new Mock <IReactSiteConfiguration>(); config.Setup(x => x.AllowJavaScriptPrecompilation).Returns(true); config.Setup(x => x.LoadReact).Returns(true); var cache = new NullCache(); var fileSystem = new Mock <IFileSystem>(); var factory = CreateFactory(config.Object, cache, fileSystem.Object, () => jsEngine.Object); var ex = Assert.Throws <ReactScriptPrecompilationNotAvailableException>( () => factory.GetEngineForCurrentThread()); Assert.Equal("Usage of the script pre-compilation without caching does not make sense.", ex.Message); }
public void ShouldThrowIfPrecompilationOfFilesThatDoNotRequireTransformIsPerformedWithoutCache() { var jsEngine = new Mock <IJsEngine>(); jsEngine.Setup(x => x.SupportsScriptPrecompilation).Returns(true); jsEngine.Setup(x => x.Evaluate <int>("1 + 1")).Returns(2); var config = new Mock <IReactSiteConfiguration>(); config.Setup(x => x.ScriptsWithoutTransform).Returns(new List <string> { "First.js", "Second.js" }); config.Setup(x => x.AllowJavaScriptPrecompilation).Returns(true); config.Setup(x => x.LoadReact).Returns(true); var cache = new NullCache(); var fileSystem = new Mock <IFileSystem>(); fileSystem.Setup(x => x.ReadAsString(It.IsAny <string>())).Returns <string>(path => "CONTENTS_" + path); var factory = CreateFactory(config.Object, cache, fileSystem.Object, () => jsEngine.Object); var ex = Assert.Throws <ReactScriptPrecompilationNotAvailableException>( () => factory.GetEngineForCurrentThread()); Assert.Equal("Usage of the script pre-compilation without caching does not make sense.", ex.Message); }
public void GetItem_ShouldSetValueAtKeyToNullAndReturnFalseIndicatingValueNotCached() { var cache = new NullCache(); var result = cache.GetItem("foo", out var value); Assert.AreEqual(value, null); Assert.IsFalse(result); }
public DefaultSettingsPackage() { Log = new NullLogProvider(); Cache = new NullCache(); Encryption = new NullEncryptionProvider(); Environment = new DefaultEnvironmentProvider(); Authorization = new NullAuthorizationProvider(); GlobalConnectionBundleType = null; }
public new void SetUp() { _discountRepo = MockRepository.GenerateMock <IRepository <Discount> >(); var discount1 = new Discount { Id = 1, DiscountType = DiscountType.AssignedToCategories, Name = "Discount 1", UsePercentage = true, DiscountPercentage = 10, DiscountAmount = 0, DiscountLimitation = DiscountLimitationType.Unlimited, LimitationTimes = 0, }; var discount2 = new Discount { Id = 2, DiscountType = DiscountType.AssignedToSkus, Name = "Discount 2", UsePercentage = false, DiscountPercentage = 0, DiscountAmount = 5, RequiresCouponCode = true, CouponCode = "SecretCode", DiscountLimitation = DiscountLimitationType.NTimesPerCustomer, LimitationTimes = 3, }; _discountRepo.Expect(x => x.Table).Return(new List <Discount>() { discount1, discount2 }.AsQueryable()); _eventPublisher = MockRepository.GenerateMock <IEventPublisher>(); _eventPublisher.Expect(x => x.Publish(Arg <object> .Is.Anything)); _storeContext = MockRepository.GenerateMock <IStoreContext>(); _storeContext.Expect(x => x.CurrentStore).Return(new Store { Id = 1, Name = "MyStore" }); _settingService = MockRepository.GenerateMock <ISettingService>(); var cacheManager = new NullCache(); _discountRequirementRepo = MockRepository.GenerateMock <IRepository <DiscountRequirement> >(); _discountUsageHistoryRepo = MockRepository.GenerateMock <IRepository <DiscountUsageHistory> >(); var pluginFinder = new PluginFinder(); _genericAttributeService = MockRepository.GenerateMock <IGenericAttributeService>(); _discountService = new DiscountService(cacheManager, _discountRepo, _discountRequirementRepo, _discountUsageHistoryRepo, _storeContext, _genericAttributeService, pluginFinder, _eventPublisher, _settingService, base.ProviderManager); }
public ConfigurationProvider() { PageCacheSize = DefaultPageCacheSize; ResourceCacheLimit = DefaultResourceCacheLimit; PersistenceType = PersistenceType.AppendOnly; QueryCache = new NullCache(); StatsUpdateTimespan = 0; StatsUpdateTransactionCount = 0; TransactionFlushTripleCount = 1000; PreloadConfiguration = new PageCachePreloadConfiguration {Enabled = false}; }
public new void SetUp() { var cacheManager = new NullCache(); _workContext = null; _currencySettings = new CurrencySettings(); var currency1 = new Currency { Id = 1, Name = "Euro", CurrencyCode = "EUR", DisplayLocale = "", CustomFormatting = "€0.00", DisplayOrder = 1, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; var currency2 = new Currency { Id = 1, Name = "US Dollar", CurrencyCode = "USD", DisplayLocale = "en-US", CustomFormatting = "", DisplayOrder = 2, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; _currencyRepo = MockRepository.GenerateMock <IRepository <Currency> >(); _currencyRepo.Expect(x => x.Table).Return(new List <Currency>() { currency1, currency2 }.AsQueryable()); _storeMappingService = MockRepository.GenerateMock <IStoreMappingService>(); _storeContext = MockRepository.GenerateMock <IStoreContext>(); var pluginFinder = new PluginFinder(); _currencyService = new CurrencyService(cacheManager, _currencyRepo, _storeMappingService, _currencySettings, pluginFinder, null, this.ProviderManager, _storeContext); _taxSettings = new TaxSettings(); _localizationService = MockRepository.GenerateMock <ILocalizationService>(); _localizationService.Expect(x => x.GetResource("Products.InclTaxSuffix", 1, false)).Return("{0} incl tax"); _localizationService.Expect(x => x.GetResource("Products.ExclTaxSuffix", 1, false)).Return("{0} excl tax"); _priceFormatter = new PriceFormatter(_workContext, _currencyService, _localizationService, _taxSettings); }
public new void SetUp() { _discountRepo = MockRepository.GenerateMock<IRepository<Discount>>(); var discount1 = new Discount { Id = 1, DiscountType = DiscountType.AssignedToCategories, Name = "Discount 1", UsePercentage = true, DiscountPercentage = 10, DiscountAmount = 0, DiscountLimitation = DiscountLimitationType.Unlimited, LimitationTimes = 0, }; var discount2 = new Discount { Id = 2, DiscountType = DiscountType.AssignedToSkus, Name = "Discount 2", UsePercentage = false, DiscountPercentage = 0, DiscountAmount = 5, RequiresCouponCode = true, CouponCode = "SecretCode", DiscountLimitation = DiscountLimitationType.NTimesPerCustomer, LimitationTimes = 3, }; _discountRepo.Expect(x => x.Table).Return(new List<Discount>() { discount1, discount2 }.AsQueryable()); _eventPublisher = MockRepository.GenerateMock<IEventPublisher>(); _eventPublisher.Expect(x => x.Publish(Arg<object>.Is.Anything)); _storeContext = MockRepository.GenerateMock<IStoreContext>(); _storeContext.Expect(x => x.CurrentStore).Return(new Store { Id = 1, Name = "MyStore" }); _settingService = MockRepository.GenerateMock<ISettingService>(); var cacheManager = new NullCache(); _discountRequirementRepo = MockRepository.GenerateMock<IRepository<DiscountRequirement>>(); _discountUsageHistoryRepo = MockRepository.GenerateMock<IRepository<DiscountUsageHistory>>(); var pluginFinder = new PluginFinder(); _genericAttributeService = MockRepository.GenerateMock<IGenericAttributeService>(); _discountService = new DiscountService(cacheManager, _discountRepo, _discountRequirementRepo, _discountUsageHistoryRepo, _storeContext, _genericAttributeService, pluginFinder, _eventPublisher, _settingService, base.ProviderManager); }
public ConfigurationProvider() { PageCacheSize = DefaultPageCacheSize; ResourceCacheLimit = DefaultResourceCacheLimit; PersistenceType = PersistenceType.AppendOnly; QueryCache = new NullCache(); StatsUpdateTimespan = 0; StatsUpdateTransactionCount = 0; TransactionFlushTripleCount = 1000; PreloadConfiguration = new PageCachePreloadConfiguration { Enabled = false }; }
public new void SetUp() { _languageRepo = MockRepository.GenerateMock <IRepository <Language> >(); var lang1 = new Language { Name = "English", LanguageCulture = "en-Us", FlagImageFileName = "us.png", Published = true, DisplayOrder = 1 }; var lang2 = new Language { Name = "Russian", LanguageCulture = "ru-Ru", FlagImageFileName = "ru.png", Published = true, DisplayOrder = 2 }; _languageRepo.Expect(x => x.Table).Return(new List <Language>() { lang1, lang2 }.AsQueryable()); _storeMappingService = MockRepository.GenerateMock <IStoreMappingService>(); _storeService = MockRepository.GenerateMock <IStoreService>(); _storeContext = MockRepository.GenerateMock <IStoreContext>(); var cacheManager = new NullCache(); _settingService = MockRepository.GenerateMock <ISettingService>(); _eventPublisher = MockRepository.GenerateMock <IEventPublisher>(); _eventPublisher.Expect(x => x.Publish(Arg <object> .Is.Anything)); _localizationSettings = new LocalizationSettings(); _languageService = new LanguageService( NullRequestCache.Instance, NullCache.Instance, _languageRepo, _settingService, _localizationSettings, _eventPublisher, _storeMappingService, _storeService, _storeContext); }
public new void SetUp() { var cacheManager = new NullCache(); _workContext = null; _currencySettings = new CurrencySettings(); var currency1 = new Currency { Id = 1, Name = "Euro", CurrencyCode = "EUR", DisplayLocale = "", CustomFormatting = "€0.00", DisplayOrder = 1, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc= DateTime.UtcNow }; var currency2 = new Currency { Id = 1, Name = "US Dollar", CurrencyCode = "USD", DisplayLocale = "en-US", CustomFormatting = "", DisplayOrder = 2, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc= DateTime.UtcNow }; _currencyRepo = MockRepository.GenerateMock<IRepository<Currency>>(); _currencyRepo.Expect(x => x.Table).Return(new List<Currency>() { currency1, currency2 }.AsQueryable()); _storeMappingService = MockRepository.GenerateMock<IStoreMappingService>(); var pluginFinder = new PluginFinder(); _currencyService = new CurrencyService(cacheManager, _currencyRepo, _storeMappingService, _currencySettings, pluginFinder, null, this.ProviderManager); _taxSettings = new TaxSettings(); _localizationService = MockRepository.GenerateMock<ILocalizationService>(); _localizationService.Expect(x => x.GetResource("Products.InclTaxSuffix", 1, false)).Return("{0} incl tax"); _localizationService.Expect(x => x.GetResource("Products.ExclTaxSuffix", 1, false)).Return("{0} excl tax"); _priceFormatter = new PriceFormatter(_workContext, _currencyService,_localizationService, _taxSettings); }
public static ICache Get(CacheType cacheType) { ICache cache = new NullCache(); try { var caches = CacheContainer.GetAll <ICache>(); cache = caches.Where(c => c.CacheType == cacheType).Last(); } catch (Exception ex) { //Log.Warn("Failed to instantiate cache of type: {0}, using null cache. Exception: {1}", cacheType, ex); cache = new NullCache(); } return(cache); }
public static ICache Get(CacheType cacheType) { ICache cache = new NullCache(); try { var caches = Container.GetAll <ICache>(); cache = (from c in caches where c.CacheType == cacheType select c).Last(); cache.Initialise(); } catch (Exception ex) { Log.Warn("Failed to instantiate cache of type: {0}, using null cache. Exception: {1}", cacheType, ex); cache = new NullCache(); } return(cache); }
public void ShardedCacheTransactionHandler_ShouldResolveICache() { const string dbName = "some-database"; var applicationCache = new NullCache(); var dbConnectionMock = new Mock <DbConnection>(); dbConnectionMock.Setup(conn => conn.Database).Returns(dbName); var shardDictionary = new Lazy <Dictionary <string, ICache> >(); shardDictionary.Value[dbName] = applicationCache; var handler = new ShardedCacheTransactionHandlerTester(shardDictionary); var someOtherCache = new NullCache(); var resolvedCache = handler.TestCacheResolver(dbConnectionMock.Object); Assert.AreSame(resolvedCache, applicationCache); Assert.AreNotSame(resolvedCache, someOtherCache); }
public void CreateShardDictionary_ShouldCreateDictionaryWithoutErrorHandler() { const string databaseName = "some-database"; var applicationCache = new NullCache(); var result = ShardedCacheConfigurator.CreateShardDictionary(() => new List <ShardLocation> { new ShardLocation { Database = databaseName, Server = "unused-in-tests" } }, (shard, handler) => applicationCache, null).Value; var expectedResult = new Lazy <Dictionary <string, ICache> >(); expectedResult.Value[databaseName] = applicationCache; var someOtherCache = new NullCache(); Assert.AreEqual(1, result.Keys.Count); Assert.AreEqual(databaseName, result.Keys.ElementAt(0)); Assert.AreSame(applicationCache, result.Values.ElementAt(0)); Assert.AreNotSame(someOtherCache, result.Values.ElementAt(0)); }
public void GetObjectData(object obj, SerializationInfo info, StreamingContext context) { var wp = (WebTileProvider)obj; var request = Utility.GetFieldValue<IRequest>(wp, "_request"); info.AddValue("_requestType", request.GetType()); info.AddValue("_request", request); Func<Uri, HttpWebRequest> defaultWebRequestFactory = (uri => (HttpWebRequest) WebRequest.Create(uri)); var webRequestFactory = Utility.GetFieldValue(wp, "_webRequestFactory", BindingFlags.NonPublic | BindingFlags.Instance, defaultWebRequestFactory); info.AddValue("_webRequestFactoryType", webRequestFactory.GetType()); info.AddValue("_webRequestFactory", webRequestFactory); IPersistentCache<byte[]> defaultCache = new NullCache(); var cache = Utility.GetFieldValue(wp, "_persistentCache", BindingFlags.Public | BindingFlags.Instance, defaultCache); if (cache == null) cache = new NullCache(); info.AddValue("_persistentCacheType", cache.GetType()); info.AddValue("_persistentCache", cache); info.AddValue("userAgent", Utility.GetPropertyValue(obj, "UserAgent", BindingFlags.NonPublic | BindingFlags.Instance, string.Empty)); info.AddValue("referer", Utility.GetPropertyValue(obj, "Referer", BindingFlags.NonPublic | BindingFlags.Instance, string.Empty)); }
public DefaultSolrLocator() { MappingManager = new MemoizingMappingManager(new AttributesMappingManager()); FieldParser = new DefaultFieldParser(); DocumentPropertyVisitor = new DefaultDocumentVisitor(MappingManager, FieldParser); if (typeof(T) == typeof(Dictionary <string, object>)) { DocumentResponseParser = (ISolrDocumentResponseParser <T>) new SolrDictionaryDocumentResponseParser(FieldParser); } else { DocumentResponseParser = new SolrDocumentResponseParser <T>(MappingManager, DocumentPropertyVisitor, new SolrDocumentActivator <T>()); } ResponseParser = new DefaultResponseParser <T>(DocumentResponseParser); SchemaParser = new SolrSchemaParser(); HeaderParser = new HeaderResponseParser <string>(); DihStatusParser = new SolrDIHStatusParser(); ExtractResponseParser = new ExtractResponseParser(HeaderParser); FieldSerializer = new DefaultFieldSerializer(); QuerySerializer = new DefaultQuerySerializer(FieldSerializer); FacetQuerySerializer = new DefaultFacetQuerySerializer(QuerySerializer, FieldSerializer); MlthResultParser = new SolrMoreLikeThisHandlerQueryResultsParser <T>(new[] { ResponseParser }); StatusResponseParser = new SolrStatusResponseParser(); if (typeof(T) == typeof(Dictionary <string, object>)) { DocumentSerializer = (ISolrDocumentSerializer <T>) new SolrDictionarySerializer(FieldSerializer); } else { DocumentSerializer = new SolrDocumentSerializer <T>(MappingManager, FieldSerializer); } HttpCache = new NullCache(); }
public GuidesHttpServiceV1BeforeAll() { Persistence = new GuidesMemoryPersistence(); Controller = new GuidesController(); Service = new GuidesHttpServiceV1(); _cache = new NullCache(); References = PipServices3.Commons.Refer.References.FromTuples( new Descriptor("wexxle-guides", "persistence", "memory", "default", "1.0"), Persistence, new Descriptor("pip-services3", "cache", "null", "default", "1.0"), _cache, new Descriptor("wexxle-guides", "controller", "default", "default", "1.0"), Controller, new Descriptor("wexxle-guides", "service", "http", "default", "1.0"), Service, new Descriptor("wexxle-attachments", "client", "null", "default", "1.0"), new AttachmentsNullClientV1() ); Controller.SetReferences(References); Service.Configure(HttpConfig); Service.SetReferences(References); Task.Run(() => Service.OpenAsync(null)); Thread.Sleep(1000); }
public new void SetUp() { _shippingSettings = new ShippingSettings(); _shippingSettings.ActiveShippingRateComputationMethodSystemNames = new List<string>(); _shippingSettings.ActiveShippingRateComputationMethodSystemNames.Add("FixedRateTestShippingRateComputationMethod"); _shippingMethodRepository = MockRepository.GenerateMock<IRepository<ShippingMethod>>(); _logger = new NullLogger(); _productAttributeParser = MockRepository.GenerateMock<IProductAttributeParser>(); _productService = MockRepository.GenerateMock<IProductService>(); _checkoutAttributeParser = MockRepository.GenerateMock<ICheckoutAttributeParser>(); var cacheManager = new NullCache(); var pluginFinder = new PluginFinder(); _eventPublisher = MockRepository.GenerateMock<IEventPublisher>(); _eventPublisher.Expect(x => x.Publish(Arg<object>.Is.Anything)); _localizationService = MockRepository.GenerateMock<ILocalizationService>(); _genericAttributeService = MockRepository.GenerateMock<IGenericAttributeService>(); _settingService = MockRepository.GenerateMock<ISettingService>(); _shoppingCartSettings = new ShoppingCartSettings(); _shippingService = new ShippingService(cacheManager, _shippingMethodRepository, _logger, _productAttributeParser, _productService, _checkoutAttributeParser, _genericAttributeService, _localizationService, _shippingSettings, pluginFinder, _eventPublisher, _shoppingCartSettings, _settingService, this.ProviderManager); }
public new void SetUp() { _shippingSettings = new ShippingSettings(); _shippingSettings.ActiveShippingRateComputationMethodSystemNames = new List <string>(); _shippingSettings.ActiveShippingRateComputationMethodSystemNames.Add("FixedRateTestShippingRateComputationMethod"); _shippingMethodRepository = MockRepository.GenerateMock <IRepository <ShippingMethod> >(); _logger = new NullLogger(); _productAttributeParser = MockRepository.GenerateMock <IProductAttributeParser>(); _productService = MockRepository.GenerateMock <IProductService>(); _checkoutAttributeParser = MockRepository.GenerateMock <ICheckoutAttributeParser>(); var cacheManager = new NullCache(); var pluginFinder = new PluginFinder(); _eventPublisher = MockRepository.GenerateMock <IEventPublisher>(); _eventPublisher.Expect(x => x.Publish(Arg <object> .Is.Anything)); _localizationService = MockRepository.GenerateMock <ILocalizationService>(); _genericAttributeService = MockRepository.GenerateMock <IGenericAttributeService>(); _settingService = MockRepository.GenerateMock <ISettingService>(); _shoppingCartSettings = new ShoppingCartSettings(); _shippingService = new ShippingService(cacheManager, _shippingMethodRepository, _logger, _productAttributeParser, _productService, _checkoutAttributeParser, _genericAttributeService, _localizationService, _shippingSettings, pluginFinder, _eventPublisher, _shoppingCartSettings, _settingService, this.ProviderManager); }
async Task <IAccessToken> IAccessTokenProvider.ProvisionAccessTokenAsync( IEnumerable <Claim> claims, IEnumerable <Scope> scopes, ICache cache ) { if (cache == null) { cache = new NullCache(); } claims = claims.ToList(); scopes = scopes.ToList(); string cacheKey = TokenCacheKeyBuilder.BuildKey(claims, scopes); CacheResponse cacheResponse = await cache.GetAsync(cacheKey).SafeAsync(); if (cacheResponse.Success) { SecurityToken securityToken = m_tokenHandler.ReadToken(cacheResponse.Value); if (securityToken.ValidTo > DateTime.UtcNow.Add(m_tokenRefreshGracePeriod)) { return(new AccessToken(cacheResponse.Value)); } } IAccessToken token = await m_accessTokenProvider.ProvisionAccessTokenAsync(claims, scopes).SafeAsync(); DateTime validTo = m_tokenHandler.ReadToken(token.Token).ValidTo; await cache.SetAsync(cacheKey, token.Token, validTo - DateTime.UtcNow).SafeAsync(); return(token); }
public new void SetUp() { currencyUSD = new Currency() { Id = 1, Name = "US Dollar", CurrencyCode = "USD", Rate = 1.2M, DisplayLocale = "en-US", CustomFormatting = "", Published = true, DisplayOrder = 1, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow, }; currencyEUR = new Currency() { Id = 2, Name = "Euro", CurrencyCode = "EUR", Rate = 1, DisplayLocale = "de-DE", CustomFormatting = "€0.00", Published = true, DisplayOrder = 2, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow, }; currencyRUR = new Currency() { Id = 3, Name = "Russian Rouble", CurrencyCode = "RUB", Rate = 34.5M, DisplayLocale = "ru-RU", CustomFormatting = "", Published = true, DisplayOrder = 3, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow, }; _currencyRepository = MockRepository.GenerateMock<IRepository<Currency>>(); _currencyRepository.Expect(x => x.Table).Return(new List<Currency>() { currencyUSD, currencyEUR, currencyRUR }.AsQueryable()); _currencyRepository.Expect(x => x.GetById(currencyUSD.Id)).Return(currencyUSD); _currencyRepository.Expect(x => x.GetById(currencyEUR.Id)).Return(currencyEUR); _currencyRepository.Expect(x => x.GetById(currencyRUR.Id)).Return(currencyRUR); _storeMappingService = MockRepository.GenerateMock<IStoreMappingService>(); var cacheManager = new NullCache(); _currencySettings = new CurrencySettings(); _currencySettings.PrimaryStoreCurrencyId = currencyUSD.Id; _currencySettings.PrimaryExchangeRateCurrencyId = currencyEUR.Id; _eventPublisher = MockRepository.GenerateMock<IEventPublisher>(); _eventPublisher.Expect(x => x.Publish(Arg<object>.Is.Anything)); var pluginFinder = new PluginFinder(); _currencyService = new CurrencyService(cacheManager, _currencyRepository, _storeMappingService, _currencySettings, pluginFinder, _eventPublisher); }
public NullCacheTest() { _cache = new NullCache(); }
private const int DefaultResourceCacheLimit = 1000000; // number of entries #endif static Configuration() { #if WINDOWS_PHONE var store = IsolatedStorageFile.GetUserStoreForApplication(); if (!store.DirectoryExists("brightstar")) { store.CreateDirectory("brightstar"); } StoreLocation = "brightstar"; TransactionFlushTripleCount = 1000; QueryCache = new NullCache(); #elif PORTABLE StoreLocation = "brightstar"; TransactionFlushTripleCount = 1000; PageCacheSize = DefaultPageCacheSize; ResourceCacheLimit = DefaultResourceCacheLimit; EnableOptimisticLocking = false; EnableQueryCache = false; PersistenceType = DefaultPersistenceType; QueryCache = new NullCache(); #else var appSettings = ConfigurationManager.AppSettings; StoreLocation = appSettings.Get(StoreLocationPropertyName); // Transaction Flushing TransactionFlushTripleCount = GetApplicationSetting(TxnFlushTriggerPropertyName, 10000); // Read Store cache // TODO : Remove this if it is no longer in use. var readStoreObjectCacheSizeString = appSettings.Get(ReadStoreObjectCacheSizeName); ReadStoreObjectCacheSize = 10000; if (!string.IsNullOrEmpty(readStoreObjectCacheSizeString)) { int val; if (int.TryParse(readStoreObjectCacheSizeString, out val)) { if (val > 0) { ReadStoreObjectCacheSize = val; } } } // Connection String ConnectionString = appSettings.Get(ConnectionStringPropertyName); // Query Caching var enableQueryCacheString = appSettings.Get(EnableQueryCacheName); EnableQueryCache = true; if (!string.IsNullOrEmpty(enableQueryCacheString)) { EnableQueryCache = bool.Parse(enableQueryCacheString); } QueryCacheMemory = GetApplicationSetting(QueryCacheMemoryName, DefaultQueryCacheMemory); QueryCacheDiskSpace = GetApplicationSetting(QueryCacheDiskSpaceName, DefaultQueryCacheDiskSpace); QueryCacheDirectory = appSettings.Get(QueryCacheDirectoryName); QueryCache = GetQueryCache(); // StatsUpdate properties StatsUpdateTransactionCount = GetApplicationSetting(StatsUpdateTransactionCountName, 0); StatsUpdateTimespan = GetApplicationSetting(StatsUpdateTimeSpanName, 0); // Advanced embedded application settings - read from the brightstar section of the app/web.config var advancedConfiguration = ConfigurationManager.GetSection("brightstar") as BrightstarConfiguration; if (advancedConfiguration != null) { PreloadConfiguration = advancedConfiguration.PreloadConfiguration; } #endif #if !PORTABLE // ResourceCacheLimit ResourceCacheLimit = GetApplicationSetting(ResourceCacheLimitName, DefaultResourceCacheLimit); // Persistence Type var persistenceTypeSetting = GetApplicationSetting(PersistenceTypeName); if (!String.IsNullOrEmpty(persistenceTypeSetting)) { switch (persistenceTypeSetting.ToLowerInvariant()) { case PersistenceTypeAppendOnly: PersistenceType = PersistenceType.AppendOnly; break; case PersistenceTypeRewrite: PersistenceType = PersistenceType.Rewrite; break; default: PersistenceType = DefaultPersistenceType; break; } } else { PersistenceType = DefaultPersistenceType; } // Page Cache Size var pageCacheSizeSetting = GetApplicationSetting(PageCacheSizeName); int pageCacheSize; if (!String.IsNullOrEmpty(pageCacheSizeSetting) && Int32.TryParse(pageCacheSizeSetting, out pageCacheSize)) { PageCacheSize = pageCacheSize; } else { PageCacheSize = DefaultPageCacheSize; } #if !WINDOWS_PHONE // Clustering var clusterNodePortSetting = GetApplicationSetting(ClusterNodePortName); int clusterNodePort; if (!String.IsNullOrEmpty(clusterNodePortSetting) && Int32.TryParse(clusterNodePortSetting, out clusterNodePort)) { ClusterNodePort = clusterNodePort; } else { ClusterNodePort = 10001; } #endif #endif }
public new void SetUp() { measureDimension1 = new MeasureDimension() { Id = 1, Name = "inch(es)", SystemKeyword = "inch", Ratio = 1M, DisplayOrder = 1, }; measureDimension2 = new MeasureDimension() { Id = 2, Name = "feet", SystemKeyword = "ft", Ratio = 0.08333333M, DisplayOrder = 2, }; measureDimension3 = new MeasureDimension() { Id = 3, Name = "meter(s)", SystemKeyword = "m", Ratio = 0.0254M, DisplayOrder = 3, }; measureDimension4 = new MeasureDimension() { Id = 4, Name = "millimetre(s)", SystemKeyword = "mm", Ratio = 25.4M, DisplayOrder = 4, }; measureWeight1 = new MeasureWeight() { Id = 1, Name = "ounce(s)", SystemKeyword = "oz", Ratio = 16M, DisplayOrder = 1, }; measureWeight2 = new MeasureWeight() { Id = 2, Name = "lb(s)", SystemKeyword = "lb", Ratio = 1M, DisplayOrder = 2, }; measureWeight3 = new MeasureWeight() { Id = 3, Name = "kg(s)", SystemKeyword = "kg", Ratio = 0.45359237M, DisplayOrder = 3, }; measureWeight4 = new MeasureWeight() { Id = 4, Name = "gram(s)", SystemKeyword = "g", Ratio = 453.59237M, DisplayOrder = 4, }; _measureDimensionRepository = MockRepository.GenerateMock <IRepository <MeasureDimension> >(); _measureDimensionRepository.Expect(x => x.Table).Return(new List <MeasureDimension>() { measureDimension1, measureDimension2, measureDimension3, measureDimension4 }.AsQueryable()); _measureDimensionRepository.Expect(x => x.GetById(measureDimension1.Id)).Return(measureDimension1); _measureDimensionRepository.Expect(x => x.GetById(measureDimension2.Id)).Return(measureDimension2); _measureDimensionRepository.Expect(x => x.GetById(measureDimension3.Id)).Return(measureDimension3); _measureDimensionRepository.Expect(x => x.GetById(measureDimension4.Id)).Return(measureDimension4); _measureWeightRepository = MockRepository.GenerateMock <IRepository <MeasureWeight> >(); _measureWeightRepository.Expect(x => x.Table).Return(new List <MeasureWeight>() { measureWeight1, measureWeight2, measureWeight3, measureWeight4 }.AsQueryable()); _measureWeightRepository.Expect(x => x.GetById(measureWeight1.Id)).Return(measureWeight1); _measureWeightRepository.Expect(x => x.GetById(measureWeight2.Id)).Return(measureWeight2); _measureWeightRepository.Expect(x => x.GetById(measureWeight3.Id)).Return(measureWeight3); _measureWeightRepository.Expect(x => x.GetById(measureWeight4.Id)).Return(measureWeight4); var cacheManager = new NullCache(); _measureSettings = new MeasureSettings(); _measureSettings.BaseDimensionId = measureDimension1.Id; //inch(es) _measureSettings.BaseWeightId = measureWeight2.Id; //lb(s) _eventPublisher = MockRepository.GenerateMock <IEventPublisher>(); _eventPublisher.Expect(x => x.Publish(Arg <object> .Is.Anything)); _measureService = new MeasureService(cacheManager, _measureDimensionRepository, _measureWeightRepository, _measureSettings, _eventPublisher); }
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); _storeMappingRepo = MockRepository.GenerateMock <IRepository <StoreMapping> >(); var cacheManager = new NullCache(); _eventPublisher = MockRepository.GenerateMock <IEventPublisher>(); _eventPublisher.Expect(x => x.Publish(Arg <object> .Is.Anything)); _checkoutAttributeService = new CheckoutAttributeService( _checkoutAttributeRepo, _checkoutAttributeValueRepo, _storeMappingRepo, _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); }
public TileSharpTileLayer() { OverlapPreventer = new PerfectQuadtreePreventer(); FeatureCache = new NullCache(); }
public new void SetUp() { #region Test data //color (dropdownlist) pa1 = new ProductAttribute { Id = 1, Name = "Color", }; pva1_1 = new ProductVariantAttribute { Id = 11, ProductId = 1, TextPrompt = "Select color:", IsRequired = true, AttributeControlType = AttributeControlType.DropdownList, DisplayOrder = 1, ProductAttribute = pa1, ProductAttributeId = pa1.Id }; pvav1_1 = new ProductVariantAttributeValue { Id = 11, Name = "Green", DisplayOrder = 1, ProductVariantAttribute = pva1_1, ProductVariantAttributeId = pva1_1.Id }; pvav1_2 = new ProductVariantAttributeValue { Id = 12, Name = "Red", DisplayOrder = 2, ProductVariantAttribute = pva1_1, ProductVariantAttributeId = pva1_1.Id }; pva1_1.ProductVariantAttributeValues.Add(pvav1_1); pva1_1.ProductVariantAttributeValues.Add(pvav1_2); //custom option (checkboxes) pa2 = new ProductAttribute { Id = 2, Name = "Some custom option", }; pva2_1 = new ProductVariantAttribute { Id = 21, ProductId = 1, TextPrompt = "Select at least one option:", IsRequired = true, AttributeControlType = AttributeControlType.Checkboxes, DisplayOrder = 2, ProductAttribute = pa2, ProductAttributeId = pa2.Id }; pvav2_1 = new ProductVariantAttributeValue { Id = 21, Name = "Option 1", DisplayOrder = 1, ProductVariantAttribute = pva2_1, ProductVariantAttributeId = pva2_1.Id }; pvav2_2 = new ProductVariantAttributeValue { Id = 22, Name = "Option 2", DisplayOrder = 2, ProductVariantAttribute = pva2_1, ProductVariantAttributeId = pva2_1.Id }; pva2_1.ProductVariantAttributeValues.Add(pvav2_1); pva2_1.ProductVariantAttributeValues.Add(pvav2_2); //custom text pa3 = new ProductAttribute { Id = 3, Name = "Custom text", }; pva3_1 = new ProductVariantAttribute { Id = 31, ProductId = 1, TextPrompt = "Enter custom text:", IsRequired = true, AttributeControlType = AttributeControlType.TextBox, DisplayOrder = 1, ProductAttribute = pa1, ProductAttributeId = pa3.Id }; #endregion _productAttributeRepo = MockRepository.GenerateMock <IRepository <ProductAttribute> >(); _productAttributeRepo.Expect(x => x.Table).Return(new List <ProductAttribute>() { pa1, pa2, pa3 }.AsQueryable()); _productAttributeRepo.Expect(x => x.GetById(pa1.Id)).Return(pa1); _productAttributeRepo.Expect(x => x.GetById(pa2.Id)).Return(pa2); _productAttributeRepo.Expect(x => x.GetById(pa3.Id)).Return(pa3); _productVariantAttributeRepo = MockRepository.GenerateMock <IRepository <ProductVariantAttribute> >(); _productVariantAttributeRepo.Expect(x => x.Table).Return(new List <ProductVariantAttribute>() { pva1_1, pva2_1, pva3_1 }.AsQueryable()); _productVariantAttributeRepo.Expect(x => x.GetById(pva1_1.Id)).Return(pva1_1); _productVariantAttributeRepo.Expect(x => x.GetById(pva2_1.Id)).Return(pva2_1); _productVariantAttributeRepo.Expect(x => x.GetById(pva3_1.Id)).Return(pva3_1); _productVariantAttributeCombinationRepo = MockRepository.GenerateMock <IRepository <ProductVariantAttributeCombination> >(); _productVariantAttributeCombinationRepo.Expect(x => x.Table).Return(new List <ProductVariantAttributeCombination>().AsQueryable()); _productVariantAttributeValueRepo = MockRepository.GenerateMock <IRepository <ProductVariantAttributeValue> >(); _productVariantAttributeValueRepo.Expect(x => x.Table).Return(new List <ProductVariantAttributeValue>() { pvav1_1, pvav1_2, pvav2_1, pvav2_2 }.AsQueryable()); _productVariantAttributeValueRepo.Expect(x => x.GetById(pvav1_1.Id)).Return(pvav1_1); _productVariantAttributeValueRepo.Expect(x => x.GetById(pvav1_2.Id)).Return(pvav1_2); _productVariantAttributeValueRepo.Expect(x => x.GetById(pvav2_1.Id)).Return(pvav2_1); _productVariantAttributeValueRepo.Expect(x => x.GetById(pvav2_2.Id)).Return(pvav2_2); _productBundleItemAttributeFilter = MockRepository.GenerateMock <IRepository <ProductBundleItemAttributeFilter> >(); _eventPublisher = MockRepository.GenerateMock <IEventPublisher>(); _eventPublisher.Expect(x => x.Publish(Arg <object> .Is.Anything)); _pictureService = MockRepository.GenerateMock <IPictureService>(); var cacheManager = new NullCache(); _productAttributeService = new ProductAttributeService(cacheManager, _productAttributeRepo, _productVariantAttributeRepo, _productVariantAttributeCombinationRepo, _productVariantAttributeValueRepo, _productBundleItemAttributeFilter, _eventPublisher, _pictureService); _productAttributeParser = new ProductAttributeParser(_productAttributeService, new MemoryRepository <ProductVariantAttributeCombination>(), NullCache.Instance); var workingLanguage = new Language(); _workContext = MockRepository.GenerateMock <IWorkContext>(); _workContext.Expect(x => x.WorkingLanguage).Return(workingLanguage); _currencyService = MockRepository.GenerateMock <ICurrencyService>(); _localizationService = MockRepository.GenerateMock <ILocalizationService>(); _localizationService.Expect(x => x.GetResource("GiftCardAttribute.For.Virtual")).Return("For: {0} <{1}>"); _localizationService.Expect(x => x.GetResource("GiftCardAttribute.From.Virtual")).Return("From: {0} <{1}>"); _localizationService.Expect(x => x.GetResource("GiftCardAttribute.For.Physical")).Return("For: {0}"); _localizationService.Expect(x => x.GetResource("GiftCardAttribute.From.Physical")).Return("From: {0}"); _taxService = MockRepository.GenerateMock <ITaxService>(); _priceFormatter = MockRepository.GenerateMock <IPriceFormatter>(); _downloadService = MockRepository.GenerateMock <IDownloadService>(); _webHelper = MockRepository.GenerateMock <IWebHelper>(); _priceCalculationService = MockRepository.GenerateMock <IPriceCalculationService>(); _shoppingCartSettings = MockRepository.GenerateMock <ShoppingCartSettings>(); _productAttributeFormatter = new ProductAttributeFormatter(_workContext, _productAttributeService, _productAttributeParser, _priceCalculationService, _currencyService, _localizationService, _taxService, _priceFormatter, _downloadService, _webHelper, _shoppingCartSettings); }
public new void SetUp() { currencyUSD = new Currency() { Id = 1, Name = "US Dollar", CurrencyCode = "USD", Rate = 1.2M, DisplayLocale = "en-US", CustomFormatting = "", Published = true, DisplayOrder = 1, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow, }; currencyEUR = new Currency() { Id = 2, Name = "Euro", CurrencyCode = "EUR", Rate = 1, DisplayLocale = "de-DE", CustomFormatting = "€0.00", Published = true, DisplayOrder = 2, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow, }; currencyRUR = new Currency() { Id = 3, Name = "Russian Rouble", CurrencyCode = "RUB", Rate = 34.5M, DisplayLocale = "ru-RU", CustomFormatting = "", Published = true, DisplayOrder = 3, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow, }; _currencyRepository = MockRepository.GenerateMock <IRepository <Currency> >(); _currencyRepository.Expect(x => x.Table).Return(new List <Currency>() { currencyUSD, currencyEUR, currencyRUR }.AsQueryable()); _currencyRepository.Expect(x => x.GetById(currencyUSD.Id)).Return(currencyUSD); _currencyRepository.Expect(x => x.GetById(currencyEUR.Id)).Return(currencyEUR); _currencyRepository.Expect(x => x.GetById(currencyRUR.Id)).Return(currencyRUR); _storeMappingService = MockRepository.GenerateMock <IStoreMappingService>(); _storeContext = MockRepository.GenerateMock <IStoreContext>(); var cacheManager = new NullCache(); _currencySettings = new CurrencySettings(); _storeContext.Expect(x => x.CurrentStore).Return(new Store { Name = "Computer store", Url = "http://www.yourStore.com", Hosts = "yourStore.com,www.yourStore.com", PrimaryStoreCurrency = currencyUSD, PrimaryExchangeRateCurrency = currencyEUR }); _eventPublisher = MockRepository.GenerateMock <IEventPublisher>(); _eventPublisher.Expect(x => x.Publish(Arg <object> .Is.Anything)); var pluginFinder = new PluginFinder(); _currencyService = new CurrencyService(cacheManager, _currencyRepository, _storeMappingService, _currencySettings, pluginFinder, _eventPublisher, this.ProviderManager, _storeContext); }
public new void SetUp() { _workContext = null; _store = new Store() { Id = 1 }; _storeContext = MockRepository.GenerateMock <IStoreContext>(); _storeContext.Expect(x => x.CurrentStore).Return(_store); var pluginFinder = new PluginFinder(); var cacheManager = new NullCache(); _shoppingCartSettings = new ShoppingCartSettings(); _catalogSettings = new CatalogSettings(); //price calculation service _discountService = MockRepository.GenerateMock <IDiscountService>(); _categoryService = MockRepository.GenerateMock <ICategoryService>(); _productAttributeParser = MockRepository.GenerateMock <IProductAttributeParser>(); _priceCalcService = new PriceCalculationService(_workContext, _storeContext, _discountService, _categoryService, _productAttributeParser, _productService, _shoppingCartSettings, _catalogSettings); _eventPublisher = MockRepository.GenerateMock <IEventPublisher>(); _eventPublisher.Expect(x => x.Publish(Arg <object> .Is.Anything)); _localizationService = MockRepository.GenerateMock <ILocalizationService>(); _settingService = MockRepository.GenerateMock <ISettingService>(); //shipping _shippingSettings = new ShippingSettings(); _shippingSettings.ActiveShippingRateComputationMethodSystemNames = new List <string>(); _shippingSettings.ActiveShippingRateComputationMethodSystemNames.Add("FixedRateTestShippingRateComputationMethod"); _shippingMethodRepository = MockRepository.GenerateMock <IRepository <ShippingMethod> >(); _logger = new NullLogger(); _shippingService = new ShippingService(cacheManager, _shippingMethodRepository, _logger, _productAttributeParser, _productService, _checkoutAttributeParser, _genericAttributeService, _localizationService, _shippingSettings, pluginFinder, _eventPublisher, _shoppingCartSettings, _settingService); _shipmentService = MockRepository.GenerateMock <IShipmentService>(); _paymentService = MockRepository.GenerateMock <IPaymentService>(); _checkoutAttributeParser = MockRepository.GenerateMock <ICheckoutAttributeParser>(); _giftCardService = MockRepository.GenerateMock <IGiftCardService>(); _genericAttributeService = MockRepository.GenerateMock <IGenericAttributeService>(); //tax _taxSettings = new TaxSettings(); _taxSettings.ShippingIsTaxable = true; _taxSettings.PaymentMethodAdditionalFeeIsTaxable = true; _taxSettings.DefaultTaxAddressId = 10; _addressService = MockRepository.GenerateMock <IAddressService>(); _addressService.Expect(x => x.GetAddressById(_taxSettings.DefaultTaxAddressId)).Return(new Address() { Id = _taxSettings.DefaultTaxAddressId }); _taxService = new TaxService(_addressService, _workContext, _taxSettings, _shoppingCartSettings, pluginFinder, _settingService); _rewardPointsSettings = new RewardPointsSettings(); _orderTotalCalcService = new OrderTotalCalculationService(_workContext, _storeContext, _priceCalcService, _taxService, _shippingService, _paymentService, _checkoutAttributeParser, _discountService, _giftCardService, _genericAttributeService, _taxSettings, _rewardPointsSettings, _shippingSettings, _shoppingCartSettings, _catalogSettings); _orderService = MockRepository.GenerateMock <IOrderService>(); _webHelper = MockRepository.GenerateMock <IWebHelper>(); _languageService = MockRepository.GenerateMock <ILanguageService>(); _productService = MockRepository.GenerateMock <IProductService>(); _priceFormatter = MockRepository.GenerateMock <IPriceFormatter>(); _productAttributeFormatter = MockRepository.GenerateMock <IProductAttributeFormatter>(); _shoppingCartService = MockRepository.GenerateMock <IShoppingCartService>(); _checkoutAttributeFormatter = MockRepository.GenerateMock <ICheckoutAttributeFormatter>(); _customerService = MockRepository.GenerateMock <ICustomerService>(); _encryptionService = MockRepository.GenerateMock <IEncryptionService>(); _workflowMessageService = MockRepository.GenerateMock <IWorkflowMessageService>(); _customerActivityService = MockRepository.GenerateMock <ICustomerActivityService>(); _currencyService = MockRepository.GenerateMock <ICurrencyService>(); _affiliateService = MockRepository.GenerateMock <IAffiliateService>(); _paymentSettings = new PaymentSettings() { ActivePaymentMethodSystemNames = new List <string>() { "Payments.TestMethod" } }; _orderSettings = new OrderSettings(); _localizationSettings = new LocalizationSettings(); _eventPublisher = MockRepository.GenerateMock <IEventPublisher>(); _eventPublisher.Expect(x => x.Publish(Arg <object> .Is.Anything)); _currencySettings = new CurrencySettings(); _orderProcessingService = new OrderProcessingService(_orderService, _webHelper, _localizationService, _languageService, _productService, _paymentService, _logger, _orderTotalCalcService, _priceCalcService, _priceFormatter, _productAttributeParser, _productAttributeFormatter, _giftCardService, _shoppingCartService, _checkoutAttributeFormatter, _shippingService, _shipmentService, _taxService, _customerService, _discountService, _encryptionService, _workContext, _storeContext, _workflowMessageService, _customerActivityService, _currencyService, _affiliateService, _eventPublisher, _paymentSettings, _rewardPointsSettings, _orderSettings, _taxSettings, _localizationSettings, _currencySettings); }
private const int DefaultResourceCacheLimit = 1000000; // number of entries #endif static Configuration() { IsRunningOnMono = (Type.GetType("Mono.Runtime") != null); #if WINDOWS_PHONE var store = IsolatedStorageFile.GetUserStoreForApplication(); if (!store.DirectoryExists("brightstar")) { store.CreateDirectory("brightstar"); } StoreLocation = "brightstar"; TransactionFlushTripleCount = 1000; QueryCache = new NullCache(); #elif PORTABLE StoreLocation = "brightstar"; TransactionFlushTripleCount = 1000; PageCacheSize = DefaultPageCacheSize; ResourceCacheLimit = DefaultResourceCacheLimit; EnableOptimisticLocking = false; EnableQueryCache = false; PersistenceType = DefaultPersistenceType; QueryCache = new NullCache(); #else var appSettings = ConfigurationManager.AppSettings; StoreLocation = appSettings.Get(StoreLocationPropertyName); // Transaction Flushing TransactionFlushTripleCount = GetApplicationSetting(TxnFlushTriggerPropertyName, 10000); // Read Store cache // TODO : Remove this if it is no longer in use. var readStoreObjectCacheSizeString = appSettings.Get(ReadStoreObjectCacheSizeName); ReadStoreObjectCacheSize = 10000; if (!string.IsNullOrEmpty(readStoreObjectCacheSizeString)) { int val; if (int.TryParse(readStoreObjectCacheSizeString, out val)) { if (val > 0) { ReadStoreObjectCacheSize = val; } } } // Connection String ConnectionString = appSettings.Get(ConnectionStringPropertyName); // Query Caching var enableQueryCacheString = appSettings.Get(EnableQueryCacheName); EnableQueryCache = true; if (!string.IsNullOrEmpty(enableQueryCacheString)) { EnableQueryCache = bool.Parse(enableQueryCacheString); } QueryCacheMemory = GetApplicationSetting(QueryCacheMemoryName, DefaultQueryCacheMemory); QueryCacheDiskSpace = GetApplicationSetting(QueryCacheDiskSpaceName, DefaultQueryCacheDiskSpace); QueryCacheDirectory = appSettings.Get(QueryCacheDirectoryName); QueryCache = GetQueryCache(); // StatsUpdate properties StatsUpdateTransactionCount = GetApplicationSetting(StatsUpdateTransactionCountName, 0); StatsUpdateTimespan = GetApplicationSetting(StatsUpdateTimeSpanName, 0); // Advanced embedded application settings - read from the brightstar section of the app/web.config EmbeddedServiceConfiguration = ConfigurationManager.GetSection("brightstar") as EmbeddedServiceConfiguration ?? new EmbeddedServiceConfiguration(); #endif #if !PORTABLE // ResourceCacheLimit ResourceCacheLimit = GetApplicationSetting(ResourceCacheLimitName, DefaultResourceCacheLimit); // Persistence Type var persistenceTypeSetting = GetApplicationSetting(PersistenceTypeName); if (!String.IsNullOrEmpty(persistenceTypeSetting)) { switch (persistenceTypeSetting.ToLowerInvariant()) { case PersistenceTypeAppendOnly: PersistenceType = PersistenceType.AppendOnly; break; case PersistenceTypeRewrite: PersistenceType = PersistenceType.Rewrite; break; default: PersistenceType = DefaultPersistenceType; break; } } else { PersistenceType = DefaultPersistenceType; } // Page Cache Size var pageCacheSizeSetting = GetApplicationSetting(PageCacheSizeName); int pageCacheSize; if (!String.IsNullOrEmpty(pageCacheSizeSetting) && Int32.TryParse(pageCacheSizeSetting, out pageCacheSize)) { PageCacheSize = pageCacheSize; } else { PageCacheSize = DefaultPageCacheSize; } #if !WINDOWS_PHONE // Clustering var clusterNodePortSetting = GetApplicationSetting(ClusterNodePortName); int clusterNodePort; if (!String.IsNullOrEmpty(clusterNodePortSetting) && Int32.TryParse(clusterNodePortSetting, out clusterNodePort)) { ClusterNodePort = clusterNodePort; } else { ClusterNodePort = 10001; } #endif #endif }
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); }
private const int DefaultQueryCacheMemory = 256; // in MB #endif static Configuration() { #if WINDOWS_PHONE var store = IsolatedStorageFile.GetUserStoreForApplication(); if (!store.DirectoryExists("brightstar")) { store.CreateDirectory("brightstar"); } StoreLocation = "brightstar"; LogLevel = "Error"; TransactionFlushTripleCount = 1000; QueryCache = new NullCache(); #else var appSettings = ConfigurationManager.AppSettings; StoreLocation = appSettings.Get(StoreLocationPropertyName); LogLevel = appSettings.Get(LogLevelPropertyName); var httpPortValue = appSettings.Get(HttpPortName); if (!string.IsNullOrEmpty(httpPortValue)) { int port; if (!int.TryParse(httpPortValue, out port)) { port = 8090; } HttPort = port; } else { HttPort = 8090; } var tcpPortValue = appSettings.Get(TcpPortName); if (!string.IsNullOrEmpty(tcpPortValue)) { int port; if (!int.TryParse(tcpPortValue, out port)) { port = 8095; } TcpPort = port; } else { TcpPort = 8095; } var namedPipeValue = appSettings.Get(NetNamedPipeName); NamedPipeName = !string.IsNullOrEmpty(namedPipeValue) ? namedPipeValue : "brightstar"; var transactionFlushTripleCountString = appSettings.Get(TxnFlushTriggerPropertyName); TransactionFlushTripleCount = 10000; if (!string.IsNullOrEmpty(transactionFlushTripleCountString)) { int val; if (int.TryParse(transactionFlushTripleCountString, out val)) { if (val > 0) { TransactionFlushTripleCount = val; } } } var readStoreObjectCacheSizeString = appSettings.Get(ReadStoreObjectCacheSizeName); ReadStoreObjectCacheSize = 10000; if (!string.IsNullOrEmpty(readStoreObjectCacheSizeString)) { int val; if (int.TryParse(readStoreObjectCacheSizeString, out val)) { if (val > 0) { ReadStoreObjectCacheSize = val; } } } ConnectionString = appSettings.Get(ConnectionStringPropertyName); var enableQueryCacheString = appSettings.Get(EnableQueryCacheName); EnableQueryCache = true; if (!string.IsNullOrEmpty(enableQueryCacheString)) { EnableQueryCache = bool.Parse(enableQueryCacheString); } var queryCacheMemoryString = appSettings.Get(QueryCacheMemoryName); int queryCacheMemory; if (!String.IsNullOrEmpty(queryCacheMemoryString) && (Int32.TryParse(queryCacheMemoryString, out queryCacheMemory))) { QueryCacheMemory = queryCacheMemory; } else { QueryCacheMemory = DefaultQueryCacheMemory; } var queryCacheDiskSpaceString = appSettings.Get(QueryCacheDiskSpaceName); int queryCacheDiskSpace; if (!String.IsNullOrEmpty(queryCacheDiskSpaceString) && (Int32.TryParse(queryCacheDiskSpaceString, out queryCacheDiskSpace))) { QueryCacheDiskSpace = queryCacheDiskSpace; } else { QueryCacheDiskSpace = DefaultQueryCacheDiskSpace; } QueryCacheDirectory = appSettings.Get(QueryCacheDirectoryName); QueryCache = GetQueryCache(); var persistenceTypeSetting = appSettings.Get(PersistenceTypeName); if (!String.IsNullOrEmpty(persistenceTypeSetting)) { switch (persistenceTypeSetting.ToLowerInvariant()) { case PersistenceTypeAppendOnly: PersistenceType = PersistenceType.AppendOnly; break; case PersistenceTypeRewrite: PersistenceType = PersistenceType.Rewrite; break; default: PersistenceType = DefaultPersistenceType; break; } } else { PersistenceType = DefaultPersistenceType; } #endif var pageCacheSizeSetting = GetApplicationSetting(PageCacheSizeName); int pageCacheSize; if (!String.IsNullOrEmpty(pageCacheSizeSetting) && Int32.TryParse(pageCacheSizeSetting, out pageCacheSize)) { PageCacheSize = pageCacheSize; } else { PageCacheSize = DefaultPageCacheSize; } var clusterNodePortSetting = GetApplicationSetting(ClusterNodePortName); int clusterNodePort; if (!String.IsNullOrEmpty(clusterNodePortSetting) && Int32.TryParse(clusterNodePortSetting, out clusterNodePort)) { ClusterNodePort = clusterNodePort; } else { ClusterNodePort = 10001; } }
public new void SetUp() { measureDimension1 = new MeasureDimension() { Id = 1, Name = "inch(es)", SystemKeyword = "inch", Ratio = 1M, DisplayOrder = 1, }; measureDimension2 = new MeasureDimension() { Id = 2, Name = "feet", SystemKeyword = "ft", Ratio = 0.08333333M, DisplayOrder = 2, }; measureDimension3 = new MeasureDimension() { Id = 3, Name = "meter(s)", SystemKeyword = "m", Ratio = 0.0254M, DisplayOrder = 3, }; measureDimension4 = new MeasureDimension() { Id = 4, Name = "millimetre(s)", SystemKeyword = "mm", Ratio = 25.4M, DisplayOrder = 4, }; measureWeight1 = new MeasureWeight() { Id = 1, Name = "ounce(s)", SystemKeyword = "oz", Ratio = 16M, DisplayOrder = 1, }; measureWeight2 = new MeasureWeight() { Id = 2, Name = "lb(s)", SystemKeyword = "lb", Ratio = 1M, DisplayOrder = 2, }; measureWeight3 = new MeasureWeight() { Id = 3, Name = "kg(s)", SystemKeyword = "kg", Ratio = 0.45359237M, DisplayOrder = 3, }; measureWeight4 = new MeasureWeight() { Id = 4, Name = "gram(s)", SystemKeyword = "g", Ratio = 453.59237M, DisplayOrder = 4, }; _measureDimensionRepository = MockRepository.GenerateMock<IRepository<MeasureDimension>>(); _measureDimensionRepository.Expect(x => x.Table).Return(new List<MeasureDimension>() { measureDimension1, measureDimension2, measureDimension3, measureDimension4 }.AsQueryable()); _measureDimensionRepository.Expect(x => x.GetById(measureDimension1.Id)).Return(measureDimension1); _measureDimensionRepository.Expect(x => x.GetById(measureDimension2.Id)).Return(measureDimension2); _measureDimensionRepository.Expect(x => x.GetById(measureDimension3.Id)).Return(measureDimension3); _measureDimensionRepository.Expect(x => x.GetById(measureDimension4.Id)).Return(measureDimension4); _measureWeightRepository = MockRepository.GenerateMock<IRepository<MeasureWeight>>(); _measureWeightRepository.Expect(x => x.Table).Return(new List<MeasureWeight>() { measureWeight1, measureWeight2, measureWeight3, measureWeight4 }.AsQueryable()); _measureWeightRepository.Expect(x => x.GetById(measureWeight1.Id)).Return(measureWeight1); _measureWeightRepository.Expect(x => x.GetById(measureWeight2.Id)).Return(measureWeight2); _measureWeightRepository.Expect(x => x.GetById(measureWeight3.Id)).Return(measureWeight3); _measureWeightRepository.Expect(x => x.GetById(measureWeight4.Id)).Return(measureWeight4); var cacheManager = new NullCache(); _measureSettings = new MeasureSettings(); _measureSettings.BaseDimensionId = measureDimension1.Id; //inch(es) _measureSettings.BaseWeightId = measureWeight2.Id; //lb(s) _eventPublisher = MockRepository.GenerateMock<IEventPublisher>(); _eventPublisher.Expect(x => x.Publish(Arg<object>.Is.Anything)); _measureService = new MeasureService(cacheManager, _measureDimensionRepository, _measureWeightRepository, _measureSettings, _eventPublisher); }
public new void SetUp() { _workContext = null; _store = new Store() { Id = 1 }; _storeContext = MockRepository.GenerateMock<IStoreContext>(); _storeContext.Expect(x => x.CurrentStore).Return(_store); var pluginFinder = new PluginFinder(); var cacheManager = new NullCache(); _shoppingCartSettings = new ShoppingCartSettings(); _catalogSettings = new CatalogSettings(); //price calculation service _discountService = MockRepository.GenerateMock<IDiscountService>(); _categoryService = MockRepository.GenerateMock<ICategoryService>(); _productAttributeParser = MockRepository.GenerateMock<IProductAttributeParser>(); _priceCalcService = new PriceCalculationService(_workContext, _storeContext, _discountService, _categoryService, _productAttributeParser, _productService, _shoppingCartSettings, _catalogSettings); _eventPublisher = MockRepository.GenerateMock<IEventPublisher>(); _eventPublisher.Expect(x => x.Publish(Arg<object>.Is.Anything)); _localizationService = MockRepository.GenerateMock<ILocalizationService>(); _settingService = MockRepository.GenerateMock<ISettingService>(); //shipping _shippingSettings = new ShippingSettings(); _shippingSettings.ActiveShippingRateComputationMethodSystemNames = new List<string>(); _shippingSettings.ActiveShippingRateComputationMethodSystemNames.Add("FixedRateTestShippingRateComputationMethod"); _shippingMethodRepository = MockRepository.GenerateMock<IRepository<ShippingMethod>>(); _logger = new NullLogger(); _shippingService = new ShippingService(cacheManager, _shippingMethodRepository, _logger, _productAttributeParser, _productService, _checkoutAttributeParser, _genericAttributeService, _localizationService, _shippingSettings, pluginFinder, _eventPublisher, _shoppingCartSettings, _settingService); _shipmentService = MockRepository.GenerateMock<IShipmentService>(); _paymentService = MockRepository.GenerateMock<IPaymentService>(); _checkoutAttributeParser = MockRepository.GenerateMock<ICheckoutAttributeParser>(); _giftCardService = MockRepository.GenerateMock<IGiftCardService>(); _genericAttributeService = MockRepository.GenerateMock<IGenericAttributeService>(); //tax _taxSettings = new TaxSettings(); _taxSettings.ShippingIsTaxable = true; _taxSettings.PaymentMethodAdditionalFeeIsTaxable = true; _taxSettings.DefaultTaxAddressId = 10; _addressService = MockRepository.GenerateMock<IAddressService>(); _addressService.Expect(x => x.GetAddressById(_taxSettings.DefaultTaxAddressId)).Return(new Address() { Id = _taxSettings.DefaultTaxAddressId }); _taxService = new TaxService(_addressService, _workContext, _taxSettings, _shoppingCartSettings, pluginFinder, _settingService); _rewardPointsSettings = new RewardPointsSettings(); _orderTotalCalcService = new OrderTotalCalculationService(_workContext, _storeContext, _priceCalcService, _taxService, _shippingService, _paymentService, _checkoutAttributeParser, _discountService, _giftCardService, _genericAttributeService, _taxSettings, _rewardPointsSettings, _shippingSettings, _shoppingCartSettings, _catalogSettings); _orderService = MockRepository.GenerateMock<IOrderService>(); _webHelper = MockRepository.GenerateMock<IWebHelper>(); _languageService = MockRepository.GenerateMock<ILanguageService>(); _productService = MockRepository.GenerateMock<IProductService>(); _priceFormatter= MockRepository.GenerateMock<IPriceFormatter>(); _productAttributeFormatter= MockRepository.GenerateMock<IProductAttributeFormatter>(); _shoppingCartService= MockRepository.GenerateMock<IShoppingCartService>(); _checkoutAttributeFormatter= MockRepository.GenerateMock<ICheckoutAttributeFormatter>(); _customerService= MockRepository.GenerateMock<ICustomerService>(); _encryptionService = MockRepository.GenerateMock<IEncryptionService>(); _workflowMessageService = MockRepository.GenerateMock<IWorkflowMessageService>(); _customerActivityService = MockRepository.GenerateMock<ICustomerActivityService>(); _currencyService = MockRepository.GenerateMock<ICurrencyService>(); _affiliateService = MockRepository.GenerateMock<IAffiliateService>(); _paymentSettings = new PaymentSettings() { ActivePaymentMethodSystemNames = new List<string>() { "Payments.TestMethod" } }; _orderSettings = new OrderSettings(); _localizationSettings = new LocalizationSettings(); _eventPublisher = MockRepository.GenerateMock<IEventPublisher>(); _eventPublisher.Expect(x => x.Publish(Arg<object>.Is.Anything)); _currencySettings = new CurrencySettings(); _orderProcessingService = new OrderProcessingService(_orderService, _webHelper, _localizationService, _languageService, _productService, _paymentService, _logger, _orderTotalCalcService, _priceCalcService, _priceFormatter, _productAttributeParser, _productAttributeFormatter, _giftCardService, _shoppingCartService, _checkoutAttributeFormatter, _shippingService, _shipmentService, _taxService, _customerService, _discountService, _encryptionService, _workContext, _storeContext, _workflowMessageService, _customerActivityService, _currencyService, _affiliateService, _eventPublisher, _paymentSettings, _rewardPointsSettings, _orderSettings, _taxSettings, _localizationSettings, _currencySettings); }
public new void SetUp() { #region Test data //color (dropdownlist) pa1 = new ProductAttribute { Id = 1, Name = "Color", }; pva1_1 = new ProductVariantAttribute { Id = 11, ProductId = 1, TextPrompt = "Select color:", IsRequired = true, AttributeControlType = AttributeControlType.DropdownList, DisplayOrder = 1, ProductAttribute = pa1, ProductAttributeId = pa1.Id }; pvav1_1 = new ProductVariantAttributeValue { Id = 11, Name = "Green", DisplayOrder = 1, ProductVariantAttribute = pva1_1, ProductVariantAttributeId = pva1_1.Id }; pvav1_2 = new ProductVariantAttributeValue { Id = 12, Name = "Red", DisplayOrder = 2, ProductVariantAttribute = pva1_1, ProductVariantAttributeId = pva1_1.Id }; pva1_1.ProductVariantAttributeValues.Add(pvav1_1); pva1_1.ProductVariantAttributeValues.Add(pvav1_2); //custom option (checkboxes) pa2 = new ProductAttribute { Id = 2, Name = "Some custom option", }; pva2_1 = new ProductVariantAttribute { Id = 21, ProductId = 1, TextPrompt = "Select at least one option:", IsRequired = true, AttributeControlType = AttributeControlType.Checkboxes, DisplayOrder = 2, ProductAttribute = pa2, ProductAttributeId = pa2.Id }; pvav2_1 = new ProductVariantAttributeValue { Id = 21, Name = "Option 1", DisplayOrder = 1, ProductVariantAttribute = pva2_1, ProductVariantAttributeId = pva2_1.Id }; pvav2_2 = new ProductVariantAttributeValue { Id = 22, Name = "Option 2", DisplayOrder = 2, ProductVariantAttribute = pva2_1, ProductVariantAttributeId = pva2_1.Id }; pva2_1.ProductVariantAttributeValues.Add(pvav2_1); pva2_1.ProductVariantAttributeValues.Add(pvav2_2); //custom text pa3 = new ProductAttribute { Id = 3, Name = "Custom text", }; pva3_1 = new ProductVariantAttribute { Id = 31, ProductId = 1, TextPrompt = "Enter custom text:", IsRequired = true, AttributeControlType = AttributeControlType.TextBox, DisplayOrder = 1, ProductAttribute = pa1, ProductAttributeId = pa3.Id }; #endregion _productAttributeRepo = MockRepository.GenerateMock<IRepository<ProductAttribute>>(); _productAttributeRepo.Expect(x => x.Table).Return(new List<ProductAttribute>() { pa1, pa2, pa3 }.AsQueryable()); _productAttributeRepo.Expect(x => x.GetById(pa1.Id)).Return(pa1); _productAttributeRepo.Expect(x => x.GetById(pa2.Id)).Return(pa2); _productAttributeRepo.Expect(x => x.GetById(pa3.Id)).Return(pa3); _productVariantAttributeRepo = MockRepository.GenerateMock<IRepository<ProductVariantAttribute>>(); _productVariantAttributeRepo.Expect(x => x.Table).Return(new List<ProductVariantAttribute>() { pva1_1, pva2_1, pva3_1 }.AsQueryable()); _productVariantAttributeRepo.Expect(x => x.GetById(pva1_1.Id)).Return(pva1_1); _productVariantAttributeRepo.Expect(x => x.GetById(pva2_1.Id)).Return(pva2_1); _productVariantAttributeRepo.Expect(x => x.GetById(pva3_1.Id)).Return(pva3_1); _productVariantAttributeCombinationRepo = MockRepository.GenerateMock<IRepository<ProductVariantAttributeCombination>>(); _productVariantAttributeCombinationRepo.Expect(x => x.Table).Return(new List<ProductVariantAttributeCombination>().AsQueryable()); _productVariantAttributeValueRepo = MockRepository.GenerateMock<IRepository<ProductVariantAttributeValue>>(); _productVariantAttributeValueRepo.Expect(x => x.Table).Return(new List<ProductVariantAttributeValue>() { pvav1_1, pvav1_2, pvav2_1, pvav2_2 }.AsQueryable()); _productVariantAttributeValueRepo.Expect(x => x.GetById(pvav1_1.Id)).Return(pvav1_1); _productVariantAttributeValueRepo.Expect(x => x.GetById(pvav1_2.Id)).Return(pvav1_2); _productVariantAttributeValueRepo.Expect(x => x.GetById(pvav2_1.Id)).Return(pvav2_1); _productVariantAttributeValueRepo.Expect(x => x.GetById(pvav2_2.Id)).Return(pvav2_2); _productBundleItemAttributeFilter = MockRepository.GenerateMock<IRepository<ProductBundleItemAttributeFilter>>(); _eventPublisher = MockRepository.GenerateMock<IEventPublisher>(); _eventPublisher.Expect(x => x.Publish(Arg<object>.Is.Anything)); _pictureService = MockRepository.GenerateMock<IPictureService>(); var cacheManager = new NullCache(); _productAttributeService = new ProductAttributeService(cacheManager, _productAttributeRepo, _productVariantAttributeRepo, _productVariantAttributeCombinationRepo, _productVariantAttributeValueRepo, _productBundleItemAttributeFilter, _eventPublisher, _pictureService); _productAttributeParser = new ProductAttributeParser(_productAttributeService, new MemoryRepository<ProductVariantAttributeCombination>(), NullCache.Instance); var workingLanguage = new Language(); _workContext = MockRepository.GenerateMock<IWorkContext>(); _workContext.Expect(x => x.WorkingLanguage).Return(workingLanguage); _currencyService = MockRepository.GenerateMock<ICurrencyService>(); _localizationService = MockRepository.GenerateMock<ILocalizationService>(); _localizationService.Expect(x => x.GetResource("GiftCardAttribute.For.Virtual")).Return("For: {0} <{1}>"); _localizationService.Expect(x => x.GetResource("GiftCardAttribute.From.Virtual")).Return("From: {0} <{1}>"); _localizationService.Expect(x => x.GetResource("GiftCardAttribute.For.Physical")).Return("For: {0}"); _localizationService.Expect(x => x.GetResource("GiftCardAttribute.From.Physical")).Return("From: {0}"); _taxService = MockRepository.GenerateMock<ITaxService>(); _priceFormatter = MockRepository.GenerateMock<IPriceFormatter>(); _downloadService = MockRepository.GenerateMock<IDownloadService>(); _webHelper = MockRepository.GenerateMock<IWebHelper>(); _priceCalculationService = MockRepository.GenerateMock<IPriceCalculationService>(); _shoppingCartSettings = MockRepository.GenerateMock<ShoppingCartSettings>(); _productAttributeFormatter = new ProductAttributeFormatter(_workContext, _productAttributeService, _productAttributeParser, _priceCalculationService, _currencyService, _localizationService, _taxService, _priceFormatter, _downloadService, _webHelper, _shoppingCartSettings); }
public new void SetUp() { _workContext = MockRepository.GenerateMock<IWorkContext>(); _store = new Store { Id = 1 }; _storeContext = MockRepository.GenerateMock<IStoreContext>(); _storeContext.Expect(x => x.CurrentStore).Return(_store); var pluginFinder = new PluginFinder(); var cacheManager = new NullCache(); _shoppingCartSettings = new ShoppingCartSettings(); _catalogSettings = new CatalogSettings(); //price calculation service _discountService = MockRepository.GenerateMock<IDiscountService>(); _categoryService = MockRepository.GenerateMock<ICategoryService>(); _productAttributeParser = MockRepository.GenerateMock<IProductAttributeParser>(); _productService = MockRepository.GenerateMock<IProductService>(); _productAttributeService = MockRepository.GenerateMock<IProductAttributeService>(); _genericAttributeService = MockRepository.GenerateMock<IGenericAttributeService>(); _eventPublisher = MockRepository.GenerateMock<IEventPublisher>(); _eventPublisher.Expect(x => x.Publish(Arg<object>.Is.Anything)); _localizationService = MockRepository.GenerateMock<ILocalizationService>(); _settingService = MockRepository.GenerateMock<ISettingService>(); //shipping _shippingSettings = new ShippingSettings(); _shippingSettings.ActiveShippingRateComputationMethodSystemNames = new List<string>(); _shippingSettings.ActiveShippingRateComputationMethodSystemNames.Add("FixedRateTestShippingRateComputationMethod"); _shippingMethodRepository = MockRepository.GenerateMock<IRepository<ShippingMethod>>(); _logger = new NullLogger(); _shippingService = new ShippingService(cacheManager, _shippingMethodRepository, _logger, _productAttributeParser, _productService, _checkoutAttributeParser, _genericAttributeService, _localizationService, _shippingSettings, pluginFinder, _eventPublisher, _shoppingCartSettings, _settingService, this.ProviderManager); _providerManager = MockRepository.GenerateMock<IProviderManager>(); _checkoutAttributeParser = MockRepository.GenerateMock<ICheckoutAttributeParser>(); _giftCardService = MockRepository.GenerateMock<IGiftCardService>(); //tax _taxSettings = new TaxSettings(); _taxSettings.ShippingIsTaxable = true; _taxSettings.PaymentMethodAdditionalFeeIsTaxable = true; _taxSettings.PricesIncludeTax = false; _taxSettings.TaxDisplayType = TaxDisplayType.IncludingTax; _taxSettings.DefaultTaxAddressId = 10; _addressService = MockRepository.GenerateMock<IAddressService>(); _addressService.Expect(x => x.GetAddressById(_taxSettings.DefaultTaxAddressId)).Return(new Address { Id = _taxSettings.DefaultTaxAddressId }); _downloadService = MockRepository.GenerateMock<IDownloadService>(); _services = MockRepository.GenerateMock<ICommonServices>(); _httpRequestBase = MockRepository.GenerateMock<HttpRequestBase>(); _geoCountryLookup = MockRepository.GenerateMock<IGeoCountryLookup>(); _taxService = new TaxService(_addressService, _workContext, _taxSettings, _shoppingCartSettings, pluginFinder, _geoCountryLookup, this.ProviderManager); _rewardPointsSettings = new RewardPointsSettings(); _priceCalcService = new PriceCalculationService(_discountService, _categoryService, _productAttributeParser, _productService, _shoppingCartSettings, _catalogSettings, _productAttributeService, _downloadService, _services, _httpRequestBase, _taxService); _orderTotalCalcService = new OrderTotalCalculationService(_workContext, _storeContext, _priceCalcService, _taxService, _shippingService, _providerManager, _checkoutAttributeParser, _discountService, _giftCardService, _genericAttributeService, _productAttributeParser, _taxSettings, _rewardPointsSettings, _shippingSettings, _shoppingCartSettings, _catalogSettings); }
public void Resolving() { var cache = new NullCache(); Assert.AreEqual("foo", cache.Resolve("urn:x-test:foo", (uri) => "foo")); }