public void DataMigration7000006Test()
        {
            var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000006Tests.xml");

            // Set up mock MDC.
            var mockMDC = new MockMDCForDataMigration();

            mockMDC.AddClass(1, "CmObject", null, new List <string> {
                "CmProject"
            });
            mockMDC.AddClass(2, "CmProject", "CmObject", new List <string> {
                "LangProject"
            });
            mockMDC.AddClass(3, "LangProject", "CmProject", new List <string>());
            IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000005, dtos, mockMDC, null,
                                                                                TestDirectoryFinder.LcmDirectories);

            m_dataMigrationManager.PerformMigration(dtoRepos, 7000006, new DummyProgressDlg());

            var cmProjDto = dtoRepos.AllInstancesSansSubclasses("LangProject").First();
            var cpElement = XElement.Parse(cmProjDto.Xml);

            Assert.AreEqual(7000006, dtoRepos.CurrentModelVersion, "Wrong updated version.");
            // Get the Description Element in cmProject
            Assert.IsNotNull(cpElement.XPathSelectElement("CmProject/Description"));
            // Get the Name Element in cmProject (should be gone)
            Assert.IsNull(cpElement.XPathSelectElement("CmProject/Name"));
        }
        private void TryThisProject(HashSet <DomainObjectDTO> dtos, MockMDCForDataMigration mockMDC, int numOfPubs)
        {
            IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000040, dtos, mockMDC,
                                                                                @"C:\Path\Not\Used", TestDirectoryFinder.LcmDirectories);

            // Do Migration
            m_dataMigrationManager.PerformMigration(dtoRepos, 7000041, new DummyProgressDlg());

            // Check that the version was updated.
            Assert.AreEqual(7000041, dtoRepos.CurrentModelVersion, "Wrong updated version.");

            // The LexEntry with ExcludeAsHeadword val="True" should be replaced by
            // DoNotShowMainEntryIn with the entire publist as objsur elements.
            VerifyReplace(dtoRepos, "7ecbb299-bf35-4795-a5cc-8d38ce8b891c", true, numOfPubs);

            // The LexEntry with no ExcludeAsHeadword should have no
            // DoNotShowMainEntryIn element.
            VerifyReplace(dtoRepos, "77b2397d-19c9-4321-b581-7a4ccfa9fc0e", false, numOfPubs);

            // The LexEntry with ExcludeAsHeadword val="False" should have no
            // DoNotShowMainEntryIn element.
            VerifyReplace(dtoRepos, "a78bb1d7-a86c-40c5-8ad1-8d75b71c4962", false, numOfPubs);

            // The LexEntry with ExcludeAsHeadword val="garbled" should have no
            // DoNotShowMainEntryIn element.
            VerifyReplace(dtoRepos, "1e4ae08a-2672-4df2-9e2d-980be367e893", false, numOfPubs);
        }
        public void DataMigration7000058Test_SkipNonEmptyGlossAppend()
        {
            var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000058_NonEmptyGlossAppend.xml");
            // Set up mock MDC.
            var mockMdc = new MockMDCForDataMigration();
            IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000057, dtos, mockMdc, null,
                                                                                TestDirectoryFinder.LcmDirectories);

            m_dataMigrationManager.PerformMigration(dtoRepos, 7000058, new DummyProgressDlg());
            Assert.AreEqual(7000058, dtoRepos.CurrentModelVersion, "Wrong updated version.");

            // Skip GlossAppend for Irregularly Inflected Form Type (Plural)
            {
                var iifPlural       = dtoRepos.GetDTO(kguidLexTypPluralVar);
                var iifNewPluralElt = XElement.Parse(iifPlural.Xml);
                Assert.That(iifNewPluralElt.XPathSelectElement("GlossAppend/AUni[@ws='en']").Value,
                            Is.EqualTo(".pL"));
            }

            //  Skip GlossAppend for Irregularly Inflected Form Type (Past)
            {
                var iifPast       = dtoRepos.GetDTO(kguidLexTypPastVar);
                var iifNewPastElt = XElement.Parse(iifPast.Xml);
                Assert.That(iifNewPastElt.XPathSelectElement("GlossAppend/AUni[@ws='en']").Value,
                            Is.EqualTo(".pST"));
            }
        }
        public void DataMigration7000032Test()
        {
            var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000033.xml");

            IFwMetaDataCacheManaged mockMdc = DataMigrationTests7000020.SetupMdc();

            IDomainObjectDTORepository repoDto = new DomainObjectDtoRepository(7000032, dtos, mockMdc,
                                                                               Path.GetTempPath(), TestDirectoryFinder.LcmDirectories);

            var projectFolder = repoDto.ProjectFolder;
            // This is equivalent to DirectoryFinder.GetConfigSettingsDir(projectFolder) at the time of creating
            // the migration, but could conceivably change later.
            var targetDir = Path.Combine(projectFolder, "ConfigurationSettings");

            Directory.CreateDirectory(targetDir);
            var testFilePath = Path.Combine(targetDir, "LexEntry_Layouts.xml");

            using (var writer = new StreamWriter(testFilePath))
            {
                writer.WriteLine(@"<LayoutInventory>" +
                                 "<layout class='LexEntry' type='jtview' name='publishStemPara' css='$fwstyle=Dictionary-Normal' version='9'>" +
                                 " <part ref='Headword' label='Headword' before='' sep=' ' after='  ' ws='vernacular' wsType='vernacular' style='Dictionary-Headword' css='headword' visibility='ifdata' comment='Headword is a smart field. It is the lexeme form unless there is a citation form. Includes Homograph number and affix marking.' />" +
                                 " <part ref='$child' label='testYYY' before='' after=' ' visibility='ifdata' ws='$ws=analysis' wsType='analysis vernacular' sep=' ' showLabels='false'>" +
                                 "   <configureMlString field='custom' class='LexEntry' />" +
                                 " </part>" +
                                 "<part ref='$child' label='TestXXX' before='' after=' ' visibility='ifdata'>" +
                                 " <string field='custom1' class='LexEntry' />" +
                                 "</part>" +
                                 " <part ref='$child' label='messed up' before='' after=' ' visibility='ifdata' ws='$ws=analysis' wsType='analysis vernacular' sep=' ' showLabels='false' originalLabel='testBB'>" +
                                 "   <configureMlString field='custom' class='LexEntry' />" +
                                 " </part>" +
                                 "<part ref='$child' label='modified' before='' after=' ' visibility='ifdata' originalLabel='TestZZZ'>" +
                                 " <string field='custom1' class='LexEntry' />" +
                                 "</part>" +
                                 " <part ref='$child' before='' after=' ' visibility='ifdata' ws='$ws=analysis' wsType='analysis vernacular' sep=' ' showLabels='false' originalLabel='testCC'>" +
                                 "   <configureMlString field='custom' class='LexEntry' />" +
                                 " </part>" +
                                 "<part ref='$child' before='' after=' ' visibility='ifdata' originalLabel='TestD'>" +
                                 " <string field='custom1' class='LexEntry' />" +
                                 "</part>" +
                                 "</layout>" +
                                 "</LayoutInventory>");
                writer.Close();
            }

            // Do the migration.
            m_dataMigrationManager.PerformMigration(repoDto, 7000033, new DummyProgressDlg());

            Assert.AreEqual(7000033, repoDto.CurrentModelVersion, "Wrong updated version.");
            var root     = XElement.Load(testFilePath);         // layout inventory node
            var layout   = root.Elements().ToList()[0];
            var children = layout.Elements().ToList();

            VerifyChild(children[1], "testYYY");
            VerifyChild(children[2], "TestXXX");
            VerifyChild(children[3], "testBB");
            VerifyChild(children[4], "TestZZZ");
            VerifyChild(children[5], "testCC");
            VerifyChild(children[6], "TestD");
        }
