public bool CanHandle(BrandEntity brand, SkinEntity skin) { using (var webClient = _serviceLocator.GetInstance <IWebClientFactory>().CreateWebClient()) { return(CCKUtils.IsCCKClient(brand, skin, webClient)); } }
private void ReloadTestCasesAsync(BrandEntity brand, SkinEntity skin) { var newABTestCases = new ABTestCaseSetViewModel[0]; if (brand != null && skin != null) { newABTestCases = ClientInformationProvider.GetABTestCases(brand, skin) .Select(tc => new ABTestCaseSetViewModel(tc)) .ToArray(); } ServiceLocator.GetInstance <IApplicationServices>().ExecuteOnUIThread(() => { UbscribeFromTestsPropertyChanged(TestCaseSets); TestCaseSets = newABTestCases; SubscribeToTestsPropertyChanged(newABTestCases); if (brand != null && skin != null) { this.ShowNoAbTestDetectedMessage = true; } OnPropertyChanged(nameof(IsValid)); }); }
public ABTestCaseSet[] GetABTestCases(BrandEntity brand, SkinEntity skin) { var skinCode = new SkinCode(brand.Id, skin.Id); var fileDescriptors = DiscoverFilesDescriptors(); return(FindABTestCases(brand, skin).Where(tc => tc.AppliesTo(skinCode, fileDescriptors)).ToArray()); }
private IPreloaderSetup GetPreloaderSetup(BrandEntity brand, SkinEntity skin) { using (var webClient = _serviceLocator.GetInstance <IWebClientFactory>().CreateWebClient()) { return(_preloaderSetupParser.Parse(CCKUtils.ReadPreloaderSetup(brand, skin, webClient))); } }
public static bool IsCCKClient(BrandEntity brand, SkinEntity skin, IWebClient webClient) { try { PathDescriptor cdnUrl = brand.CDNUrl; var versionInfo = ExtractVersionInfo(brand, skin, ParseVersionsJson(cdnUrl, webClient)); if (versionInfo == null) { return(false); } var majorDefaultClientVersion = NdlVersionParser.ExtractMajorVersion(versionInfo.Version); if (string.IsNullOrEmpty(majorDefaultClientVersion)) { return(false); } return(VersionNumber.Parse(majorDefaultClientVersion) >= new VersionNumber("7.4")); } catch (HttpException) { return(false); } }
public virtual IClientUrlBuilder GetClientUrlBuilder(BrandEntity brand, SkinEntity skin) { using (var webClient = WebClientFactory.CreateWebClient()) { return(CreateUrlBuilder(brand, skin, GetVersion(brand, skin, webClient))); } }
public static ClientVersionInfo ExtractVersion(BrandEntity brand, SkinEntity skin, VersionsFileContent versions) { var specificVersion = versions.Clients.FirstOrDefault(c => c.Brand == brand.Id.ToString() && c.Skin == skin.Id.ToString() && c.Language == "eng"); if (specificVersion == null) { specificVersion = versions.Clients.FirstOrDefault(c => c.Brand == brand.Id.ToString() && c.Skin == skin.Id.ToString() && c.Language == "*"); } if (specificVersion == null) { specificVersion = versions.Clients.FirstOrDefault(c => c.Brand == brand.Id.ToString() && c.Skin == "*" && c.Language == "*"); } if (specificVersion != null) { return(new ClientVersionInfo(specificVersion.Version, specificVersion.PreloaderSetupPath)); } else { return(new ClientVersionInfo(versions.DefaultFolder, versions.PreloaderSetupPath)); } }
public void Read_ConfigurationFileWithTestCasesDefined_FilesOverridesAreCorrectlyRead() { var brand = new BrandEntity(1, "888Casino", "http://localhost/casino"); var skin = new SkinEntity(4, "Non UK"); var webClient = Substitute.For <IWebClient>(); webClient.DownloadStringReturns("http://localhost/casino/application/ABTesting_Configuration.xml", @"<test ID='2' Name='Test name as string' Description='Long description of the test'> <test_cases brand='0' skin='4' lang='en'> <test_case ID='1' IsDefault='true' Method='1' Name='Acquisition' UsePercentage='93.55' Description='Acquisition login test case' ClientPath='../../setups/ab-testing/fileMapping1.xml'/> <test_case ID='2' IsDefault='false' Method='1' Name='Test' UsePercentage='6.45' Description='test case' ClientPath='../../a/b/test.xml'/> </test_cases> </test>"); webClient.DownloadStringReturns("http://localhost/casino/versionX/setups/ab-testing/fileMapping1.xml", @"<overrides> <overrides originalFile='../../bin/application/version.xml' overrideFile='../../setups/ab-testing/FLASH_MLNG/version.xml'/> </overrides>"); webClient.DownloadStringReturns("http://localhost/casino/versionX/a/b/test.xml", @"<overrides> <overrides originalFile='../../navigation/plan/4/navigation_plan_ndl.xmm' overrideFile='../../setups/ab-testing/HTML5_MLNG/navigation_plan_ndl.xmm'/> <overrides originalFile='../../navigation/plan/games_properties.xmm' overrideFile='../../setups/ab-testing/HTML5_MLNG/games_properties.xmm'/> <overrides type='configuration' originalFile='../../brand/brand_%BRAND%/skin_%SKIN%/skin.xml' overrideFile='../../setups/ab-testing/testCase1/skin.xml'/> </overrides>"); var skinCode = new SkinCode(0, 4); var reader = CreateReader(webClient, CreateClientUrlBuilder(brand, skin)); var configuration = reader.Read(brand.CDNUrl); var testCases = configuration.TestCaseSets[0]; var test = testCases[0]; Assert.AreEqual(1, test.FilesOverride.Count); var file = test.FilesOverride[0]; AssertEquals("../../bin/application/version.xml", file.GetOriginalFile(skinCode)); AssertEquals("../../setups/ab-testing/FLASH_MLNG/version.xml", file.OverrideFile); test = testCases[1]; Assert.AreEqual(3, test.FilesOverride.Count); file = test.FilesOverride[0]; AssertEquals("../../navigation/plan/4/navigation_plan_ndl.xmm", file.GetOriginalFile(skinCode)); AssertEquals("../../setups/ab-testing/HTML5_MLNG/navigation_plan_ndl.xmm", file.OverrideFile); file = test.FilesOverride[1]; AssertEquals("../../navigation/plan/games_properties.xmm", file.GetOriginalFile(skinCode)); AssertEquals("../../setups/ab-testing/HTML5_MLNG/games_properties.xmm", file.OverrideFile); file = test.FilesOverride[2]; AssertEquals("../../brand/brand_0/skin_4/skin.xml", file.GetOriginalFile(skinCode)); AssertEquals("../../setups/ab-testing/testCase1/skin.xml", file.OverrideFile); }
public ISkinDefinitionBuilder GetSkinDefinitionBuilder(BrandEntity brand, SkinEntity skin, ABTestCaseDescriptor abTest) { var clientUrlBuilder = GetClientUrlBuilder(brand, skin); var baseUrl = clientUrlBuilder.BuildBaseUrl(abTest?.Test); var files = CreateFiles(new SkinCode(brand.Id, skin.Id), baseUrl, abTest?.Test); return(new SkinDefinitionBuilder(clientUrlBuilder.GetVersion(abTest?.Test), CreateParser(files), CreateConverter(files))); }
public ISkinDefinitionBuilder GetSkinDefinitionBuilder(BrandEntity brand, SkinEntity skin, ABTestCaseDescriptor abTestDescriptor) { var clientBuilder = GetClientUrlBuilder(brand, skin); IPreloaderSetup preloaderSetup = GetPreloaderSetup(brand, skin); var files = CreateFiles(preloaderSetup.GetFileDescriptors(brand, skin), clientBuilder.BuildBaseUrl(abTestDescriptor?.Test), new SkinCode(brand.Id, skin.Id), abTestDescriptor?.Test); return(new SkinDefinitionBuilder(clientBuilder.GetVersion(abTestDescriptor?.Test), CreateParser(files), CreateConverer(files))); }
public IClientInformationProvider GetProvider(BrandEntity brand, SkinEntity skin) { foreach (var provider in _providers) { if (provider.CanHandle(brand, skin)) { return(provider); } } throw new InvalidOperationException($"Can't find a client for '{brand.ToString()}' and skin '{skin.ToString()}'; CDN={brand.CDNUrl}"); }
public EnvironmentConnection[] GetEnvironmentConnections(BrandEntity brand, SkinEntity skin) { var themeEntry = FindThemeEntry(brand, skin); var environmentSet = this.EnvironmentsSets.FirstOrDefault(es => string.Compare(es.Name, themeEntry.ClientProfile.Environmentset, true) == 0); if (environmentSet == null) { throw new ArgumentException($"Couldn't find an environment set for brand {brand.Id}-{brand.Name} and skin {skin.Id}-{skin.Name}"); } return(environmentSet.Environmnets.Select(env => new EnvironmentConnection(env.Name, new PathDescriptor(env.Path))) .ToArray()); }
public void GetBaseUrl_WebClientDownloadString_ReceivesCorrectParameters() { var webClient = Substitute.For <IWebClient>(); webClient.DownloadString(new PathDescriptor("http://ndl-cdn.safe-iplay.com/casino/application/versions.xml")).Returns("<setup defaultFolder='6.2-0-375'/>"); var clientUrlBuilderFactory = new XmlClientUrlBuilderFactory(CreateWebClientFactorySubstitute(webClient)); var brand = new BrandEntity(0, "888Casino", "http://ndl-cdn.safe-iplay.com/casino"); var skin = new SkinEntity(4, "Non UK"); var urlInfo = clientUrlBuilderFactory.GetClientUrlBuilder(brand, skin); webClient.Received().DownloadString(new PathDescriptor("http://ndl-cdn.safe-iplay.com/casino/application/versions.xml")); }
private ABTestCaseSet[] FindABTestCases(BrandEntity brand, SkinEntity skin, IPreloaderSetup preloaderSetup) { var abTestConfigurationReader = CreateJsonABTestingConfigurationReader(brand, skin, preloaderSetup); var abTestConfiguration = abTestConfigurationReader.Read(brand.CDNUrl); if (abTestConfiguration == null) { return(new ABTestCaseSet[0]); } return(abTestConfiguration.GetApplicableTestCases(new SkinCode(brand.Id, skin.Id))); }
public override Player Map(PlayerEntity entity) { Type type = charactarTypesDict[entity.Character]; SkinEntity skinEntity = _uof.Repository <ISkinsRepository>().Get(entity.SkinId); Skin skin = _skinMapper.Map(skinEntity); WeaponEntity weaponEntity = _uof.Repository <IWeaponsRepository>().Get(entity.WeaponId); Weapon weapon = _weaponMapper.Map(weaponEntity); Character character = (Character)Activator.CreateInstance(type, entity.Id, skin, weapon); Player player = (Player)Activator.CreateInstance(typeof(Player), entity.Id, entity.Money, character); return(player); }
public void GetBaseUrl_IfNoBrandSkinSpecialFolder_UseDefaultFolder() { var webClient = Substitute.For <IWebClient>(); webClient.DownloadStringReturns("http://ndl-cdn.safe-iplay.com/casino/application/versions.xml", "<setup defaultFolder='6.2-0-375'/>"); var clientUrlBuilderFactory = new XmlClientUrlBuilderFactory(CreateWebClientFactorySubstitute(webClient)); var brand = new BrandEntity(0, "888Casino", "http://ndl-cdn.safe-iplay.com/casino"); var skin = new SkinEntity(4, "Non UK"); var url = clientUrlBuilderFactory.GetClientUrlBuilder(brand, skin).BuildBaseUrl(null); AssertEquals("http://ndl-cdn.safe-iplay.com/casino/6.2-0-375/", url); }
public string TryReadDefaultFolderFromVersionsJson(BrandEntity brand, SkinEntity skin, PathDescriptor cdnUrlWithTrailingSlash, IWebClient webClient) { string versionsJson = null; try { versionsJson = CCKUtils.ReadVersionsJsonFile(cdnUrlWithTrailingSlash, webClient); } catch (HttpNotFoundException) { return(null); } return(ExtractVersion(brand, skin, ParseVersionsJson(versionsJson)).Version); }
public void GetBaseUrl_WhenWebClientThrowsHttpNotFound_ReturnTheBrandCDNUrl() { var webClient = Substitute.For <IWebClient>(); webClient.DownloadString(new PathDescriptor("http://ndl-cdn.safe-iplay.com/casino/7.2-0-60c/application/versions.xml")) .Returns(x => { throw new HttpNotFoundException(404, "Not found", "http://ndl-cdn.safe-iplay.com/casino/7.2-0-60c/application/versions.xml"); }); var clientUrlBuilderFactory = new XmlClientUrlBuilderFactory(CreateWebClientFactorySubstitute(webClient)); var brand = new BrandEntity(0, "888Casino", "http://ndl-cdn.safe-iplay.com/casino/7.2-0-60c"); var skin = new SkinEntity(4, "Non UK"); var url = clientUrlBuilderFactory.GetClientUrlBuilder(brand, skin).BuildBaseUrl(null); AssertEquals(brand.CDNUrl, url); }
protected string TryReadDefaultFolderFromVersionsXml(BrandEntity brand, SkinEntity skin, PathDescriptor cdnUrlWithTrailingSlash, IWebClient webClient) { string versionsXml = null; try { versionsXml = webClient.DownloadString(cdnUrlWithTrailingSlash + new PathDescriptor("application/versions.xml")); } catch (HttpNotFoundException) { return(null); } return(ExtractVersion(brand, skin, ParseVersionsXml(versionsXml)).Version); }
public void GetBaseUrl_AFolderIsSpecifidedForTheProvidedBrandAnySkinAndAnyLanguage() { var webClient = Substitute.For <IWebClient>(); webClient.DownloadStringReturns("http://ndl-cdn.safe-iplay.com/casino/application/versions.xml", @"<setup defaultFolder='6.2-0-375'> <client brand='0' skin='*' lang='*' version='7.2-0-60c'/> </setup>"); var clientUrlBuilderFactory = new XmlClientUrlBuilderFactory(CreateWebClientFactorySubstitute(webClient)); var brand = new BrandEntity(0, "888Casino", "http://ndl-cdn.safe-iplay.com/casino"); var skin = new SkinEntity(4, "Non UK"); var url = clientUrlBuilderFactory.GetClientUrlBuilder(brand, skin).BuildBaseUrl(null); AssertEquals("http://ndl-cdn.safe-iplay.com/casino/7.2-0-60c/", url); }
public static string ReadPreloaderSetup(BrandEntity brand, SkinEntity skin, IWebClient webClient) { PathDescriptor cdnUrl = brand.CDNUrl; var versionInfo = ExtractVersionInfo(brand, skin, ParseVersionsJson(cdnUrl, webClient)); PathDescriptor preloaderSetupUrl = null; if (string.IsNullOrEmpty(versionInfo.PreloaderSetupPath)) { preloaderSetupUrl = cdnUrl + new PathDescriptor("application/preloader_setup.json"); } else { preloaderSetupUrl = cdnUrl + new PathDescriptor("application/" + new PathDescriptor(versionInfo.PreloaderSetupPath)); } return(webClient.DownloadString(preloaderSetupUrl)); }
protected override string GetVersion(BrandEntity brand, SkinEntity skin, IWebClient webClient) { var version = TryReadDefaultFolderFromVersionsJson(brand, skin, brand.CDNUrl, webClient); if (!string.IsNullOrEmpty(version)) { return(version); } version = TryReadDefaultFolderFromVersionsXml(brand, skin, brand.CDNUrl, webClient); if (!string.IsNullOrEmpty(version)) { return(version); } return(TryReadeDefaultFolderFromClientSettingsJs(webClient, brand.CDNUrl)); }
public ABTestCaseSet[] GetABTestCases(BrandEntity brand, SkinEntity skin) { var preloaderSetup = GetPreloaderSetup(brand, skin); var skinCode = new SkinCode(brand.Id, skin.Id); var fileDescriptors = preloaderSetup.GetFileDescriptors(brand, skin); var result = new List <ABTestCaseSet>(); foreach (var testCase in FindABTestCases(brand, skin, preloaderSetup)) { if (testCase.AppliesTo(skinCode, fileDescriptors)) { result.Add(testCase); } } return(result.ToArray()); }
public ClientUrlBuilderViewModel(BrandEntity brand, SkinEntity skin, ABTestCase abTest, IClientInformationProvider clientInformationProvider) { _brand = brand; _skin = skin; _abTest = abTest; _clientInformationProvider = clientInformationProvider; _clientUrlBuilder = clientInformationProvider.GetClientUrlBuilder(brand, skin); _environmentsConnections = clientInformationProvider.GetEnvironmentsConnections(brand, skin); #warning maybe I should do something with this hard coded PRODUCTION value. _selectedEnvironmentConnection = _environmentsConnections.FirstOrDefault(e => e.Name == "PRODUCTION"); if (_selectedEnvironmentConnection == null) { _selectedEnvironmentConnection = _environmentsConnections.FirstOrDefault(); } UpdateSocketsSetupOverrideProvider(); }
public bool CanHandle(BrandEntity brand, SkinEntity skin) { return(!IsCCKClient(brand, skin)); }
public IClientUrlBuilder GetClientUrlBuilder(BrandEntity brand, SkinEntity skin) { return(new JsonClientUrlBuilderFactory(_serviceLocator.GetInstance <IWebClientFactory>(), GetPreloaderSetup(brand, skin)) .GetClientUrlBuilder(brand, skin)); }
public IFiddlerOverrideProvider GetSocketsSetupOverrideProvider(BrandEntity brand, SkinEntity skin, EnvironmentConnection environmentConnection) { if (environmentConnection == null) { throw new ArgumentNullException(nameof(environmentConnection)); } var environmentConfigurationFilePath = GetClientUrlBuilder(brand, skin).BuildBaseUrl(null) + environmentConnection.ConfigurationFilePath; return(new JsonSocketsSetupOverrideProvider(environmentConfigurationFilePath, _serviceLocator.GetInstance <IMainProxyAdapter>().Port)); }
private JsonABTestingConfigurationReader CreateJsonABTestingConfigurationReader(BrandEntity brand, SkinEntity skin, IPreloaderSetup preloaderSetup) { return(new JsonABTestingConfigurationReader(_serviceLocator.GetInstance <IWebClientFactory>(), preloaderSetup.GetNavigationPlanPath(brand, skin))); }
private static ClientVersionInfo ExtractVersionInfo(BrandEntity brand, SkinEntity skin, VersionsFileContent versions) { return(ClientUrlBuilderFactory.ExtractVersion(brand, skin, versions)); }
public EnvironmentConnection[] GetEnvironmentsConnections(BrandEntity brand, SkinEntity skin) { return(GetPreloaderSetup(brand, skin).GetEnvironmentConnections(brand, skin)); }