public void Given_Configuration_When_GetCityServiceInvoked_Then_ICityServiceRetrived() { var configuration = new InternalConfiguration(StaticDataConfigurationBuilder.Generate().SetApiPreferably(false)); var service = StaticDataServiceFactory.GetCityService(configuration); Assert.IsNotNull(service); Assert.AreEqual(typeof(CityService), service.GetType()); }
public void Given_Nothing_When_GenerateAndBuild_Then_DefaultConfigRetrived() { var testConfig = StaticDataConfigurationBuilder.Generate().Build(); Assert.AreEqual(testConfig.BaseCurrency, StaticDataConfigurationBuilder.DEFAULT_BASE_CURRENCY); Assert.IsFalse(testConfig.ConfiguredCurrencies.Any()); Assert.IsTrue(testConfig.ApiDataPeferably); }
public void Given_ConfigurationWithApiTrue_When_GetCountryServiceInvoked_Then_ICountryServiceWithExternalServiceRetrived() { var configuration = new InternalConfiguration(StaticDataConfigurationBuilder.Generate()); var service = StaticDataServiceFactory.GetCountryService(configuration); Assert.IsNotNull(service); Assert.AreEqual(typeof(CountryService), service.GetType()); }
public void Given_Configuration_When_GetExchangeRateServiceInvoked_Then_IExchangeRateServiceRetrived() { var configuration = new InternalConfiguration(StaticDataConfigurationBuilder.Generate()); var service = StaticDataServiceFactory.GetExchangeRateService(configuration); Assert.IsNotNull(service); Assert.AreEqual(typeof(ExchangeRateService), service.GetType()); }
public void Given_ConfiguredCurrency_When_GenerateAddConfiguredCurrencyAndBuild_Then_ConfigRetrivedWithSpecifiedConfigCurrency() { var configCurrency = "EUR"; var testConfig = StaticDataConfigurationBuilder.Generate() .AddConfiguredCurrency(configCurrency) .Build(); Assert.AreEqual(testConfig.BaseCurrency, StaticDataConfigurationBuilder.DEFAULT_BASE_CURRENCY); Assert.IsTrue(testConfig.ConfiguredCurrencies.Any(x => x.Equals(configCurrency))); Assert.IsTrue(testConfig.ApiDataPeferably); }
public void Given_DefaultCurrency_When_GenerateAndSetBaseCurrencyAndBuild_Then_ConfigRetrivedWithSameDefaultCurrency() { var defaultCurrency = "EUR"; var testConfig = StaticDataConfigurationBuilder.Generate() .SetBaseCurrency(defaultCurrency) .Build(); Assert.AreEqual(testConfig.BaseCurrency, defaultCurrency); Assert.IsFalse(testConfig.ConfiguredCurrencies.Any()); Assert.IsTrue(testConfig.ApiDataPeferably); }
public void Given_ApiPrerably_When_GenerateAndSetApiPreferablyAndBuild_Then_ConfigRetrivedWithSamePreferably() { var preferability = false; var testConfig = StaticDataConfigurationBuilder.Generate() .SetApiPreferably(preferability) .Build(); Assert.AreEqual(testConfig.BaseCurrency, StaticDataConfigurationBuilder.DEFAULT_BASE_CURRENCY); Assert.IsFalse(testConfig.ConfiguredCurrencies.Any()); Assert.AreEqual(testConfig.ApiDataPeferably, preferability); }
public void Given_EmptyCurrencyConverterApiKey_When_GenerateAndAddCurrencyConverterApiKeyAndBuild_Then_ErrorRetrived() { var testConfigBuilder = StaticDataConfigurationBuilder.Generate() .AddCurrencyConverterApiKey(string.Empty); var testConfig = testConfigBuilder.Build(); Assert.IsTrue(testConfigBuilder.Errors.Any()); Assert.AreEqual(testConfig.BaseCurrency, StaticDataConfigurationBuilder.DEFAULT_BASE_CURRENCY); Assert.IsFalse(testConfig.ConfiguredCurrencies.Any()); Assert.AreEqual(testConfig.CurrencyConversionApiKey, string.Empty); Assert.IsTrue(testConfig.ApiDataPeferably); }
public void Given_CurrencyConverterApiKey_When_GenerateAndAddCurrencyConverterApiKeyAndBuild_Then_DefaultConfigRetrived() { var testKey = "TEST_KEY_STATICDATA"; var testConfig = StaticDataConfigurationBuilder.Generate() .AddCurrencyConverterApiKey(testKey) .Build(); Assert.AreEqual(testConfig.BaseCurrency, StaticDataConfigurationBuilder.DEFAULT_BASE_CURRENCY); Assert.IsFalse(testConfig.ConfiguredCurrencies.Any()); Assert.AreEqual(testConfig.CurrencyConversionApiKey, testKey); Assert.IsTrue(testConfig.ApiDataPeferably); }
public void Given_ConfiguredCurrenciesCollection_When_GenerateAddConfiguredCurrenciesAndBuild_Then_ConfigRetrivedWithSpecifiedConfigCurrencies() { var configCurrencies = new List <string> { "EUR", "GBP" }; var testConfig = StaticDataConfigurationBuilder.Generate() .AddConfiguredCurrencies(configCurrencies) .Build(); Assert.AreEqual(testConfig.BaseCurrency, StaticDataConfigurationBuilder.DEFAULT_BASE_CURRENCY); Assert.IsTrue(testConfig.ConfiguredCurrencies.Any(x => configCurrencies.Contains(x))); Assert.IsTrue(testConfig.ApiDataPeferably); }
internal static IExchangeRateService CreateMockService(bool goodConfiguration) { var mockedConfiguration = StaticDataConfigurationBuilder.Generate().SetBaseCurrency(GetMockedConfiguredCurrencyBase()); if (goodConfiguration) { mockedConfiguration.AddConfiguredCurrencies(GetMockedConfiguredCurrencies()); } else { mockedConfiguration.AddConfiguredCurrencies(GetMockedConfiguredCurrenciesWithUnknown()); } var multipleRepository = CreateMockMultipleRepository(); var singleRepository = CreateMockSingleRepository(); return(new ExchangeRateService(new InternalConfiguration(mockedConfiguration), singleRepository, multipleRepository)); }
internal static IExchangeRateSingleRepository CreateMockSingleRepository() { var mockedConfiguration = new InternalConfiguration(StaticDataConfigurationBuilder.Generate().AddCurrencyConverterApiKey(TestKeys.TestFreeCurrencyConverterKey)); return(new ExchangeRateSingleExternalService(mockedConfiguration)); }
internal static IExchangeRateMultipleRepository CreateMockMultipleRepository() { var mockedConfiguration = new InternalConfiguration(StaticDataConfigurationBuilder.Generate()); return(new ExchangeRateMultipleExternalService(mockedConfiguration)); }
private static ICountryRepository GetCountryExternalService() { var mockedConfiguration = new InternalConfiguration(StaticDataConfigurationBuilder.Generate().SetApiPreferably(false)); return(new CountryExternalService(mockedConfiguration)); }