Example #5
0
        public void DataMigration7000060Test()
        {
            var projectFolder  = Path.GetTempPath();
            var settingsFolder = Path.Combine(projectFolder, LcmFileHelper.ksConfigurationSettingsDir);
            var sampleLayout   = Path.Combine(settingsFolder, "Test_Layouts.xml");
            var otherFile      = Path.Combine(settingsFolder, "other.xml");
            var newLayoutPath  = Path.Combine(settingsFolder, "Test.fwlayout");

            // Delete any leftover data from incomplete test (or previous test).
            if (Directory.Exists(settingsFolder))
            {
                Directory.Delete(settingsFolder, true);
            }

            Directory.CreateDirectory(settingsFolder);
            File.WriteAllText(sampleLayout, "nonsence", Encoding.UTF8);
            File.WriteAllText(otherFile, "rubbish", Encoding.UTF8);

            var mockMDC = new MockMDCForDataMigration();           // no classes to migrate here
            var dtos    = new HashSet <DomainObjectDTO>();         // no objects to migrate
            IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000059, dtos, mockMDC, projectFolder,
                                                                                TestDirectoryFinder.LcmDirectories);

            // Do the migration.
            m_dataMigrationManager.PerformMigration(dtoRepos, 7000060, new DummyProgressDlg());

            Assert.That(File.Exists(newLayoutPath));
            Assert.That(File.Exists(otherFile));
            Assert.That(!File.Exists(sampleLayout));
            Directory.Delete(settingsFolder, true);

            Assert.AreEqual(7000060, dtoRepos.CurrentModelVersion, "Wrong updated version.");
        }
Example #6
0
        public void BadListDisplayOptionAndChoiceOptionAreFixed()
        {
            var mockMdc = new MockMDCForDataMigration();

            mockMdc.AddClass(1, "CmObject", null, new List <string> {
                "CmPossibilityList", "LanguageProject", "CmCustomItem", "LexDb", "LexEntryRef"
            });
            mockMdc.AddClass(2, "CmPossibilityList", "CmObject", new List <string>());
            mockMdc.AddClass(3, "CmCustomItem", "CmObject", new List <string>());
            mockMdc.AddClass(4, "LanguageProject", "CmObject", new List <string>());
            mockMdc.AddClass(5, "LexDb", "CmObject", new List <string>());
            mockMdc.AddClass(6, "LexEntryRef", "CmObject", new List <string>());

            var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000070_DoubledList.xml");
            IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000069, dtos, mockMdc, null,
                                                                                TestDirectoryFinder.LcmDirectories);

            const string badEnumValue = "-1073741824";

            Assert.True(dtoRepos.AllInstancesWithSubclasses("CmPossibilityList").Any(dto => dto.Xml.Contains("PreventChoiceAboveLevel val=\"" + badEnumValue + "\"")),
                        "The CmPossibilityList test data has changed");
            Assert.True(dtoRepos.AllInstancesWithSubclasses("CmPossibilityList").Any(dto => dto.Xml.Contains("DisplayOption val=\"" + badEnumValue + "\"")),
                        "The CmPossibilityList test data has changed");

            m_dataMigrationManager.PerformMigration(dtoRepos, 7000070, new DummyProgressDlg());             // SUT

            var resultingLists = dtoRepos.AllInstancesWithSubclasses("CmPossibilityList").ToList();

            Assert.False(dtoRepos.AllInstancesWithSubclasses("CmPossibilityList").Any(dto => dto.Xml.Contains(badEnumValue)), "Bad list data was not removed.");
            Assert.AreEqual(2, resultingLists.Count(dto => dto.Xml.Contains("PreventChoiceAboveLevel val=\"0\"")), "PreventChoiceAbove should have changed to 0");
            Assert.AreEqual(2, resultingLists.Count(dto => dto.Xml.Contains("DisplayOption val=\"0\"")), "DisplayOption should have changed to 0");
        }
Example #7
0
        public void DataMigration7000063Test()
        {
            var mockMdc = new MockMDCForDataMigration();

            mockMdc.AddClass(1, "CmObject", null, new List <string> {
                "LangProject"
            });
            mockMdc.AddClass(2, "LangProject", "CmObject", new List <string>());

            var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000063.xml");
            IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000062, dtos, mockMdc, null,
                                                                                TestDirectoryFinder.LcmDirectories);

            m_dataMigrationManager.PerformMigration(dtoRepos, 7000063, new DummyProgressDlg());

            var wmbLangProjList = dtoRepos.AllInstancesSansSubclasses("LangProject");
            var wmbLangProj     = wmbLangProjList.First();
            var wmbLangProjElt  = XElement.Parse(wmbLangProj.Xml);
            // the homograph ws should have been added
            var homographWs = wmbLangProjElt.Element("HomographWs");             // has to be only one

            Assert.IsNotNull(homographWs, "Migration 7000063 failed to add HomographWs element to LangProject class");
            var homographWsUni = homographWs.Element("Uni");             // only one

            Assert.IsNotNull(homographWs, "Migration 7000063 failed to add HomographWs/Uni element to LangProject class");
            var homographWsTag = homographWsUni.Value;             // only one

            Assert.AreEqual("fa", homographWsUni.Value, "HomographWs value in LangProject class is incorrect");

            Assert.AreEqual(7000063, dtoRepos.CurrentModelVersion, "Wrong updated version.");
        }
