Example #1
0
        public void LoadParatextMappings_MarkMappingsInUse()
        {
            if (ScriptureProvider.VersionInUse >= new Version(8, 0))
            {
                Assert.Ignore("This test uses data that is only valid for Paratext7. The test fails with Paratext8 installed.");
            }
            var stylesheet = new LcmStyleSheet();

            stylesheet.Init(Cache, m_scr.Hvo, ScriptureTags.kflidStyles);
            IScrImportSet importSettings = Cache.ServiceLocator.GetInstance <IScrImportSetFactory>().Create();

            Cache.LangProject.TranslatedScriptureOA.ImportSettingsOC.Add(importSettings);
            importSettings.ParatextScrProj = "TEV";
            ScrMappingList mappingList = importSettings.GetMappingListForDomain(ImportDomain.Main);

            Assert.NotNull(mappingList, "Setup Failure, no mapping list returned for the domain.");
            mappingList.Add(new ImportMappingInfo(@"\hahaha", @"\*hahaha", false,
                                                  MappingTargetType.TEStyle, MarkerDomain.Default, "laughing",
                                                  null, null, true, ImportDomain.Main));
            mappingList.Add(new ImportMappingInfo(@"\bthahaha", @"\*bthahaha", false,
                                                  MappingTargetType.TEStyle, MarkerDomain.Default, "laughing",
                                                  "en", null, true, ImportDomain.Main));

            Unpacker.UnPackParatextTestProjects();

            ParatextHelper.LoadProjectMappings(importSettings);

            Assert.IsTrue(mappingList[@"\c"].IsInUse);
            Assert.IsTrue(mappingList[@"\p"].IsInUse);
            Assert.IsFalse(mappingList[@"\ipi"].IsInUse);
            Assert.IsFalse(mappingList[@"\hahaha"].IsInUse,
                           "In-use flag should have been cleared before re-scanning when the P6 project changed.");
            Assert.IsTrue(mappingList[@"\bthahaha"].IsInUse,
                          "In-use flag should not have been cleared before re-scanning when the P6 project changed because it was in use by the BT.");
        }
Example #2
0
        public void LoadParatextMappings_MarkMappingsInUse()
        {
            var stylesheet = new FwStyleSheet();

            stylesheet.Init(Cache, m_scr.Hvo, ScriptureTags.kflidStyles);
            IScrImportSet importSettings = Cache.ServiceLocator.GetInstance <IScrImportSetFactory>().Create();

            importSettings.ParatextScrProj = "TEV";
            ScrMappingList mappingList = importSettings.GetMappingListForDomain(ImportDomain.Main);

            mappingList.Add(new ImportMappingInfo(@"\hahaha", @"\*hahaha", false,
                                                  MappingTargetType.TEStyle, MarkerDomain.Default, "laughing",
                                                  null, null, true, ImportDomain.Main));
            mappingList.Add(new ImportMappingInfo(@"\bthahaha", @"\*bthahaha", false,
                                                  MappingTargetType.TEStyle, MarkerDomain.Default, "laughing",
                                                  "en", null, true, ImportDomain.Main));

            Unpacker.UnPackParatextTestProjects();

            ParatextHelper.LoadProjectMappings(importSettings);

            Assert.IsTrue(mappingList[@"\c"].IsInUse);
            Assert.IsTrue(mappingList[@"\p"].IsInUse);
            Assert.IsFalse(mappingList[@"\ipi"].IsInUse);
            Assert.IsFalse(mappingList[@"\hahaha"].IsInUse,
                           "In-use flag should have been cleared before re-scanning when the P6 project changed.");
            Assert.IsTrue(mappingList[@"\bthahaha"].IsInUse,
                          "In-use flag should not have been cleared before re-scanning when the P6 project changed because it was in use by the BT.");
        }
Example #3
0
        public void LoadParatextMappings_NullProjectName()
        {
            IScrImportSet importSettings = Cache.ServiceLocator.GetInstance <IScrImportSetFactory>().Create();

            ParatextHelper.LoadProjectMappings(importSettings);
            Assert.That(importSettings.ParatextScrProj, Is.Null);
        }
Example #4
0
        public void LoadParatextMappings_Normal()
        {
            if (ScriptureProvider.VersionInUse >= new Version(8, 0))
            {
                Assert.Ignore("This test uses data that is only valid for Paratext7. The test fails with Paratext8 installed.");
            }
            Unpacker.UnPackParatextTestProjects();

            var stylesheet = new LcmStyleSheet();

            stylesheet.Init(Cache, m_scr.Hvo, ScriptureTags.kflidStyles);
            IScrImportSet importSettings = Cache.ServiceLocator.GetInstance <IScrImportSetFactory>().Create();

            Cache.LangProject.TranslatedScriptureOA.ImportSettingsOC.Add(importSettings);
            importSettings.ParatextScrProj = "KAM";
            ParatextHelper.LoadProjectMappings(importSettings);

            ScrMappingList mappingList = importSettings.GetMappingListForDomain(ImportDomain.Main);

            // Test to see that the projects are set correctly
            Assert.AreEqual(44, mappingList.Count);

            Assert.AreEqual(MarkerDomain.Default, mappingList[@"\c"].Domain);
            Assert.AreEqual(MarkerDomain.Default, mappingList[@"\v"].Domain);
            Assert.AreEqual(@"\f*", mappingList[@"\f"].EndMarker);
            Assert.IsTrue(mappingList[@"\p"].IsInUse);
            Assert.IsFalse(mappingList[@"\tb2"].IsInUse);
        }
