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 async void Select_WorkSheet_By_Index()
        {
            var providerSettings = TestHelper.CreateProviderSettings();
            var excelPackage = TestHelper.CreateSampleExcelPackage(providerSettings);

            var excelTerminologyService =
                new ExcelTermLoaderService(providerSettings);

            var worksheet = await excelTerminologyService.GetTerminologyWorksheet(excelPackage);

            Assert.Equal(worksheet.Name, "Glossary");
        }
        public async void Select_WorkSheet_Which_Doesnt_Exists()
        {
            var providerSettings = TestHelper.CreateProviderSettings();
            var excelPackage = TestHelper.CreateSampleExcelPackage(providerSettings);

            providerSettings.WorksheetName = "Worksheet";

            var excelTerminologyService =
                new ExcelTermLoaderService(providerSettings);

            var worksheet = await excelTerminologyService.GetTerminologyWorksheet(excelPackage);

            Assert.Equal(worksheet, null);
        }
Esempio n. 4
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);


        }
        public async void Get_All_Terms_With_Header(int id
            , string expectedSource
            , string expectedTarget
            , string expectedApproved
            , int expectedCount)
        {
            var providerSettings = TestHelper.CreateProviderSettings();
            var excelPackage = TestHelper.CreateSampleExcelPackage(providerSettings);

            var excelTerminologyService =
                new ExcelTermLoaderService(providerSettings);

            var worksheet = await excelTerminologyService.GetTerminologyWorksheet(excelPackage);
            var actual = await excelTerminologyService.GetTermsFromExcel(worksheet);
            Assert.Equal(actual.Count, expectedCount);
            var actualExcelTerm = actual[id];
            Assert.Equal(actualExcelTerm.Source, expectedSource);
            Assert.Equal(actualExcelTerm.SourceCulture.Name,
                providerSettings.SourceLanguage.Name);
            Assert.Equal(actualExcelTerm.Target, expectedTarget);
            Assert.Equal(actualExcelTerm.TargetCulture.Name,
                providerSettings.TargetLanguage.Name);
            Assert.Equal(actualExcelTerm.Approved, expectedApproved);
        }
        public async void Delete_Term(int id)
        {
            var providerSettings = TestHelper
                .CreateProviderSettings();


            var excelTerminologyService =
                new ExcelTermLoaderService(providerSettings);

            await excelTerminologyService.DeleteTerm(id);

            var actualTerms = await excelTerminologyService.LoadTerms();

            Assert.False(actualTerms.ContainsKey(id));

        }
        public async void Add_Or_Update_Term(int id, string expectedSource, string expectedTarget)
        {
            var providerSettings = TestHelper
                .CreateProviderSettings();


            var excelTerminologyService =
                new ExcelTermLoaderService(providerSettings);
            var excelTerm = TestHelper.CreateExcelTerm(expectedSource,
                expectedTarget,
                "Approved",
                providerSettings);

           await excelTerminologyService.AddOrUpdateTerm(id, excelTerm);

            var actualTerms =await excelTerminologyService.LoadTerms();

            Assert.Equal(actualTerms[id].Source, expectedSource);

        }