Example #8
0
        public void DeleteWeatherListAndField()
        {
            var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000017.xml");

            var mockMdc = SetupMdc();

            IDomainObjectDTORepository repoDTO = new DomainObjectDtoRepository(7000016, dtos, mockMdc, null,
                                                                               TestDirectoryFinder.LcmDirectories);

            // SUT: Do the migration.
            m_dataMigrationManager.PerformMigration(repoDTO, 7000017, new DummyProgressDlg());

            // Verification Phase
            Assert.AreEqual(7000017, repoDTO.CurrentModelVersion, "Wrong updated version.");

            DomainObjectDTO dtoLP = null;

            foreach (DomainObjectDTO dto in repoDTO.AllInstancesSansSubclasses("LangProject"))
            {
                Assert.IsNull(dtoLP, "Only one LangProject object should exist");
                dtoLP = dto;
            }
            Assert.NotNull(dtoLP, "The LangProject object should exist");
            string sXml = dtoLP.Xml;

            Assert.IsFalse(sXml.Contains("<WeatherConditions>"), "The <WeatherConditions> element should have disappeared");
            string sLpOwnerGuid = GetGuidAsOwnerGuid(sXml);

            DomainObjectDTO dtoNbk = null;

            foreach (DomainObjectDTO dto in repoDTO.AllInstancesSansSubclasses("RnResearchNbk"))
            {
                Assert.IsNull(dtoNbk, "Only one RnResearchNbk should exist");
                Assert.IsTrue(dto.Xml.Contains(sLpOwnerGuid), "The RnResearchNbk should be owned by the LangProject");
                dtoNbk = dto;
            }
            Assert.NotNull(dtoNbk, "The RnResearchNbk should exist");
            string sNbkOwnerGuid = GetGuidAsOwnerGuid(dtoNbk.Xml);
            int    cList         = 0;

            foreach (DomainObjectDTO dto in repoDTO.AllInstancesSansSubclasses("CmPossibilityList"))
            {
                sXml = dto.Xml;
                Assert.IsTrue(sXml.Contains(sNbkOwnerGuid), "Possibility List must be owned by Data Notebook");
                ++cList;
            }
            Assert.AreEqual(1, cList, "Only one CmPossibilityList should exist");

            foreach (DomainObjectDTO dto in repoDTO.AllInstancesWithSubclasses("RnGenericRec"))
            {
                Assert.IsFalse(dto.Xml.Contains("<Weather"), "Any <Weather> element should have disappeared");
                Assert.IsFalse(dto.Xml.Contains("<Custom name="), "No <Custom> element should have been created");
            }

            // This test file has three overlays; the first refers to a weather item and the weather possibility list,
            // and should be delted. The second refers to a non-weather possibility, and the third to a non-weather
            // possibility list; they should survive.
            Assert.That(repoDTO.AllInstancesSansSubclasses("CmOverlay"), Has.Count.EqualTo(2));
        }
        public void DataMigration7000016Test()
        {
            var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000016.xml");

            var mockMdc = SetupMdc();

            IDomainObjectDTORepository repoDTO = new DomainObjectDtoRepository(7000015, dtos, mockMdc, null,
                                                                               TestDirectoryFinder.LcmDirectories);

            // SUT: Do the migration.
            m_dataMigrationManager.PerformMigration(repoDTO, 7000016, new DummyProgressDlg());

            // Verification Phase
            Assert.AreEqual(7000016, repoDTO.CurrentModelVersion, "Wrong updated version.");

            DomainObjectDTO nbkDto = null;

            foreach (DomainObjectDTO dot in repoDTO.AllInstancesSansSubclasses("RnResearchNbk"))
            {
                nbkDto = dot;
                break;
            }
            Assert.NotNull(nbkDto);
            XElement nbkElem      = XElement.Parse(nbkDto.Xml);
            var      recTypesGuid = (string)nbkElem.XPathSelectElement("RecTypes/objsur").Attribute("guid");

            Assert.AreEqual(recTypesGuid.ToLowerInvariant(), ksguidRecTypesList);

            // All we can guarantee being able to check are those items that we create, and to a
            // limited degree, those items that are moved to belong to a created item.
            bool fFoundEvent   = false;
            bool fFoundMethod  = false;
            bool fFoundWeather = false;

            foreach (DomainObjectDTO dto in repoDTO.GetDirectlyOwnedDTOs(ksguidRecTypesList))
            {
                string sguid = dto.Guid.ToLowerInvariant();
                Assert.AreNotEqual(sguid, ksguidObservation);
                Assert.AreNotEqual(sguid, ksguidConversation);
                Assert.AreNotEqual(sguid, ksguidInterview);
                Assert.AreNotEqual(sguid, ksguidPerformance);
                if (sguid == ksguidEvent)
                {
                    fFoundEvent = true;
                    CheckEventSubTypes(repoDTO);
                }
                else if (sguid == ksguidMethodology)
                {
                    fFoundMethod = true;
                }
                else if (sguid == ksguidWeather)
                {
                    fFoundWeather = true;
                }
            }
            Assert.IsTrue(fFoundEvent);
            Assert.IsTrue(fFoundMethod);
            Assert.IsTrue(fFoundWeather);
        }
        public void DowngradeMigrationTest()
        {
            var mockMDC = new MockMDCForDataMigration();
            IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7100000,
                                                                                new HashSet <DomainObjectDTO>(), mockMDC, null, TestDirectoryFinder.LcmDirectories);

            m_dataMigrationManager.PerformMigration(dtoRepos, 7000000, null);
        }
        public void DowngradeMigrationTest()
        {
            var mockMDC = new MockMDCForDataMigration();
            IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7100000,
                                                                                new HashSet <DomainObjectDTO>(), mockMDC, null, TestDirectoryFinder.LcmDirectories);

            Assert.That(() => m_dataMigrationManager.PerformMigration(dtoRepos, 7000000, null),
                        Throws.TypeOf <DataMigrationException>());
        }
        public void DataMigration7000014Test()
        {
            var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000014_Evaluations.xml");

            var mockMDC = SetupMDC();

            IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000013, dtos, mockMDC, null,
                                                                                TestDirectoryFinder.LcmDirectories);

            // SUT; Do the migration.
            m_dataMigrationManager.PerformMigration(dtoRepos, 7000014, new DummyProgressDlg());

            // Verification Phase
            Assert.AreEqual(7000014, dtoRepos.CurrentModelVersion, "Wrong updated version.");

            //
            var firstAgent     = dtoRepos.GetDTO("c1ec8357-e382-11de-8a39-0800200c9a66");
            var secondAgent    = dtoRepos.GetDTO("c1ec8357-e382-11de-8a39-0800200c9a67");
            var thirdAgent     = dtoRepos.GetDTO("c1ec8357-e382-11de-8a39-0800200c9a68");
            var emptyAgent     = dtoRepos.GetDTO("c1ec8357-e382-11de-8a39-0800200c9a6c");
            var firstAnalysis  = dtoRepos.GetDTO("c84614e6-168b-4304-a025-0d6ae6573086");
            var secondAnalysis = dtoRepos.GetDTO("c84614e6-168b-4304-a025-0d6ae6573087");

            string firstApprovesGuid,
                   firstDisapprovesGuid,
                   secondApprovesGuid,
                   secondDisapprovesGuid,
                   thirdApprovesGuid,
                   thirdDisapprovesGuid,
                   emptyApprovesGuid,
                   emptyDisapprovesGuid;

            VerifyAgent(firstAgent, dtoRepos, out firstApprovesGuid, out firstDisapprovesGuid);
            VerifyAgent(secondAgent, dtoRepos, out secondApprovesGuid, out secondDisapprovesGuid);
            VerifyAgent(thirdAgent, dtoRepos, out thirdApprovesGuid, out thirdDisapprovesGuid);
            VerifyAgent(emptyAgent, dtoRepos, out emptyApprovesGuid, out emptyDisapprovesGuid);

            VerifyAnalysis(firstAnalysis, new string[] { firstApprovesGuid, secondDisapprovesGuid, thirdApprovesGuid });
            VerifyAnalysis(secondAnalysis, new string[] { firstApprovesGuid });

            var goners = ((DomainObjectDtoRepository)dtoRepos).Goners;

            Assert.AreEqual(4, goners.Count, "Wrong number removed.");
            var gonerGuids = new List <string>
            {
                ("c84614e6-168b-4304-a025-0d6ae6573085").ToLower(),
                ("c84614e6-168b-4304-a025-0d6ae6573088").ToLower(),
                ("8151a002-a32e-476f-9c32-f95ee48fc71c").ToLower(),
                ("c84614e6-168b-4304-a025-0d6ae657308a").ToLower()
            };

            foreach (var goner in goners)
            {
                Assert.Contains(goner.Guid.ToLower(), gonerGuids, "Goner guid not found.");
            }
        }
