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 void Create_Entry_Term_Fields(string approved, int fieldNumber, string expected)
 {
     //arrange
     var providerSettings = TestHelper.CreateProviderSettings();
     var parser = new Parser(providerSettings);
     var transformerService = new EntryTransformerService(parser);
     var approvals = parser.Parse(approved);
     //act
     var fields = transformerService.CreateEntryTermFields(fieldNumber, approvals);
     //assert
     Assert.Equal(fields[0].Value, expected);
 }
        public void Create_Entry_Term(string terms, int numberOfTerms)
        {
            //arrange
            var providerSettings = TestHelper.CreateProviderSettings();
            var parser = new Parser(providerSettings);
            var transformerService = new EntryTransformerService(parser);

            //act
            var entryTerms = transformerService.CreateEntryTerms(terms);
            //assert
            Assert.Equal(entryTerms.Count, numberOfTerms);
        }
        public void Create_Entry_Terms_With_Fields(string terms
            , string approved
            , int numberOfTerms)
        {
            //arrange
            var providerSettings = TestHelper.CreateProviderSettings();
            var parser = new Parser(providerSettings);
            var transformerService = new EntryTransformerService(parser);

            //act
            var entryTerms = transformerService.CreateEntryTerms(terms, approved);
            //assert
            Assert.Equal(entryTerms.Count, numberOfTerms);
            var entryTerm = entryTerms[entryTerms.Count - 1];
            Assert.True(entryTerm.Fields.Count > 0);
        }
        public async void Load_Entries()
        {
            var providerSettings = TestHelper.CreateProviderSettings();
            var excelTermLoaderService = new TestExcelLoader();
            var parser = new Parser(providerSettings);
            var transformerService = new EntryTransformerService(parser);
            var actualTerms = await excelTermLoaderService.LoadTerms();
            var excelTermProviderService =
                new ExcelTermProviderService(excelTermLoaderService, transformerService);
            var sw = Stopwatch.StartNew();
            var expected = await excelTermProviderService.LoadEntries();
            sw.Stop();
            var el = sw.Elapsed;
            Assert.Equal(expected.Count, actualTerms.Count);

        }
        public void Create_Entry_Languages()
        {
            //arrange
            var sampleExcelTerm = TestExcelLoader.SampleExcelTerm;
            var providerSettings = TestHelper.CreateProviderSettings();
            var parser = new Parser(providerSettings);
            var transformerService = new EntryTransformerService(parser);

            //act
            var entryLanguages = transformerService
                .CreateEntryLanguages(sampleExcelTerm);

            //assert
            Assert.Equal(entryLanguages.Count, 2);
            Assert.Equal(entryLanguages[0].Locale, sampleExcelTerm.SourceCulture);
            Assert.Equal(entryLanguages[1].Locale, sampleExcelTerm.TargetCulture);
        }
Example #7
0
        public TermsList(List<ExcelEntry> terms,Uri uri):this()
        {
            _terms = terms;
            _uri = uri;

            var persistenceService = new PersistenceService();
            _providerSettings = persistenceService.Load(_uri);
            if (string.IsNullOrEmpty(_providerSettings.ApprovedColumn))
            {
                this.Approved.Visible = false;
            }
            var excelTermLoaderService = new ExcelTermLoaderService(_providerSettings);
            var parser = new Parser(_providerSettings);
            _transformerService = new EntryTransformerService(parser);

            _excelTermProviderService = new ExcelTermProviderService(excelTermLoaderService,
                _transformerService);
        }
        public async Task LoadEntries()
        {
            try
            {
                var parser = new Parser(_providerSettings);
                var transformerService = new EntryTransformerService(parser);
                var excelTermLoader = new ExcelTermLoaderService(_providerSettings);
                var excelTermProviderService = new ExcelTermProviderService(excelTermLoader, transformerService);

                _termEntries = await excelTermProviderService.LoadEntries();
                TelemetryService.Instance.AddMetric("Loaded Terms", _termEntries.Count);
                TermsLoaded?.Invoke(_termEntries);
            }
            catch (Exception ex)
            {
                TelemetryService.Instance.AddException(ex);
                throw;
            }
        }
        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);


        }