Example #5
0
        public void GetAssociatedProject()
        {
            m_ptHelper.AddProject("MNKY", "Soup");
            m_ptHelper.AddProject("SOUP", "Monkey Soup");
            m_ptHelper.AddProject("GRK", "Levington");
            m_ptHelper.AddProject("Mony", "Money");
            ScrText found = ParatextHelper.GetAssociatedProject(new TestProjectId(FDOBackendProviderType.kXML, "Monkey Soup"));

            Assert.AreEqual("SOUP", found.Name);
        }
Example #6
0
        public void LoadParatextMappings_MissingStyleFile()
        {
            FwStyleSheet stylesheet = new FwStyleSheet();

            stylesheet.Init(Cache, m_scr.Hvo, ScriptureTags.kflidStyles);
            IScrImportSet importSettings = Cache.ServiceLocator.GetInstance <IScrImportSetFactory>().Create();

            importSettings.ParatextScrProj = "NSF";

            Unpacker.UnPackMissingFileParatextTestProjects();
            ParatextHelper.LoadProjectMappings(importSettings);
            Assert.That(importSettings.ParatextScrProj, Is.Null);
        }
Example #7
0
        public void LoadParatextMappings_MissingEncodingFile()
        {
            var stylesheet = new LcmStyleSheet();

            stylesheet.Init(Cache, m_scr.Hvo, ScriptureTags.kflidStyles);
            IScrImportSet importSettings = Cache.ServiceLocator.GetInstance <IScrImportSetFactory>().Create();

            Cache.LangProject.TranslatedScriptureOA.ImportSettingsOC.Add(importSettings);
            importSettings.ParatextScrProj = "NEC";

            Unpacker.UnPackMissingFileParatextTestProjects();

            ParatextHelper.LoadProjectMappings(importSettings);
            Assert.That(importSettings.ParatextScrProj, Is.Null);
        }
Example #8
0
        public void IsProjectWritable()
        {
            m_ptHelper.AddProject("MNKY");
            m_ptHelper.AddProject("SOUP", "Monkey Soup", null, true, false);
            m_ptHelper.AddProject("TWNS", null, null, false, false);
            m_ptHelper.AddProject("LNDN", null, null, false, true);
            m_ptHelper.AddProject("Mony", null, null, true, true);
            m_ptHelper.AddProject("Grk7");             // Considered a source language text so should be ignored

            Assert.IsTrue(ParatextHelper.IsProjectWritable("MNKY"));
            Assert.IsFalse(ParatextHelper.IsProjectWritable("SOUP"));
            Assert.IsFalse(ParatextHelper.IsProjectWritable("TWNS"));
            Assert.IsFalse(ParatextHelper.IsProjectWritable("LNDN"));
            Assert.IsFalse(ParatextHelper.IsProjectWritable("Mony"));
            Assert.IsFalse(ParatextHelper.IsProjectWritable("Grk7"));
        }
Example #9
0
        public void IsProjectWritable()
        {
            if (ScriptureProvider.VersionInUse >= new Version(8, 0))
            {
                Assert.Ignore("This test is insufficiently mocked and uses Paratext7 data with Paratext8 logic if Paratext8 is installed.");
            }
            m_ptHelper.AddProject("MNKY");
            m_ptHelper.AddProject("SOUP", "Monkey Soup", null, true, false);
            m_ptHelper.AddProject("TWNS", null, null, false, false);
            m_ptHelper.AddProject("LNDN", null, null, false, true);
            m_ptHelper.AddProject("Mony", null, null, true, true);
            m_ptHelper.AddProject("Grk7");             // Considered a source language text so should be ignored

            Assert.IsTrue(ParatextHelper.IsProjectWritable("MNKY"));
            Assert.IsFalse(ParatextHelper.IsProjectWritable("SOUP"));
            Assert.IsFalse(ParatextHelper.IsProjectWritable("TWNS"));
            Assert.IsFalse(ParatextHelper.IsProjectWritable("LNDN"));
            Assert.IsFalse(ParatextHelper.IsProjectWritable("Mony"));
            Assert.IsFalse(ParatextHelper.IsProjectWritable("Grk7"));
        }
Example #10
0
        public void LoadParatextMappings_Normal()
        {
            Unpacker.UnPackParatextTestProjects();

            var stylesheet = new FwStyleSheet();

            stylesheet.Init(Cache, m_scr.Hvo, ScriptureTags.kflidStyles);
            IScrImportSet importSettings = Cache.ServiceLocator.GetInstance <IScrImportSetFactory>().Create();

            importSettings.ParatextScrProj = "KAM";
            ParatextHelper.LoadProjectMappings(importSettings);

            ScrMappingList mappingList = importSettings.GetMappingListForDomain(ImportDomain.Main);

            // Test to see that the projects are set correctly
            Assert.AreEqual(44, mappingList.Count);

            Assert.AreEqual(MarkerDomain.Default, mappingList[@"\c"].Domain);
            Assert.AreEqual(MarkerDomain.Default, mappingList[@"\v"].Domain);
            Assert.AreEqual(@"\f*", mappingList[@"\f"].EndMarker);
            Assert.IsTrue(mappingList[@"\p"].IsInUse);
            Assert.IsFalse(mappingList[@"\tb2"].IsInUse);
        }