Example #13
0
        public void NonExistantGuidTest()
        {
            IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(
                1,
                new HashSet <DomainObjectDTO>(),
                m_mdc,
                null, TestDirectoryFinder.LcmDirectories);

            dtoRepos.GetDTO(Guid.NewGuid().ToString());
        }
Example #14
0
        public void DataMigration7000037Test()
        {
            // Bring in data from xml file.
            var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000037.xml");

            // Create all the Mock classes for the classes in my test data.
            var mockMDC = new MockMDCForDataMigration();

            mockMDC.AddClass(1, "CmObject", null, new List <string> {
                "LexSense", "StPara"
            });
            mockMDC.AddClass(7, "LexSense", "CmObject", new List <string>());
            mockMDC.AddClass(15, "StPara", "CmObject", new List <string> {
                "StTxtPara"
            });
            mockMDC.AddClass(16, "StTxtPara", "StPara", new List <string>());

            IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000036, dtos, mockMDC,
                                                                                FileUtils.ChangePathToPlatform("C:\\WW\\DistFiles\\Projects\\TokPisin"), TestDirectoryFinder.LcmDirectories);

            // Check that the version is correct.
            Assert.AreEqual(7000036, dtoRepos.CurrentModelVersion, "Wrong original version.");
            // Collect the link values that shouldn't change.
            m_cLinks = 0;
            CollectionNonSilfwLinks(dtoRepos);
            int cLinksOrig = m_cLinks;

            Assert.AreEqual(12, m_cLinks, "Should have 12 externalLink attributes in the test data");

            // Do Migration
            m_dataMigrationManager.PerformMigration(dtoRepos, 7000037, new DummyProgressDlg());

            // Check that the version was updated.
            Assert.AreEqual(7000037, dtoRepos.CurrentModelVersion, "Wrong updated version.");

            // Check that all externalLink values are reasonable, and that we find the right
            // number of them.
            m_cLinks = 0;
            foreach (var dto in dtoRepos.AllInstancesWithValidClasses())
            {
                string xml = dto.Xml;
                Assert.IsTrue(xml.Contains("externalLink"), "Every object in the test has an externalLink");
                var dtoXML = XElement.Parse(xml);
                foreach (var run in dtoXML.XPathSelectElements("//Run"))
                {
                    var externalLinkAttr = run.Attribute("externalLink");
                    if (externalLinkAttr != null)
                    {
                        CheckForValidLinkValue(externalLinkAttr.Value);
                        ++m_cLinks;
                    }
                }
            }
            Assert.AreEqual(cLinksOrig, m_cLinks, "Migration should not change the number of externalLink attributes");
        }
        public void PerformMigration7000018()
        {
            var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000018.xml");

            var mockMdc = SetupMdc();

            IDomainObjectDTORepository repoDTO = new DomainObjectDtoRepository(7000017, dtos, mockMdc, null,
                                                                               TestDirectoryFinder.LcmDirectories);

            // SUT: Do the migration.
            m_dataMigrationManager.PerformMigration(repoDTO, 7000018, new DummyProgressDlg());

            // Verification Phase
            Assert.AreEqual(7000018, repoDTO.CurrentModelVersion, "Wrong updated version.");

            DomainObjectDTO dtoLP = null;

            foreach (DomainObjectDTO dto in repoDTO.AllInstancesSansSubclasses("LangProject"))
            {
                Assert.IsNull(dtoLP, "Only one Language Project object should exist");
                dtoLP = dto;
            }
            Assert.NotNull(dtoLP, "The Language Project object should exist");

            DomainObjectDTO dtoNtbk = null;

            foreach (DomainObjectDTO dto in repoDTO.AllInstancesSansSubclasses("RnResearchNbk"))
            {
                Assert.IsNull(dtoNtbk, "Only one Data Notebook object should exist");
                dtoNtbk = dto;
            }
            Assert.NotNull(dtoNtbk, "The Data Notebook object should exist");

            DomainObjectDTO dtoLexDb = null;

            foreach (DomainObjectDTO dto in repoDTO.AllInstancesSansSubclasses("LexDb"))
            {
                Assert.IsNull(dtoLexDb, "Only one Lexical Database object should exist");
                dtoLexDb = dto;
            }
            Assert.NotNull(dtoLexDb, "The Lexical Database object should exist");

            string sLexDbXml = dtoLexDb.Xml;

            Assert.False(sLexDbXml.Contains("<Styles>"), "The Styles field should be gone from the Lexical Database object");

            string sLpXml = dtoLP.Xml;

            Assert.True(sLpXml.Contains("<Styles>"), "The Styles field should still exist in the Language Project object");

            VerifyStylesRenamedOrDeleted(repoDTO);
            VerifyStyleReferencesUpdated(repoDTO);
            VerifyScriptureStylesUnchanged(repoDTO);
            VerifyNoDirectFormatting(repoDTO);
        }
