public void Check_Unique_CacheSource() { // Arrange var urls = new List <string> { "12345", "12344", "12345.yaml", "1234.yaml", "1.yaml", "12.yaml", "test.yaml", "tset.yaml", "https://google.com/ru.yaml", "https://google.com/en.yaml", "https://google.com/kz.yaml", }; var locales = new Dictionary <string, string>(); // Act & Assert foreach (var url in urls) { var language = new RemoteLocale("ru", url); locales.Add(language.CacheSource, language.Key); } }
public async Task Check_DownloadContent() { // Arrange var remoteConfig = new RemoteContentConfig { CacheDir = Path.GetTempPath() }; var localConfig = new AssetsContentConfig { ResourceFolder = remoteConfig.CacheDir }; if (!Directory.Exists(localConfig.ResourceFolder)) { Directory.CreateDirectory(localConfig.ResourceFolder); } this.assetsTranslateContentClient = new AssetsTranslateContentClient(new PlatformComponentsFactory(), localConfig); var remoteTranslateContentClient = new RemoteTranslateContentClient(new PlatformComponentsFactory(), remoteConfig); var remoteLocale = new RemoteLocale("ru", RemoteTranslateContentClientTests.TestLocaleUrl); await remoteTranslateContentClient.GetContent(remoteLocale, null); var locales = this.assetsTranslateContentClient.GetLocales(); // Act var content = await this.assetsTranslateContentClient.GetContent(locales.First(), null, CancellationToken.None); // Assert Assert.IsNotEmpty(content); }
public async Task Crash_Download_File() { // Arrange var badRemoteLanguage = new RemoteLocale("ru", "badbad"); // Act & Assert Assert.ThrowsAsync <InvalidOperationException>( () => this.remoteTranslateContentClient.GetContent(badRemoteLanguage, null)); }
public virtual IList <ILocale> GetLocales() { var locales = new List <ILocale>(); foreach (var locale in this.contentConfig.Locales) { var remoteLocale = new RemoteLocale(locale.Key, locale.Value) { CacheFilePrefix = this.contentConfig.CacheFilePrefix }; // set status remoteLocale.Downloaded = this.platformCacheFileManager.ContainsFile(remoteLocale.CacheSource); locales.Add(remoteLocale); } return(locales); }
public RemoteLocaleCellElement(RemoteLocale remoteLocale) : base(remoteLocale) { this.Locale = remoteLocale; }