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(); //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) { TelemetryService.Instance.Init(); var persistenceService = new PersistenceService(); var termSearchService = new NormalTermSeachService(); var providerSettings = persistenceService.Load(terminologyProviderUri); var terminologyProvider = new TerminologyProviderExcel(providerSettings, termSearchService); Task.Run(terminologyProvider.LoadEntries); return terminologyProvider; }
public ITerminologyProvider[] Browse(IWin32Window owner, ITerminologyProviderCredentialStore credentialStore) { TelemetryService.Instance.Init(); var settingsDialog = new Settings(); settingsDialog.ShowDialog(); var providerUri=settingsDialog.GetProviderUri(); var persistenceService = new PersistenceService(); var termSearchService = new NormalTermSeachService(); var providerSettings = persistenceService.Load(providerUri); var excelProvider = new TerminologyProviderExcel(providerSettings, termSearchService); return new ITerminologyProvider[] {excelProvider}; }
public async void Search_Term_Phrase_Multiple_Results(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(); //act var results = termSearchService.Search(text, termEntries, expectedNumberResults); //assert Assert.Equal(results.Count, expectedNumberResults); }
private void submitBtn_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(separatorTextBox.Text) || string.IsNullOrWhiteSpace(pathTextBox.Text)) { MessageBox.Show(@"Please complete all fields", "", MessageBoxButtons.OK); return; } var provider = new ProviderSettings { HasHeader = hasHeader.Checked, ApprovedColumn = approvedBox.Text, SourceColumn = sourceBox.Text, TargetColumn = targetBox.Text, SourceLanguage = (CultureInfo) sourceLanguageComboBox.SelectedItem, TargetLanguage = (CultureInfo) targetLanguageComboBox.SelectedItem, Separator = separatorTextBox.Text[0], TermFilePath = pathTextBox.Text, }; var termSearchService = new NormalTermSeachService(); var persistence = new PersistenceService(); var excelProvider = new TerminologyProviderExcel(provider, termSearchService); provider.Uri = excelProvider.Uri; _providerUri = provider.Uri; persistence.AddSettings(provider); persistence.Save(); Close(); }