Example #16
0
        public void DataMigration7000051Test()
        {
            var dtos = new HashSet <DomainObjectDTO>();
            var sb   = new StringBuilder();
            // Add Lang Project dto.
            const string sLpGuid    = "9719A466-2240-4DEA-9722-9FE0746A30A6";
            const string afxCatGuid = "60ab6c6c-43f3-4a7f-af61-96b4b77648a5";

            sb.AppendFormat("<rt class=\"LangProject\" guid=\"{0}\">", sLpGuid);
            sb.Append("<AffixCategories>");
            sb.AppendFormat("<objsur guid=\"{0}\" t=\"o\" />", afxCatGuid);
            sb.Append("</AffixCategories>");
            sb.Append("</rt>");
            var oldDto = new DomainObjectDTO(sLpGuid, "LangProject", sb.ToString());

            dtos.Add(oldDto);
            sb.Length = 0;

            sb.AppendFormat("<rt class=\"CmPossibilityList\" guid=\"{0}\"  ownerguid=\"{1}\" />", afxCatGuid, sLpGuid);
            var afxCatDto = new DomainObjectDTO(afxCatGuid, "CmPossibilityList", sb.ToString());

            dtos.Add(afxCatDto);

            // Set up mock MDC.
            var mockMDC = new MockMDCForDataMigration();

            mockMDC.AddClass(1, "CmObject", null, new List <string> {
                "LangProject", "CmPossibilityList"
            });                                                                                                         // Not true, but no matter.
            mockMDC.AddClass(2, "LangProject", "CmObject", new List <string>());
            mockMDC.AddClass(3, "CmPossibilityList", "CmObject", new List <string>());
            IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000050, dtos, mockMDC, null,
                                                                                TestDirectoryFinder.LcmDirectories);

            m_dataMigrationManager.PerformMigration(dtoRepos, 7000051, new DummyProgressDlg());
            Assert.AreEqual(7000051, dtoRepos.CurrentModelVersion, "Wrong updated version.");

            // Check that the old LP is not present.
            DomainObjectDTO gonerDto;

            Assert.IsFalse(dtoRepos.TryGetValue(sLpGuid, out gonerDto));
            Assert.IsTrue(((DomainObjectDtoRepository)dtoRepos).Goners.Contains(oldDto));
            var newDto = dtoRepos.AllInstancesSansSubclasses("LangProject").FirstOrDefault();

            Assert.IsNotNull(newDto);
            Assert.AreNotSame(oldDto, newDto);
            var newDtoGuid = newDto.Guid.ToLowerInvariant();

            Assert.AreNotEqual(sLpGuid.ToLowerInvariant(), newDtoGuid);

            // Check that ownerguid was changed on afxCatDto.
            var afxCatElm = XElement.Parse(afxCatDto.Xml);

            Assert.AreEqual(newDtoGuid, afxCatElm.Attribute("ownerguid").Value.ToLowerInvariant());
        }
Example #17
0
        public void AllRegularBasicDataPropertiesExistAfterDataMigration66()
        {
            var mockMdc = new MockMDCForDataMigration();

            mockMdc.AddClass(1, "CmObject", null, new List <string> {
                "RegularPropertyMagnet"
            });
            mockMdc.AddClass(2, "RegularPropertyMagnet", "CmObject", new List <string>());

            // These are all present in the original data file and act as controls.
            // They should not be changed.
            var currentFlid = 2000;

            mockMdc.AddField(++currentFlid, "ExtantOwningAtomic", CellarPropertyType.OwningAtom, 2);
            mockMdc.AddField(++currentFlid, "ExtantBooleanProperty", CellarPropertyType.Boolean, 0);
            mockMdc.AddField(++currentFlid, "ExtantGenDateProperty", CellarPropertyType.GenDate, 0);
            mockMdc.AddField(++currentFlid, "ExtantGuidProperty", CellarPropertyType.Guid, 0);
            // Not used in model yet (as of 23 march 2013) mockMdc.AddField(++currentFlid, "ExtantFloatProperty", CellarPropertyType.Float, 0);
            mockMdc.AddField(++currentFlid, "ExtantIntegerProperty", CellarPropertyType.Integer, 0);
            // Not used in model yet (as of 23 march 2013) var mockMdc.AddField(++currentFlid, "ExtantNumericProperty", CellarPropertyType.Numeric, 0);
            mockMdc.AddField(++currentFlid, "ExtantTimeProperty", CellarPropertyType.Time, 0);

            // These are all missing in the original data file.
            // They should all end up with the default values for the given type of data.
            mockMdc.AddField(++currentFlid, "NewBooleanProperty", CellarPropertyType.Boolean, 0);
            mockMdc.AddField(++currentFlid, "NewGenDateProperty", CellarPropertyType.GenDate, 0);
            mockMdc.AddField(++currentFlid, "NewGuidProperty", CellarPropertyType.Guid, 0);
            // Not used in model yet (as of 23 march 2013) mockMdc.AddField(++currentFlid, "NewFloatProperty", CellarPropertyType.Float, 0);
            mockMdc.AddField(++currentFlid, "NewIntegerProperty", CellarPropertyType.Integer, 0);
            // Not used in model yet (as of 23 march 2013) mockMdc.AddField(++currentFlid, "NewNumericProperty", CellarPropertyType.Numeric, 0);
            mockMdc.AddField(++currentFlid, "NewTimeProperty", CellarPropertyType.Time, 0);

            var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000066_RegularPropertyMagnet.xml");
            IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000065, dtos, mockMdc, null,
                                                                                TestDirectoryFinder.LcmDirectories);

            m_dataMigrationManager.PerformMigration(dtoRepos, 7000066, new DummyProgressDlg());

            var magnet = XElement.Parse(dtoRepos.AllInstancesSansSubclasses("RegularPropertyMagnet").First().Xml);

            // Check the 'control' props to make sure they were not changed.
            Assert.AreEqual("e268fe80-5d9d-4f6b-a68f-37db8218b15d", magnet.Element("ExtantOwningAtomic").Element("objsur").Attribute("guid").Value);
            Assert.AreEqual("True", GetRegularPropertyValue(magnet, "ExtantBooleanProperty"));
            Assert.AreEqual("-201303233", GetRegularPropertyValue(magnet, "ExtantGenDateProperty"));
            Assert.AreEqual("c1ee311b-e382-11de-8a39-0800200c9a66", GetRegularPropertyValue(magnet, "ExtantGuidProperty"));
            Assert.AreEqual("1", GetRegularPropertyValue(magnet, "ExtantIntegerProperty"));
            Assert.AreEqual("2006-3-12 18:19:46.87", GetRegularPropertyValue(magnet, "ExtantTimeProperty"));

            // Check the newly added props to make sure they are present and using default values.
            Assert.AreEqual("False", GetRegularPropertyValue(magnet, "NewBooleanProperty"));
            Assert.AreEqual("-000000000", GetRegularPropertyValue(magnet, "NewGenDateProperty"));
            Assert.AreEqual(Guid.Empty.ToString(), GetRegularPropertyValue(magnet, "NewGuidProperty"));
            Assert.AreEqual("0", GetRegularPropertyValue(magnet, "NewIntegerProperty"));
            Assert.IsNotNull(GetRegularPropertyValue(magnet, "NewTimeProperty"));
        }
        public void ExtantGuidFindsDTOTest()
        {
            var dtos = new HashSet <DomainObjectDTO>();
            // 1. Add barebones LP.
            const string lpGuid = "9719A466-2240-4DEA-9722-9FE0746A30A6";
            var          lpDto  = CreatoDTO(dtos, lpGuid, "LangProject", null);
            IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(1, dtos, m_mdc, null, TestDirectoryFinder.LcmDirectories);
            var resultDto = dtoRepos.GetDTO(lpGuid);

            Assert.AreSame(lpDto, resultDto, "Wrong DTO.");
        }
        public void NonExistantGuidTest()
        {
            IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(
                1,
                new HashSet <DomainObjectDTO>(),
                m_mdc,
                null, TestDirectoryFinder.LcmDirectories);

            Assert.That(() => dtoRepos.GetDTO(Guid.NewGuid().ToString()),
                        Throws.TypeOf <ArgumentException>());
        }
        public void UpdateDtoTest()
        {
            var dtos = new HashSet <DomainObjectDTO>();
            // 1. Add barebones LP.
            const string lpGuid = "9719A466-2240-4DEA-9722-9FE0746A30A6";
            var          lpDto  = CreatoDTO(dtos, lpGuid, "LangProject", null);
            IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(1, dtos, m_mdc, null, TestDirectoryFinder.LcmDirectories);

            dtoRepos.Update(lpDto);
            Assert.IsTrue(((DomainObjectDtoRepository)dtoRepos).Dirtballs.Contains(lpDto), "Dirty DTO not in dirtball set.");
        }
