public async void Search_Term_One_Result(string text, int expectedId) { //arrange var providerSettings = TestHelper.CreateProviderSettings(); var parser = new Parser(providerSettings); var excelTermLoaderService = new ExcelTermLoaderService(providerSettings); var entryTransformer = new EntryTransformerService(parser); var excelTermProviderService = new ExcelTermProviderService(excelTermLoaderService, entryTransformer); var termEntries = await excelTermProviderService.LoadEntries(); var termSearchService = new NormalTermSeachService(providerSettings); //act var results = termSearchService.Search(text, termEntries, 1); //assert Assert.Equal(results.Count, 1); var actualResult = results.First(); Assert.Equal(expectedId, actualResult.Id); Assert.Equal(providerSettings.SourceLanguage, actualResult.Language.Locale); }
public ITerminologyProvider CreateTerminologyProvider(Uri terminologyProviderUri, ITerminologyProviderCredentialStore credentials) { TerminologyProviderExcel terminologyProvider; try { var persistenceService = new PersistenceService(); var providerSettings = persistenceService.Load(terminologyProviderUri); //in case we didn't any settings stored there is no need to load the provider if (providerSettings == null) { return(null); } var termSearchService = new NormalTermSeachService(providerSettings); terminologyProvider = new TerminologyProviderExcel(providerSettings, termSearchService); Task.Run(terminologyProvider.LoadEntries); } catch (Exception ex) { Log.Logger.Error($"CreateTerminologyProvider method: {ex.Message}\n {ex.StackTrace}"); throw ex; } return(terminologyProvider); }
public ITerminologyProvider[] Browse(IWin32Window owner, ITerminologyProviderCredentialStore credentialStore) { var result = new List <ITerminologyProvider>(); try { var settingsDialog = new Settings(); var dialogResult = settingsDialog.ShowDialog(); if (dialogResult == DialogResult.OK || dialogResult == DialogResult.Yes) { var settings = settingsDialog.GetSettings(); var persistenceService = new PersistenceService(); var provider = new TerminologyProviderExcel(settings); settings.Uri = provider.Uri; persistenceService.AddSettings(settings); var providerSettings = persistenceService.Load(provider.Uri); var termSearchService = new NormalTermSeachService(providerSettings); var excelProvider = new TerminologyProviderExcel(providerSettings, termSearchService); result.Add(excelProvider); } } catch (Exception ex) { throw ex; } return(result.ToArray()); }
public ITerminologyProvider CreateTerminologyProvider(Uri terminologyProviderUri, ITerminologyProviderCredentialStore credentials) { TerminologyProviderExcel terminologyProvider = null; try { var persistenceService = new PersistenceService(); var providerSettings = persistenceService.Load(terminologyProviderUri); //in case we didn't any settings stored there is no need to load the provider if (providerSettings == null) { // new Dictionary<string, string> { { "Uri", terminologyProviderUri.ToString() } }); return(terminologyProvider); } var termSearchService = new NormalTermSeachService(providerSettings); terminologyProvider = new TerminologyProviderExcel(providerSettings, termSearchService); Task.Run(terminologyProvider.LoadEntries); } catch (Exception ex) { throw ex; } return(terminologyProvider); }
public async void Search_Term_Phrase_With_Separator(string text, int expectedNumberResults) { //arrange var providerSettings = TestHelper.CreateProviderSettings(); var parser = new Parser(providerSettings); var excelTermLoaderService = new ExcelTermLoaderService(providerSettings); var entryTransformer = new EntryTransformerService(parser); var excelTermProviderService = new ExcelTermProviderService(excelTermLoaderService, entryTransformer); var termEntries = await excelTermProviderService.LoadEntries(); var termSearchService = new NormalTermSeachService(providerSettings); //act var results = termSearchService.Search(text, termEntries, expectedNumberResults); //assert Assert.Equal(results.Count, expectedNumberResults); }