Example #21
0
        public void DataMigration7000062Test()
        {
            var mockMdc = new MockMDCForDataMigration();

            mockMdc.AddClass(1, "CmObject", null, new List <string> {
                "LangProject", "StStyle", "CmResource"
            });
            mockMdc.AddClass(2, "LangProject", "CmObject", new List <string>());
            mockMdc.AddClass(3, "StStyle", "CmObject", new List <string>());
            mockMdc.AddClass(4, "CmResource", "CmObject", new List <string>());

            var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000062.xml");
            IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000061, dtos, mockMdc, null,
                                                                                TestDirectoryFinder.LcmDirectories);

            m_dataMigrationManager.PerformMigration(dtoRepos, 7000062, new DummyProgressDlg());

            // Check Step 1.A.
            // <rt class="StStyle" guid ="bb68f6bc-f233-4cd4-8894-c33b4b4c43ba">
            DomainObjectDTO dto;

            dtoRepos.TryGetValue("bb68f6bc-f233-4cd4-8894-c33b4b4c43ba", out dto);
            Assert.IsNull(dto);
            // Step 1.A. Control
            // <rt class="StStyle" guid ="9d28219c-6185-416e-828b-b9e304de141c" ownerguid="88ddebd1-dfad-4033-8b1c-896081469f66">
            dtoRepos.TryGetValue("9d28219c-6185-416e-828b-b9e304de141c", out dto);
            Assert.IsNotNull(dto);

            // Check Step 1.B. (Real + control)
            foreach (var resourceDto in dtoRepos.AllInstancesSansSubclasses("CmResource"))
            {
                var resourceElement = XElement.Parse(resourceDto.Xml);
                var name            = resourceElement.Element("Name").Element("Uni").Value;
                var actualVersion   = resourceElement.Element("Version").Attribute("val").Value;
                var expectedVersion = "";
                switch (name)
                {
                case "TeStyles":
                    expectedVersion = "700176e1-4f42-4abd-8fb5-3c586670085d";
                    break;

                case "FlexStyles":
                    expectedVersion = "13c213b9-e409-41fc-8782-7ca0ee983b2c";
                    break;

                case "ControlResource":
                    expectedVersion = "c1ede2e2-e382-11de-8a39-0800200c9a66";
                    break;
                }
                Assert.AreEqual(expectedVersion, actualVersion);
            }

            Assert.AreEqual(7000062, dtoRepos.CurrentModelVersion, "Wrong updated version.");
        }
        public void DataMigration7000056Test()
        {
            var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000056.xml");
            // Set up mock MDC.
            var mockMDC = new MockMDCForDataMigration();
            IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000055, dtos, mockMDC, null,
                                                                                TestDirectoryFinder.LcmDirectories);

            m_dataMigrationManager.PerformMigration(dtoRepos, 7000056, new DummyProgressDlg());
            Assert.AreEqual(7000056, dtoRepos.CurrentModelVersion, "Wrong updated version.");

            // check that PhPhonData has the PhonRuleFeats possibility list
            {
                var             dtosList          = dtoRepos.AllInstancesSansSubclasses("PhPhonData");
                DomainObjectDTO dtoPhPhonDataTest = dtosList.First();
                CheckPhPhonData(dtoPhPhonDataTest, dtoRepos);
            }

            // In the extremely unlikely event that there is no PhPhonData yet, check that we add it
            {
                dtos = new HashSet <DomainObjectDTO>();

                var sb = new StringBuilder();
                // Add WfiMorphBundle that already has a form.
                const string sGuid_wmbLangProj = "00b35f9f-86ce-4f07-bde7-b65c28503641";

                sb.AppendFormat("<rt class=\"LangProj\" guid=\"{0}\">", sGuid_wmbLangProj);
                sb.Append("</rt>");
                var dtoLangProj = new DomainObjectDTO(sGuid_wmbLangProj, "LangProj", sb.ToString());
                dtos.Add(dtoLangProj);
                sb.Length = 0;

                mockMDC  = new MockMDCForDataMigration();
                dtoRepos = new DomainObjectDtoRepository(7000055, dtos, mockMDC, null, TestDirectoryFinder.LcmDirectories);
                m_dataMigrationManager.PerformMigration(dtoRepos, 7000056, new DummyProgressDlg());
                Assert.AreEqual(7000056, dtoRepos.CurrentModelVersion, "Wrong updated version.");

                var             dtosList           = dtoRepos.AllInstancesSansSubclasses("LangProj");
                DomainObjectDTO dtoLangProjTest    = dtosList.First();
                var             eltWmbLangProjTest = XElement.Parse(dtoLangProjTest.Xml);
                // get phon rule feats
                var eltPhonologicalDataTest = eltWmbLangProjTest.Element("PhonologicalData");
                Assert.IsNotNull(eltPhonologicalDataTest);
                var eltObjsurTest = eltPhonologicalDataTest.Element("objsur");
                Assert.IsNotNull(eltObjsurTest);
                // get possibility list itself
                var guidPhPhonDataTest = eltObjsurTest.Attribute("guid").Value;
                Assert.IsNotNull(guidPhPhonDataTest);
                DomainObjectDTO dtoPhPhonDataTest;
                dtoRepos.TryGetValue(guidPhPhonDataTest, out dtoPhPhonDataTest);
                Assert.IsNotNull(dtoPhPhonDataTest);
                CheckPhPhonData(dtoPhPhonDataTest, dtoRepos);
            }
        }
Example #23
0
        public void DataMigration7000007Test()
        {
            var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000007Tests.xml");

            // Set up mock MDC.
            var mockMDC = new MockMDCForDataMigration();

            mockMDC.AddClass(1, "CmObject", null, new List <string> {
                "ScrImportSet", "StPara", "StText"
            });
            mockMDC.AddClass(2, "ScrImportSet", "CmObject", new List <string>());
            mockMDC.AddClass(4, "StPara", "CmObject", new List <string> {
                "StTxtPara"
            });
            mockMDC.AddClass(6, "StText", "CmObject", new List <string> {
                "StFootnote"
            });
            mockMDC.AddClass(7, "StTxtPara", "StPara", new List <string>());
            mockMDC.AddClass(9, "StFootnote", "StText", new List <string> {
                "ScrFootnote"
            });
            mockMDC.AddClass(10, "ScrFootnote", "StFootnote", new List <string>());
            IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000006, dtos, mockMDC, null,
                                                                                TestDirectoryFinder.LcmDirectories);

            m_dataMigrationManager.PerformMigration(dtoRepos, 7000007, new DummyProgressDlg());

            var ScrInpDto     = dtoRepos.AllInstancesSansSubclasses("ScrImportSet").First();
            var ScrInpElement = XElement.Parse(ScrInpDto.Xml);

            Assert.AreEqual(7000007, dtoRepos.CurrentModelVersion, "Wrong updated version.");

            Assert.IsNull(ScrInpElement.XPathSelectElement("ScrImportSet/ImportSettings"));
            // Get the ImportSettings Element in ScrImportSet (should be gone)
            Assert.IsNotNull(ScrInpElement.XPathSelectElement("ScrImportSet/ImportType"));
            // Get the ImportType Element in ScrImportSet.

            var ScrFootDto     = dtoRepos.AllInstancesSansSubclasses("ScrFootnote").First();
            var ScrFootElement = XElement.Parse(ScrFootDto.Xml);

            Assert.IsNull(ScrFootElement.XPathSelectElement("StFootnote/DisplayFootnoteReference"));
            // Get the DisplayFootnoteReference Element in StFootnote (should be gone)
            Assert.IsNull(ScrFootElement.XPathSelectElement("StFootnote/DisplayFootnoteMarker"));
            // Get the DisplayFootnoteMarker Element in StFootnote (should be gone)

            var StTxtDto     = dtoRepos.AllInstancesSansSubclasses("StTxtPara").First();
            var StTxtElement = XElement.Parse(StTxtDto.Xml);

            Assert.IsNotNull(StTxtElement.XPathSelectElement("StPara/StyleRules"));
            // Get the StyleRules Element in StPara
            Assert.IsNull(StTxtElement.XPathSelectElement("StPara/StyleName"));
            // Get the StyleName Element in StPara (should be gone)
        }
Example #24
0
        public void DataMigration7000057Test_SubInflTypes()
        {
            var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000057_SubInflTypes.xml");
            // Set up mock MDC.
            var mockMdc = new MockMDCForDataMigration();
            IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000056, dtos, mockMdc, null,
                                                                                TestDirectoryFinder.LcmDirectories);

            m_dataMigrationManager.PerformMigration(dtoRepos, 7000057, new DummyProgressDlg());
            Assert.AreEqual(7000057, dtoRepos.CurrentModelVersion, "Wrong updated version.");

            const string guidNonStandard      = "1df6f9da-7b69-44e4-b98d-13a0cee17b77";
            const string guidNonStandardChild = "208cc589-f10f-485b-bdcc-843f046d4146";
            const string guidPluralChild      = "2bd3437f-8bde-495c-a12b-d0c8feb7c3e9";
            const string guidPastChild        = "7c607ea9-c1a0-4b7f-aee7-06ead42ac299";

            // test that non-standard (user created) Irregularly Inflected Form has the right class
            {
                var nonStandard = dtoRepos.GetDTO(guidNonStandard);
                Assert.That(nonStandard.Classname, Is.EqualTo(LexEntryInflTypeTags.kClassName));
                var nonStandardElt = XElement.Parse(nonStandard.Xml);
                Assert.That(nonStandardElt.XPathSelectElement("Name/AUni").Value,
                            Is.EqualTo("NonStandard"));
            }

            // test that non-standard child has correct class
            {
                var nonStandardChild = dtoRepos.GetDTO(guidNonStandardChild);
                Assert.That(nonStandardChild.Classname, Is.EqualTo(LexEntryInflTypeTags.kClassName));
                var nonStandardChildElt = XElement.Parse(nonStandardChild.Xml);
                Assert.That(nonStandardChildElt.XPathSelectElement("Name/AUni").Value,
                            Is.EqualTo("NonStandardChild"));
            }

            // test that plural child has correct class
            {
                var varTypePluralChild = dtoRepos.GetDTO(guidPluralChild);
                Assert.That(varTypePluralChild.Classname, Is.EqualTo(LexEntryInflTypeTags.kClassName));
                var varTypePluralChildElt = XElement.Parse(varTypePluralChild.Xml);
                Assert.That(varTypePluralChildElt.XPathSelectElement("Name/AUni").Value,
                            Is.EqualTo("PluralChild"));
            }

            // test that past child has correct class
            {
                var varTypePastChild = dtoRepos.GetDTO(guidPastChild);
                Assert.That(varTypePastChild.Classname, Is.EqualTo(LexEntryInflTypeTags.kClassName));
                var varTypePastChildElt = XElement.Parse(varTypePastChild.Xml);
                Assert.That(varTypePastChildElt.XPathSelectElement("Name/AUni").Value,
                            Is.EqualTo("PastChild"));
            }
        }
Example #25
0
        public void DataMigration7000072Test()
        {
            var dtos    = DataMigrationTestServices.ParseProjectFile("DataMigration7000072.xml");
            var mockMdc = new MockMDCForDataMigration();
            IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000071, dtos, mockMdc, null, TestDirectoryFinder.LcmDirectories);

            m_dataMigrationManager.PerformMigration(dtoRepos, 7000072, new DummyProgressDlg());

            // Test to Check whether the given Reversal Index Entry has the added senses
            // Get the Reversal Index Entry with the specified guid
            var aReversalIndexEntry  = dtoRepos.GetDTO("2d1fb89c-5671-43de-8cdd-4624f4648ef4");
            var reversalIndexElement = XElement.Parse(aReversalIndexEntry.Xml);

            // Check for the Senses Tag
            var sensesElement = reversalIndexElement.Element("Senses");

            Assert.NotNull(sensesElement, "No senses‽");
            var objsurElementsList = sensesElement.Elements("objsur");
            var guidList           = new ArrayList();

            foreach (var objsurElement in objsurElementsList)
            {
                guidList.Add(objsurElement.Attribute("guid")?.Value);
            }

            Assert.AreEqual(guidList[0], "c836e945-92d3-4560-9622-bfd9656551c8");
            Assert.AreEqual(guidList[1], "d3d19eae-d840-484e-8de2-0100336808ed");

            // Test to check whether Reversal Entries collection has been removed from LexSense
            var allLexSenses = dtoRepos.AllInstancesWithSubclasses("LexSense");

            foreach (var aLexSense in allLexSenses)
            {
                var lexSenseElement       = XElement.Parse(aLexSense.Xml);
                var reveralEntriesElement = lexSenseElement.Element("ReversalEntries");
                Assert.AreEqual(reveralEntriesElement, null);
            }

            // Test to check whether the Referring Senses value has been changed to Senses under VirtualOrdering
            var allOrderings = dtoRepos.AllInstancesWithSubclasses("VirtualOrdering");

            foreach (var anOrdering in allOrderings)
            {
                var orderingElement = XElement.Parse(anOrdering.Xml);
                var field           = orderingElement.Element("Field");
                Assert.NotNull(field, "field should not be null");
                var uniValue = field.Element("Uni");
                Assert.NotNull(uniValue, "uniValue should not be null");
                Assert.AreEqual("Senses", uniValue.Value);
            }
        }
        public void UpdateUnknownDtoTest()
        {
            var dtos = new HashSet <DomainObjectDTO>();
            // 1. Add barebones LP.
            const string lpGuid = "9719A466-2240-4DEA-9722-9FE0746A30A6";

            CreatoDTO(dtos, lpGuid, "LangProject", null);
            IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(1, dtos, m_mdc, null, TestDirectoryFinder.LcmDirectories);

            var newGuid = Guid.NewGuid();
            var newby   = new DomainObjectDTO(newGuid.ToString(), "LexEntry", "<rt />");

            Assert.That(() => dtoRepos.Update(newby), Throws.TypeOf <InvalidOperationException>());
        }
        public void RemoveDtoTest()
        {
            var dtos = new HashSet <DomainObjectDTO>();
            // 1. Add barebones LP.
            const string lpGuid = "9719A466-2240-4DEA-9722-9FE0746A30A6";
            var          lpDto  = CreatoDTO(dtos, lpGuid, "LangProject", null);
            IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(1, dtos, m_mdc, null, TestDirectoryFinder.LcmDirectories);

            dtoRepos.Remove(lpDto);
            Assert.IsTrue(((DomainObjectDtoRepository)dtoRepos).Goners.Contains(lpDto), "Goner not in goners set.");
            Assert.IsNull(dtoRepos.AllInstancesSansSubclasses("LexEntry").FirstOrDefault(), "Found goner by class.");
            Assert.That(() => dtoRepos.GetDTO(lpDto.Guid),
                        Throws.ArgumentException, "Found deleted DTO by guid.");
        }
        public void DtosByClassButNoSubclassesTest()
        {
            var dtos = new HashSet <DomainObjectDTO>();
            // 1. Add barebones LP.
            const string lpGuid = "9719A466-2240-4DEA-9722-9FE0746A30A6";

            CreatoDTO(dtos, lpGuid, "LangProject", null);
            IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(1, dtos, m_mdc, null, TestDirectoryFinder.LcmDirectories);
            var result = new List <DomainObjectDTO>(dtoRepos.AllInstancesSansSubclasses("CmObject"));

            Assert.AreEqual(0, result.Count, "Wrong number of DTOs (expected 0).");
            result = new List <DomainObjectDTO>(dtoRepos.AllInstancesSansSubclasses("LangProject"));
            Assert.AreEqual(1, result.Count, "Wrong number of DTOs (expected 1).");
        }
        public void DtosByClassWithSubclassesTest()
        {
            var dtos = new HashSet <DomainObjectDTO>();
            // 1. Add barebones LP.
            const string lpGuid = "9719A466-2240-4DEA-9722-9FE0746A30A6";

            CreatoDTO(dtos, lpGuid, "LangProject", null);
            const string lexDbGuid = "6C84F84A-5B99-4CF5-A7D5-A308DDC604E0";

            CreatoDTO(dtos, lexDbGuid, "LexDb", null);
            IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(1, dtos, m_mdc, null, TestDirectoryFinder.LcmDirectories);
            var result = new List <DomainObjectDTO>(dtoRepos.AllInstancesWithSubclasses("CmObject"));

            Assert.AreEqual(2, result.Count, "Wrong number of DTOs (expected 2).");
        }
Example #30
0
        private static IDomainObjectDTORepository DoCommonBasics(IEnumerable <string> extraDataFiles)
        {
            var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000013_CommonData.xml");

            foreach (var extraDataFile in extraDataFiles)
            {
                dtos.UnionWith(DataMigrationTestServices.ParseProjectFile(extraDataFile));
            }

            var mockMDC = SetupMDC();

            IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000012, dtos, mockMDC, null,
                                                                                TestDirectoryFinder.LcmDirectories);

            return(dtoRepos);
        }