コード例 #1
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.");
        }
コード例 #2
0
        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"));
        }
コード例 #3
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"));
        }
コード例 #4
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");
        }
コード例 #5
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());
        }
コード例 #6
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.");
        }
コード例 #7
0
        private static MockMDCForDataMigration SetupMdc()
        {
            var mockMdc = new MockMDCForDataMigration();

            mockMdc.AddClass(1, "CmObject", null, new List <string> {
                "PhContextOrVar", "PhTerminalUnit", "StText"
            });
            mockMdc.AddClass(2, "PhContextOrVar", "CmObject", new List <string> {
                "PhPhonContext"
            });
            mockMdc.AddClass(3, "PhPhonContext", "PhContextOrVar", new List <string> {
                "PhSimpleContext"
            });
            mockMdc.AddClass(4, "PhSimpleContext", "PhPhonContext", new List <string> {
                "PhSimpleContextBdry"
            });
            mockMdc.AddClass(5, "PhSimpleContextBdry", "PhSimpleContext", new List <string>());
            mockMdc.AddClass(6, "PhTerminalUnit", "CmObject", new List <string> {
                "PhBdryMarker"
            });
            mockMdc.AddClass(7, "PhBdryMarker", "PhTerminalUnit", new List <string>());
            mockMdc.AddClass(8, "StText", "CmObject", new List <string>());

            return(mockMdc);
        }
コード例 #8
0
        public void FixtureSetup()
        {
            var mockMDC = new MockMDCForDataMigration();
            // Set it up for CmObject, LangProject, LexDb, and LexEntry.
            var clsid = 0;

            mockMDC.AddClass(++clsid, "CmObject", null, new List <string> {
                "LangProject", "LexDb", "LexEntry"
            });
            mockMDC.AddClass(++clsid, "LangProject", "CmObject", new List <string>());
            mockMDC.AddClass(++clsid, "LexDb", "CmObject", new List <string>());
            mockMDC.AddClass(++clsid, "LexEntry", "CmObject", new List <string>());

            m_mdc = mockMDC;
        }
コード例 #9
0
        public void UniElementPropertiesAreRemoved()
        {
            var mockMdc = new MockMDCForDataMigration();

            mockMdc.AddClass(1, "CmObject", null, new List <string> {
                "ClassWithUnicodeProperties", "AbstractClassWithUnicodeProperties"
            });
            mockMdc.AddClass(2, "ClassWithUnicodeProperties", "CmObject", new List <string>());
            var currentFlid = 2000;

            mockMdc.AddField(++currentFlid, "UnicodePropWithAttrs", CellarPropertyType.Unicode, 0);
            mockMdc.AddField(++currentFlid, "UnicodePropWithoutAttrs", CellarPropertyType.Unicode, 0);

            mockMdc.AddClass(3, "AbstractClassWithUnicodeProperties", "CmObject", new List <string> {
                "ClassWithInheritedUnicodeProperties"
            });
            currentFlid = 3000;
            mockMdc.AddField(++currentFlid, "UnicodePropWithAttrs", CellarPropertyType.Unicode, 0);
            mockMdc.AddField(++currentFlid, "UnicodePropWithoutAttrs", CellarPropertyType.Unicode, 0);
            mockMdc.AddClass(4, "ClassWithInheritedUnicodeProperties", "AbstractClassWithUnicodeProperties", new List <string>());

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

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

            var instance   = XElement.Parse(dtoRepos.AllInstancesSansSubclasses("ClassWithUnicodeProperties").First().Xml);
            var uniElement = instance.Element("UnicodePropWithAttrs").Element("Uni");

            Assert.IsFalse(uniElement.HasAttributes);
            Assert.AreEqual("With Attrs", uniElement.Value);
            uniElement = instance.Element("UnicodePropWithoutAttrs").Element("Uni");
            Assert.IsFalse(uniElement.HasAttributes);
            Assert.AreEqual("Without Attrs", uniElement.Value);

            instance   = XElement.Parse(dtoRepos.AllInstancesSansSubclasses("ClassWithInheritedUnicodeProperties").First().Xml);
            uniElement = instance.Element("UnicodePropWithAttrs").Element("Uni");
            Assert.IsFalse(uniElement.HasAttributes);
            Assert.AreEqual("Inherited With Attrs", uniElement.Value);
            uniElement = instance.Element("UnicodePropWithoutAttrs").Element("Uni");
            Assert.IsFalse(uniElement.HasAttributes);
            Assert.AreEqual("Inherited Without Attrs", uniElement.Value);
        }
コード例 #10
0
        public void DataMigration7000026Test()
        {
            //Bring in data from xml file.
            var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000026Tests.xml");


            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(7000025, dtos, mockMDC, null,
                                                                                TestDirectoryFinder.LcmDirectories);

            //Before the migration there should be a ExtLinkRootDir element in the project.
            var langProjDto            = dtoRepos.AllInstancesSansSubclasses("LangProject").First();
            var langProjElement        = XElement.Parse(langProjDto.Xml);
            var langProjExtLinkRootDir = langProjElement.XPathSelectElement("ExtLinkRootDir");

            Assert.That(langProjExtLinkRootDir, Is.Not.Null, "Before the migration we should have a 'ExtLinkRootDir' element on LangProj");

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

            //This object should contain a 'LinkedFilesRootDir' property
            langProjDto     = dtoRepos.AllInstancesSansSubclasses("LangProject").First();
            langProjElement = XElement.Parse(langProjDto.Xml);
            var langProjLinkedFilesRootDir = langProjElement.XPathSelectElement("LinkedFilesRootDir");

            Assert.That(langProjLinkedFilesRootDir, Is.Not.Null, "We should now have a 'LinkedFilesRootDir' element on LangProj");
            //This object should not contain an 'AnalysysStatus' property
            langProjExtLinkRootDir = langProjElement.XPathSelectElement("ExtLinkRootDir");
            Assert.That(langProjExtLinkRootDir, Is.Null, "LangProject ExtLinkRootDir Property should not exist any more");


            Assert.AreEqual(7000026, dtoRepos.CurrentModelVersion, "Wrong updated version.");
        }
コード例 #11
0
        public void DataMigration7000040Test()
        {
            // Bring in data from xml file.
            var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000040.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> {
                "LexEntryRef"
            });
            mockMDC.AddClass(2, "LexEntryRef", "CmObject", new List <string>());
            mockMDC.AddClass(3, "LexEntry", "CmObject", new List <string>());

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

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

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

            // The empty element should have stayed that way.
            VerifyEntryRef(dtoRepos, "82CB0EC6-B542-4FB8-B5B6-41398790DDF9", 0, 0);

            // The one with no primary lexemes should have no ShowComplexFormsIn
            VerifyEntryRef(dtoRepos, "c1ecaa73-e382-11de-8a39-0800200c9a66", 1, 0);

            // The one with one primary lexemes should have one ShowComplexFormsIn (and ComponentLexemes and PrimaryLexemes unchanged)
            var osElements = VerifyEntryRef(dtoRepos, "BF274D15-406E-4816-A81F-9B8C70AEF8E5", 2, 1);

            Assert.That(osElements.Count(), Is.EqualTo(1));
            VerifyObjSur(osElements, 0, "BFC76313-B9E4-4A31-8408-F854D7709E68");

            // The one with two primary lexemes should have two in ShowComplexFormsIn (and ComponentLexemes and PrimaryLexemes unchanged)
            osElements = VerifyEntryRef(dtoRepos, "B854113C-4B99-46FF-A9F6-ED3F0245E259", 2, 2);
            VerifyObjSur(osElements, 0, "6704EB7A-EFEA-42E4-BFAA-9B99B1D45D6F");
            VerifyObjSur(osElements, 1, "BFC76313-B9E4-4A31-8408-F854D7709E68");
        }
コード例 #12
0
        public void DataMigration7000028Test()
        {
            //Bring in data from xml file.
            var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000028.xml");


            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>());
            mockMDC.AddClass(4, "LexDb", "CmObject", new List <string> ());
            mockMDC.AddClass(5, "LexEntry", "CmObject", new List <string>());

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

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

            // The Entries property of the LexDb should be gone.
            var lexDbDto     = dtoRepos.AllInstancesSansSubclasses("LexDb").First();
            var lexDbElement = XElement.Parse(lexDbDto.Xml);
            var entriesElt   = lexDbElement.Element("Entries");

            Assert.That(lexDbElement.Name.LocalName, Is.EqualTo("rt"));
            Assert.That(entriesElt, Is.Null);

            // LexEntries should no longer know owners.
            var entryDto  = dtoRepos.AllInstancesSansSubclasses("LexEntry").First();
            var entryElt  = XElement.Parse(entryDto.Xml);
            var ownerAttr = entryElt.Attribute("ownerguid");

            Assert.That(ownerAttr, Is.Null);

            Assert.AreEqual(7000028, dtoRepos.CurrentModelVersion, "Wrong updated version.");
        }
コード例 #13
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");
        }
コード例 #14
0
        public void DataMigration7000008Test()
        {
            // Add at least one ScrScriptureNote which has a null BeginObject prop.
            // This ScrScriptureNote should not be removed in this migration.

            var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000008Tests.xml");

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

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

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

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

            Assert.AreEqual(4, goners.Count, "Wrong number removed.");
            var gonerGuids = new List <string>
            {
                ("54E4A881-23D7-48FC-BD05-14DD0CA86D5B").ToLower(),                                                         // Defective Discourse Chart ann.
                ("22a8431f-f974-412f-a261-8bd1a4e1be1b").ToLower(),
                ("155B8419-0A9B-44A4-A960-F78983C84768").ToLower(),
                ("84FC5548-8AB2-4AA0-AFE5-72F64F567982").ToLower()
            };

            foreach (var goner in goners)
            {
                Assert.Contains(goner.Guid.ToLower(), gonerGuids, "Goner guid not found.");
            }
        }
コード例 #15
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)
        }
コード例 #16
0
        public void DataMigration7000041Test()
        {
            // Bring in data from xml file.
            var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000041.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> {
                "LexEntry", "CmMajorObject"
            });
            mockMDC.AddClass(2, "LexEntry", "CmObject", new List <string>());
            mockMDC.AddClass(3, "CmMajorObject", "CmObject", new List <string> {
                "CmPossibilityList"
            });
            mockMDC.AddClass(4, "CmPossibilityList", "CmMajorObject", new List <string>());

            TryThisProject(dtos, mockMDC, 3);             // with Publications posibility list

            dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000041a.xml");

            TryThisProject(dtos, mockMDC, 1);             // no Publications posibility list
        }
コード例 #17
0
        private static MockMDCForDataMigration SetupMdc()
        {
            var mockMdc = new MockMDCForDataMigration();

            mockMdc.AddClass(0, "CmObject", null, new List <string> {
                "CmProject", "CmMajorObject", "CmPossibility", "RnGenericRec"
            });
            mockMdc.AddClass(CmProjectTags.kClassId, "CmProject", "CmObject", new List <string> {
                "LangProject"
            });
            mockMdc.AddClass(CmMajorObjectTags.kClassId, "CmMajorObject", "CmObject", new List <string> {
                "RnResearchNbk", "CmPossibilityList"
            });
            mockMdc.AddClass(CmPossibilityTags.kClassId, "CmPossibility", "CmObject", new List <string>());
            mockMdc.AddClass(LangProjectTags.kClassId, "LangProject", "CmProject", new List <string>());
            mockMdc.AddClass(RnResearchNbkTags.kClassId, "RnResearchNbk", "CmMajorObject", new List <string>());
            mockMdc.AddClass(CmPossibilityListTags.kClassId, "CmPossibilityList", "CmMajorObject", new List <string>());
            mockMdc.AddClass(RnGenericRecTags.kClassId, "RnGenericRec", "CmObject", new List <string>());

            return(mockMdc);
        }
コード例 #18
0
        private static MockMDCForDataMigration SetupMDC()
        {
            var mockMDC = new MockMDCForDataMigration();

            mockMDC.AddClass(1, "CmObject", null, new List <string> {
                "LangProject", "CmAgent", "WfiWordform",
                "WfiAnalysis", "CmAgentEvaluation"
            });
            mockMDC.AddClass(2, "CmAgent", "CmObject", new List <string>());
            mockMDC.AddClass(3, "LangProject", "CmObject", new List <string>());
            mockMDC.AddClass(4, "WfiWordform", "CmObject", new List <string>());
            mockMDC.AddClass(5, "WfiAnalysis", "CmObject", new List <string>());
            mockMDC.AddClass(6, "CmAgentEvaluation", "CmObject", new List <string>());
            return(mockMDC);
        }
コード例 #19
0
        internal static MockMDCForDataMigration SetupMdc()
        {
            var mockMdc = new MockMDCForDataMigration();

            mockMdc.AddClass(0, "CmObject", null, new List <string> {
                "CmProject", "UserView", "UserViewRec", "UserViewField"
            });
            mockMdc.AddClass(1, "CmProject", "CmObject", new List <string> {
                "LangProject"
            });
            mockMdc.AddClass(6001, "LangProject", "CmProject", new List <string>());
            mockMdc.AddClass(18, "UserView", "CmObject", new List <string>());
            mockMdc.AddClass(19, "UserViewRec", "CmObject", new List <string>());
            mockMdc.AddClass(20, "UserViewField", "CmObject", new List <string>());
            return(mockMdc);
        }
コード例 #20
0
        private static MockMDCForDataMigration SetupMdc()
        {
            var mockMdc = new MockMDCForDataMigration();

            mockMdc.AddClass(1, "CmObject", null, new List <string> {
                "CmProject", "CmMajorObject", "CmPossibility"
            });
            mockMdc.AddClass(2, "CmProject", "CmObject", new List <string> {
                "LangProject"
            });
            mockMdc.AddClass(3, "CmMajorObject", "CmObject", new List <string> {
                "RnResearchNbk", "CmPossibilityList"
            });
            mockMdc.AddClass(4, "CmPossibility", "CmObject", new List <string>());
            mockMdc.AddClass(5, "LangProject", "CmProject", new List <string>());
            mockMdc.AddClass(6, "RnResearchNbk", "CmMajorObject", new List <string>());
            mockMdc.AddClass(7, "CmPossibilityList", "CmMajorObject", new List <string>());

            return(mockMdc);
        }
コード例 #21
0
        public void DuplicatedListsAreMarkedAsCustom()
        {
            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);

            Assert.AreEqual(3, dtoRepos.AllInstancesWithSubclasses("CmPossibilityList").Count(), "The CmPossibilityList test data has changed");

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

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

            Assert.AreEqual(3, resultingLists.Count, "The Custom list and new replacement should be all there is");
            // Make sure that the custom list got a custom name and the 'real' owned list kept the original name
            var custLanguages = XElement.Parse(resultingLists[0].Xml);
            var origLanguages = XElement.Parse(resultingLists[1].Xml);
            var notLanguages  = XElement.Parse(resultingLists[2].Xml);

            Assert.IsTrue(origLanguages.Attribute("ownerguid") != null, "Test data order has changed");
            var firstName = origLanguages.Element("Name").Elements("AUni").First().Value;

            Assert.That(firstName, Is.StringMatching("Languages"), "Built in list should not have changed the name");
            firstName = custLanguages.Element("Name").Elements("AUni").First().Value;
            Assert.That(firstName, Is.StringMatching("Languages-Custom"), "The custom Languages list did not have its name changed");
            firstName = notLanguages.Element("Name").Elements("AUni").First().Value;
            Assert.That(firstName, Is.StringMatching("Not Languages"), "The unrelated list should not have had its name changed");
        }
コード例 #22
0
        private static MockMDCForDataMigration SetupMDC()
        {
            var mockMDC = new MockMDCForDataMigration();

            mockMDC.AddClass(1, "CmObject", null, new List <string> {
                "LangProject", "DsDiscourseData", "DsConstChart",
                "ConstChartRow", "CmPossibility", "ConstituentChartCellPart"
            });
            mockMDC.AddClass(2, "CmPossibility", "CmObject", new List <string>());
            mockMDC.AddClass(3, "LangProject", "CmObject", new List <string>());
            mockMDC.AddClass(4, "DsDiscourseData", "CmObject", new List <string>());
            mockMDC.AddClass(5, "DsConstChart", "CmObject", new List <string>());
            mockMDC.AddClass(6, "ConstChartRow", "CmObject", new List <string>());
            mockMDC.AddClass(14, "ConstituentChartCellPart", "CmObject", new List <string> {
                "ConstChartWordGroup", "ConstChartMovedTextMarker", "ConstChartClauseMarker", "ConstChartTag"
            });
            mockMDC.AddClass(15, "ConstChartWordGroup", "ConstituentChartCellPart", new List <string>());
            mockMDC.AddClass(16, "ConstChartMovedTextMarker", "ConstituentChartCellPart", new List <string>());
            mockMDC.AddClass(17, "ConstChartClauseMarker", "ConstituentChartCellPart", new List <string>());
            mockMDC.AddClass(18, "ConstChartTag", "ConstituentChartCellPart", new List <string>());
            return(mockMDC);
        }
コード例 #23
0
        public void DataMigration7000029Test()
        {
            //Bring in data from xml file.
            var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000029Tests.xml");

            //Now create all the Mock classes for the classes in my test data.
            //eg LangProject base class is CmProject which has a base class of CmObject
            //eg LexEntry base class is CmObject
            var mockMDC = new MockMDCForDataMigration();

            mockMDC.AddClass(1, "CmObject", null, new List <string>
            {
                "CmProject",
                "CmMajorObject",
                "LexEntry",
                "LexSense",
                "CmPicture",
                "CmFolder",
                "CmFile"
            });
            mockMDC.AddClass(2, "CmProject", "CmObject", new List <string> {
                "LangProject"
            });
            mockMDC.AddClass(3, "LangProject", "CmProject", new List <string>());

            mockMDC.AddClass(4, "CmMajorObject", "CmObject", new List <string> {
                "LexDb"
            });
            mockMDC.AddClass(5, "LexDb", "CmMajorObject", new List <string>());

            mockMDC.AddClass(6, "LexEntry", "CmObject", new List <string>());
            mockMDC.AddClass(7, "LexSense", "CmObject", new List <string>());
            mockMDC.AddClass(8, "CmPicture", "CmObject", new List <string>());
            mockMDC.AddClass(9, "CmFolder", "CmObject", new List <string>());
            mockMDC.AddClass(10, "CmFile", "CmObject", new List <string>());
            //-------------------+++++++++++++++++++++++++=

            IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000028, dtos, mockMDC,
                                                                                @"C:\FwWW\DistFiles\Projects\Sena 3", TestDirectoryFinder.LcmDirectories);

            //Get the Element <rt guid="b8bdad3d-9006-46f0-83e8-ae1d1726f2ad" class="LangProject">
            var langProjDto = dtoRepos.AllInstancesSansSubclasses("LangProject").First();

            var langProjElement            = XElement.Parse(langProjDto.Xml);
            var langProjLinkedFilesRootDir = langProjElement.XPathSelectElement("LinkedFilesRootDir");

            Assert.That(langProjLinkedFilesRootDir, Is.Not.Null, "Before the migration we should have a 'LinkedFilesRootDir' element on LangProj");
            var langProjPictures = langProjElement.XPathSelectElement("Pictures");

            Assert.That(langProjPictures, Is.Not.Null, "Before the migration we should have a 'Pictures' element on LangProj");
            var langProjMedia = langProjElement.XPathSelectElement("Media");

            Assert.That(langProjMedia, Is.Not.Null, "Before the migration we should have a 'Media' element on LangProj");

            //Get the Elements  for class="CmFile"
            var CmFileDtosBeforeMigration = dtoRepos.AllInstancesSansSubclasses("CmFile");
            //Get all the file paths (as strings) for the CmFile's in the project
            var filesPathsBeforeMigration = new List <String>();

            foreach (var fileDto in CmFileDtosBeforeMigration)
            {
                filesPathsBeforeMigration.Add(GetCmFilePath(fileDto));
            }
            Assert.That(filesPathsBeforeMigration.ElementAt(0), Is.EqualTo(@"Pictures\Jude1.jpg"));
            Assert.That(filesPathsBeforeMigration.ElementAt(1), Is.EqualTo(@"Pictures\Rick USVI-extraOne.jpg"));
            Assert.That(filesPathsBeforeMigration.ElementAt(2), Is.EqualTo(@"C:\FwWW\DistFiles\Projects\Sena 3\LinkedFiles\RickKayak.jpg"));
            Assert.That(filesPathsBeforeMigration.ElementAt(3), Is.EqualTo(@"C:\FwWW\DistFiles\RickKayak.jpg"));
            Assert.That(filesPathsBeforeMigration.ElementAt(4), Is.EqualTo(@"C:\FwWW\DistFiles\Projects\Sena 3\LinkedFiles\Pictures\Rick USVI.jpg"));
            Assert.That(filesPathsBeforeMigration.ElementAt(5), Is.EqualTo(@"AudioVisual\Untitled5.WMV"));
            Assert.That(filesPathsBeforeMigration.ElementAt(6), Is.EqualTo(@"C:\FwWW\DistFiles\Projects\Sena 3\LinkedFiles\AudioVisual\MacLeanKidsMovie.WMV"));
            Assert.That(filesPathsBeforeMigration.ElementAt(7), Is.EqualTo(@"C:\FwWW\DistFiles\AudioVisual\NotInLinkedFilesPath.WMV"));

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

            //make sure the version was updated.
            Assert.AreEqual(7000029, dtoRepos.CurrentModelVersion, "Wrong updated version.");

            //Now check that all the CmFile's have paths which are correct.
            //Get the Elements  for class="CmFile"
            var CmFileDtosAfterMigration = dtoRepos.AllInstancesSansSubclasses("CmFile");
            //Get all the file paths (as strings) for the CmFile's in the project
            var filesPathsAfterMigration = new List <String>();

            foreach (var fileDto in CmFileDtosAfterMigration)
            {
                filesPathsAfterMigration.Add(GetCmFilePath(fileDto));
            }
            //Now check to ensure path are corrected relative to LinkedFiles
            //Also ensure ones that are not relative to the LinkedFiles path are not changed.
            Assert.That(filesPathsAfterMigration.ElementAt(0), Is.EqualTo(FileUtils.ChangePathToPlatform(@"Pictures\Jude1.jpg")));
            Assert.That(filesPathsAfterMigration.ElementAt(1), Is.EqualTo(FileUtils.ChangePathToPlatform(@"Pictures\Rick USVI-extraOne.jpg")));
            Assert.That(filesPathsAfterMigration.ElementAt(2), Is.EqualTo(FileUtils.ChangePathToPlatform(@"RickKayak.jpg")));
            Assert.That(filesPathsAfterMigration.ElementAt(3), Is.EqualTo(FileUtils.ChangePathToPlatform(@"C:\FwWW\DistFiles\RickKayak.jpg")));
            Assert.That(filesPathsAfterMigration.ElementAt(4), Is.EqualTo(FileUtils.ChangePathToPlatform(@"Pictures\Rick USVI.jpg")));
            Assert.That(filesPathsAfterMigration.ElementAt(5), Is.EqualTo(FileUtils.ChangePathToPlatform(@"AudioVisual\Untitled5.WMV")));
            Assert.That(filesPathsAfterMigration.ElementAt(6), Is.EqualTo(FileUtils.ChangePathToPlatform(@"AudioVisual\MacLeanKidsMovie.WMV")));
            Assert.That(filesPathsAfterMigration.ElementAt(7), Is.EqualTo(FileUtils.ChangePathToPlatform(@"C:\FwWW\DistFiles\AudioVisual\NotInLinkedFilesPath.WMV")));
        }
コード例 #24
0
        private static MockMDCForDataMigration SetupMdc()
        {
            var mockMdc = new MockMDCForDataMigration();

            mockMdc.AddClass(0, "CmObject", null,
                             new List <string> {
                "CmProject", "CmMajorObject", "RnGenericRec", "StStyle", "StText", "StPara"
            });
            mockMdc.AddClass(CmProjectTags.kClassId, "CmProject", "CmObject", new List <string> {
                "LangProject"
            });
            mockMdc.AddClass(CmMajorObjectTags.kClassId, "CmMajorObject", "CmObject",
                             new List <string> {
                "RnResearchNbk", "LexDb"
            });
            mockMdc.AddClass(LangProjectTags.kClassId, "LangProject", "CmProject", new List <string>());
            mockMdc.AddClass(RnResearchNbkTags.kClassId, "RnResearchNbk", "CmMajorObject", new List <string>());
            mockMdc.AddClass(RnGenericRecTags.kClassId, "RnGenericRec", "CmObject", new List <string>());
            mockMdc.AddClass(LexDbTags.kClassId, "LexDb", "CmMajorObject", new List <string>());
            mockMdc.AddClass(StStyleTags.kClassId, "StStyle", "CmObject", new List <string>());
            mockMdc.AddClass(StTextTags.kClassId, "StText", "CmObject", new List <string>());
            mockMdc.AddClass(StParaTags.kClassId, "StPara", "CmObject", new List <string> {
                "StTxtPara"
            });
            mockMdc.AddClass(StTxtParaTags.kClassId, "StTxtPara", "StPara", new List <string>());

            return(mockMdc);
        }
コード例 #25
0
        public void DataMigration7000027Test()
        {
            var dtos = new HashSet <DomainObjectDTO>();
            var sb   = new StringBuilder();

            // 1. Add barebones LP.
            sb.Append("<rt class=\"LangProject\" guid=\"9719A466-2240-4DEA-9722-9FE0746A30A6\">");
            sb.Append("<Texts>");
            StTextAndParaInfo lpTextsGuids = new StTextAndParaInfo("9719A466-2240-4DEA-9722-9FE0746A30A6", "Normal", false, false);

            sb.Append("<objsur guid=\"" + lpTextsGuids.textGuid + "\" t=\"o\" />");
            sb.Append("</Texts>");
            sb.Append("<TranslatedScripture>");
            sb.Append("<objsur guid=\"2c5c1f5f-1f08-41d7-99fe-23893ee4ceef\" t=\"o\" />");
            sb.Append("</TranslatedScripture>");
            sb.Append("</rt>");
            var lpDto = new DomainObjectDTO("9719A466-2240-4DEA-9722-9FE0746A30A6",
                                            "LangProject", sb.ToString());

            dtos.Add(lpDto);

            // Add text dto.
            var txtDto = new DomainObjectDTO(lpTextsGuids.textGuid.ToString(), "StText",
                                             lpTextsGuids.textXml);

            dtos.Add(txtDto);
            // Add text para dto.
            var txtParaDto = new DomainObjectDTO(lpTextsGuids.paraGuid.ToString(), "ScrTxtPara",
                                                 lpTextsGuids.paraXml);

            dtos.Add(txtParaDto);

            // 2. Add Scripture
            sb = new StringBuilder();
            sb.Append("<rt class=\"Scripture\" guid=\"2c5c1f5f-1f08-41d7-99fe-23893ee4ceef\" ownerguid=\"9719A466-2240-4DEA-9722-9FE0746A30A6\" owningflid=\"6001040\" owningord=\"0\">");
            sb.Append("<Books>");
            sb.Append("<objsur guid=\"f213db11-7007-4a2f-9b94-06d6c96014ca\" t=\"o\" />");
            sb.Append("</Books>");
            sb.Append("</rt>");
            var scrDto = new DomainObjectDTO("2c5c1f5f-1f08-41d7-99fe-23893ee4ceef", "Scripture",
                                             sb.ToString());

            dtos.Add(scrDto);

            // 3. Add a ScrBook
            sb = new StringBuilder();
            sb.Append("<rt class=\"ScrBook\" guid=\"f213db11-7007-4a2f-9b94-06d6c96014ca\" ownerguid=\"2c5c1f5f-1f08-41d7-99fe-23893ee4ceef\" owningflid=\"3001001\" owningord=\"0\">");
            sb.Append("<Name>");
            sb.Append("<AUni ws=\"fr\">Genesis</AUni>");
            sb.Append("</Name>");
            sb.Append("<Title>");
            StTextAndParaInfo titleTextGuids = new StTextAndParaInfo("f213db11-7007-4a2f-9b94-06d6c96014ca", "Title Main", true, false);

            sb.Append("<objsur guid=\"" + titleTextGuids.textGuid + "\" t=\"o\" />");
            sb.Append("</Title>");
            sb.Append("<Sections>");
            sb.Append("<objsur guid=\"834e1bf8-3a25-47d6-9f92-806b38b5f815\" t=\"o\" />");
            sb.Append("</Sections>");
            sb.Append("<Footnotes>");
            StTextAndParaInfo footnoteGuids = new StTextAndParaInfo("ScrFootnote", "f213db11-7007-4a2f-9b94-06d6c96014ca", "Title Main", null, true, false);

            sb.Append("<objsur guid=\"" + footnoteGuids.textGuid + "\" t=\"o\" />");
            sb.Append("</Footnotes>");
            sb.Append("</rt>");
            var bookDto = new DomainObjectDTO("f213db11-7007-4a2f-9b94-06d6c96014ca", "ScrBook", sb.ToString());

            dtos.Add(bookDto);

            // Add title
            var titleDto = new DomainObjectDTO(titleTextGuids.textGuid.ToString(), "StText",
                                               titleTextGuids.textXml);

            dtos.Add(titleDto);
            // Title para
            var titleParaDto = new DomainObjectDTO(titleTextGuids.paraGuid.ToString(), "ScrTxtPara",
                                                   titleTextGuids.paraXml);

            dtos.Add(titleParaDto);

            // Add footnote
            var footnoteDto = new DomainObjectDTO(footnoteGuids.textGuid.ToString(), "ScrFootnote",
                                                  footnoteGuids.textXml);

            dtos.Add(footnoteDto);
            // Footnote para
            var footnoteParaDto = new DomainObjectDTO(footnoteGuids.paraGuid.ToString(), "ScrTxtPara",
                                                      footnoteGuids.paraXml);

            dtos.Add(footnoteParaDto);

            // 4. Add a section to the book
            sb = new StringBuilder();
            sb.Append("<rt class=\"ScrSection\" guid=\"834e1bf8-3a25-47d6-9f92-806b38b5f815\" ownerguid=\"f213db11-7007-4a2f-9b94-06d6c96014ca\" owningflid=\"3002001\" owningord=\"0\">");
            sb.Append("<Content>");
            StTextAndParaInfo contentsTextGuids = new StTextAndParaInfo("StText", "834e1bf8-3a25-47d6-9f92-806b38b5f815", "Paragraph",
                                                                        "<Run ws=\"fr\" ownlink=\"" + footnoteGuids.textGuid + "\"></Run>", true, false);

            sb.Append("<objsur guid=\"" + contentsTextGuids.textGuid + "\" t=\"o\" />");
            sb.Append("</Content>");
            sb.Append("<Heading>");
            StTextAndParaInfo headingTextGuids = new StTextAndParaInfo("834e1bf8-3a25-47d6-9f92-806b38b5f815", "Section Head", true, false);

            sb.Append("<objsur guid=\"" + headingTextGuids.textGuid + "\" t=\"o\" />");
            sb.Append("</Heading>");
            sb.Append("</rt>");
            var sectionDto = new DomainObjectDTO("834e1bf8-3a25-47d6-9f92-806b38b5f815", "ScrSection",
                                                 sb.ToString());

            dtos.Add(sectionDto);

            // Add the contents
            var contentsDto = new DomainObjectDTO(contentsTextGuids.textGuid.ToString(), "StText",
                                                  contentsTextGuids.textXml);

            dtos.Add(contentsDto);
            // Contents para
            var contentsParaDto = new DomainObjectDTO(contentsTextGuids.paraGuid.ToString(), "ScrTxtPara",
                                                      contentsTextGuids.paraXml);

            dtos.Add(contentsParaDto);

            // Add the heading to the xml
            var headingDto = new DomainObjectDTO(headingTextGuids.textGuid.ToString(), "StText",
                                                 headingTextGuids.textXml);

            dtos.Add(headingDto);
            // heading para
            var headingParaDto = new DomainObjectDTO(headingTextGuids.paraGuid.ToString(), "ScrTxtPara",
                                                     headingTextGuids.paraXml);

            dtos.Add(headingParaDto);

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

            mockMDC.AddClass(1, "CmObject", null, new List <string> {
                "LangProject", "StText", "Scripture",
                "ScrBook", "StFootnote", "ScrSection", "StPara"
            });
            mockMDC.AddClass(2, "LangProject", "CmObject", new List <string>());
            mockMDC.AddClass(3, "StText", "CmObject", new List <string> {
                "StFootnote"
            });
            mockMDC.AddClass(4, "Scripture", "CmObject", new List <string>());
            mockMDC.AddClass(5, "ScrBook", "CmObject", new List <string>());
            mockMDC.AddClass(6, "StFootnote", "StText", new List <string> {
                "ScrFootnote"
            });
            mockMDC.AddClass(7, "ScrSection", "CmObject", new List <string>());
            mockMDC.AddClass(8, "StTxtPara", "StPara", new List <string> {
                "ScrTxtPara"
            });
            mockMDC.AddClass(9, "ScrFootnote", "StFootnote", new List <string>());
            mockMDC.AddClass(10, "ScrTxtPara", "StTxtPara", new List <string>());
            mockMDC.AddClass(11, "StPara", "CmObject", new List <string> {
                "StTxtPara"
            });
            IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000026, dtos, mockMDC, null,
                                                                                TestDirectoryFinder.LcmDirectories);

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

            // Check that the ParaContainingOrc property in footnotes is set
            DomainObjectDTO footnoteDTO       = dtoRepos.GetDTO(footnoteGuids.textGuid.ToString());
            XElement        footnote          = XElement.Parse(footnoteDTO.Xml);
            XElement        paraContainingOrc = footnote.Element("ParaContainingOrc");

            Assert.IsNotNull(paraContainingOrc);
            XElement objRef = paraContainingOrc.Element("objsur");

            Assert.IsNotNull(objRef);
            Assert.AreEqual(contentsTextGuids.paraGuid.ToString(), objRef.Attribute("guid").Value);
            Assert.AreEqual("r", objRef.Attribute("t").Value);
        }
コード例 #26
0
        public void DataMigration7000001_and_Delint_Tests()
        {
            var dtos = new HashSet <DomainObjectDTO>();
            // 1. Add barebones LP.
            // LP will have one extra property to make sure it isnt; affected.
            // LP will also have a couple 'dangling' references for when 'Delint' is tested.
            // LP will also have an empty Name element that ought to be removed.
            var xml =
                string.Format("<rt class=\"LangProject\" guid=\"9719A466-2240-4DEA-9722-9FE0746A30A6\">{0}" +
                              "<CmObject></CmObject>{0}" +
                              "<LangProject>{0}" +
                              "<Name>{0}" +
                              "</Name>{0}" +
                              "<FakeBoolProperty val=\"True\" />{0}" +
                              "<FakeProperty>bogus content</FakeProperty>{0}" +
                              "<EthnologueCode>{0}" +
                              "<Uni>ZPI</Uni>{0}" +
                              "</EthnologueCode>{0}" +
                              "<WordformInventory>{0}" +
                              "<objsur guid=\"6C84F84A-5B99-4CF5-A7D5-A308DDC604E0\" t=\"o\"/>{0}" +
                              "</WordformInventory>{0}" +
                              "<AnalysisStatus>{0}" +
                              "<objsur guid=\"44AF225F-964C-4F7B-BE51-1AE05995D38C\" t=\"o\" />{0}" +
                              "</AnalysisStatus>{0}" +
                              "<CurVernWss>{0}" +
                              "<objsur guid=\"D75F7FB5-BABD-4D60-B57F-E188BEF264B7\" t=\"r\"/>{0}" +
                              "</CurVernWss>{0}" +
                              "</LangProject>{0}" +
                              "</rt>", Environment.NewLine);
            var lpDto = new DomainObjectDTO("9719A466-2240-4DEA-9722-9FE0746A30A6",
                                            "LangProject",
                                            xml);

            dtos.Add(lpDto);

            xml = string.Format(
                "<rt class=\"WordformInventory\" guid=\"6C84F84A-5B99-4CF5-A7D5-A308DDC604E0\" ownerguid=\"9719A466-2240-4DEA-9722-9FE0746A30A6\" owningflid=\"6001013\" owningord=\"1\">{0}" +
                "<CmObject></CmObject>{0}" +
                "<WordformInventory>{0}" +
                "<Wordforms>{0}" +
                "<objsur guid=\"88304983-CDB2-460B-B3D5-5F95C66F27FF\" t=\"o\" />{0}" +
                "<objsur guid=\"59821DAB-AB03-470E-B430-5696A0503A08\" t=\"o\" />{0}" +
                "</Wordforms>{0}" +
                "</WordformInventory>{0}" +
                "</rt>", Environment.NewLine);
            var wfiDto = new DomainObjectDTO("6C84F84A-5B99-4CF5-A7D5-A308DDC604E0",
                                             "WordformInventory",
                                             xml);

            dtos.Add(wfiDto);

            // 3. Add two wordforms
            // First wordform.
            xml = string.Format(
                "<rt class=\"WfiWordform\" guid=\"88304983-CDB2-460B-B3D5-5F95C66F27FF\" ownerguid=\"6C84F84A-5B99-4CF5-A7D5-A308DDC604E0\" owningflid=\"5063001\" owningord=\"1\">{0}" +
                "<CmObject></CmObject>{0}" +
                "<WfiWordform>{0}" +
                "<Checksum val=\"1722980789\"/>{0}" +
                "<Form>{0}" +
                "<AUni ws=\"eZPI\">aerekondixyonada</AUni>{0}" +
                "</Form>{0}" +
                "<SpellingStatus val=\"1\"/>{0}" +
                "</WfiWordform>{0}" +
                "</rt>", Environment.NewLine);
            var wf1Dto = new DomainObjectDTO("88304983-CDB2-460B-B3D5-5F95C66F27FF",
                                             "WfiWordform",
                                             xml);

            dtos.Add(wf1Dto);

            // Second wordform.
            xml = string.Format(
                "<rt class=\"WfiWordform\" guid=\"59821DAB-AB03-470E-B430-5696A0503A08\" ownerguid=\"6C84F84A-5B99-4CF5-A7D5-A308DDC604E0\" owningflid=\"5063001\" owningord=\"2\">{0}" +
                "<CmObject></CmObject>{0}" +
                "<WfiWordform>{0}" +
                "<Checksum val=\"-1933028922\"/>{0}" +
                "<Form>{0}" +
                "<AUni ws=\"eZPI\">aeropwerto</AUni>{0}" +
                "</Form>{0}" +
                "<SpellingStatus val=\"1\"/>{0}" +
                "</WfiWordform>{0}" +
                "</rt>", Environment.NewLine);
            var wf2Dto = new DomainObjectDTO("59821DAB-AB03-470E-B430-5696A0503A08",
                                             "WfiWordform",
                                             xml);

            dtos.Add(wf2Dto);

            // Add zombie, which is where an object's owner does not exist.
            xml = @"<rt class=""LexSense"" guid=""3462BE3E-4817-4BBE-B2B9-30828B48E2C7"" ownerguid=""0875E978-79C5-4F87-95FE-A4235C0711C1"" owningflid=""5002011"" owningord=""1"" />";
            var zombie = new DomainObjectDTO("3462BE3E-4817-4BBE-B2B9-30828B48E2C7",
                                             "LexSense",
                                             xml);

            dtos.Add(zombie);
            // Add another zombie,
            // which is where an object's owner *does* exist,
            // but it doesn't know it owns the zombie.
            xml = @"<rt class=""Text"" guid=""c1ecaa72-e382-11de-8a39-0800200c9a66"" ownerguid=""9719A466-2240-4DEA-9722-9FE0746A30A6"" owningflid=""6001006"" owningord=""1"" />";
            var zombie2 = new DomainObjectDTO("c1ecaa72-e382-11de-8a39-0800200c9a66",
                                              "Text",
                                              xml);

            dtos.Add(zombie2);

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

            mockMDC.AddClass(1, "CmObject", null, new List <string> {
                "LangProject", "Text", "WfiWordform", "LexSense"
            });
            mockMDC.AddClass(2, "LangProject", "CmObject", new List <string>());
            mockMDC.AddClass(3, "Text", "CmObject", new List <string>());
            mockMDC.AddClass(4, "WfiWordform", "CmObject", new List <string>());
            mockMDC.AddClass(5, "LexSense", "CmObject", new List <string>());
            IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000000, dtos, mockMDC, null, TestDirectoryFinder.LcmDirectories);

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

            // Make sure version number is correct.
            Assert.AreEqual(7000001, dtoRepos.CurrentModelVersion, "Wrong updated version.");
            // Make sure <rt class=\"LangProject\" ...> has no WFI property.
            var lpElement        = XElement.Parse(lpDto.Xml);
            var lpInnerLpElement = lpElement.Element("LangProject");

            Assert.IsNotNull(lpInnerLpElement, "Oops. The 'LangProject' node was also eaten :-(.");

            Assert.IsNull(lpInnerLpElement.Element("WordformInventory"), "Still has WFI in the LangProj element.");

            // Sanity checks.
            Assert.IsNotNull(lpInnerLpElement.Element("EthnologueCode"), "Oops. The 'EthnologueCode' was also eaten :-(.");

            // Make sure there is no WordformInventory <rt> element
            DataMigrationTestServices.CheckDtoRemoved(dtoRepos, wfiDto);

            // Make sure the two wordforms have no owning-related attrs.
            var wfRtElements = new List <XElement> {
                XElement.Parse(wf1Dto.Xml), XElement.Parse(wf2Dto.Xml)
            };

            foreach (var wfElement in wfRtElements)
            {
                Assert.IsNull(wfElement.Attribute("ownerguid"), "Still has 'ownerguid'attr.");
                Assert.IsNull(wfElement.Attribute("owningflid"), "Still has 'owningflid'attr.");
                Assert.IsNull(wfElement.Attribute("owningord"), "Still has 'owningord'attr.");
                // Sanity checks.
                Assert.IsNotNull(wfElement.Descendants("WfiWordform").FirstOrDefault(), "Oops. The 'WfiWordform' element was also eaten :-(.");
                Assert.IsNotNull(wfElement.Descendants("Checksum").FirstOrDefault(), "Oops. The 'Checksum' element was also eaten :-(.");
            }

            // [NB: Other unit tests need not check Delint, as once is good enough. :-)]
            // Make sure Delint worked.
            // Make sure dangling owned object was removed.
            var analStatusElement = lpElement.Descendants("AnalysisStatus").FirstOrDefault();

            Assert.IsNull(analStatusElement, "Now empty element was not removed.");
            // Make sure dangling regular reference was removed.
            var curVernWssElement = lpElement.Descendants("CurVernWss").FirstOrDefault();

            Assert.IsNull(curVernWssElement, "Now empty element was not removed.");
            // Make sure zombie was removed.
            DataMigrationTestServices.CheckDtoRemoved(dtoRepos, zombie);
            // Make sure zombie2 was removed.
            DataMigrationTestServices.CheckDtoRemoved(dtoRepos, zombie2);
            // Make sure Delint handled emtpy properties correctly.
            Assert.IsNull(lpInnerLpElement.Element("Name"), "Empty 'Name' property not removed.");
            Assert.IsNotNull(lpInnerLpElement.Element("FakeBoolProperty"), "Oops. 'FakeBoolProperty' removed.");
            Assert.IsNull(lpInnerLpElement.Element("FakeProperty"), "'FakeProperty' survived.");
        }
コード例 #27
0
        public void DataMigration7000061Test()
        {
            var mockMdc = new MockMDCForDataMigration();

            mockMdc.AddClass(1, "CmObject", null, new List <string> {
                "LangProject", "StStyle", "CmResource", "LexEntry", "MoStemAllomorph", "MoStemName", "MoStemMsa", "CmIndirectAnnotation", "CmBaseAnnotation", "MoMorphAdhocProhib", "StText", "StTxtPara"
            });
            mockMdc.AddClass(2, "LangProject", "CmObject", new List <string>());
            mockMdc.AddClass(3, "StStyle", "CmObject", new List <string>());
            mockMdc.AddClass(4, "CmResource", "CmObject", new List <string>());
            mockMdc.AddClass(5, "LexEntry", "CmObject", new List <string>());
            mockMdc.AddClass(6, "MoStemAllomorph", "CmObject", new List <string>());
            mockMdc.AddClass(7, "MoStemName", "CmObject", new List <string>());
            mockMdc.AddClass(8, "MoStemMsa", "CmObject", new List <string>());
            mockMdc.AddClass(9, "CmIndirectAnnotation", "CmObject", new List <string>());
            mockMdc.AddClass(10, "CmBaseAnnotation", "CmObject", new List <string>());
            mockMdc.AddClass(11, "MoMorphAdhocProhib", "CmObject", new List <string>());
            mockMdc.AddClass(12, "StText", "CmObject", new List <string>());
            mockMdc.AddClass(13, "StTxtPara", "CmObject", new List <string>());

            mockMdc.AddField(1001, "Name", CellarPropertyType.Unicode, 0);
            mockMdc.AddField(5001, "LexemeForm", CellarPropertyType.OwningAtomic, 6);
            mockMdc.AddField(6001, "StemName", CellarPropertyType.ReferenceAtomic, 7);

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

            m_dataMigrationManager.PerformMigration(dtoRepos, 7000061, 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);
            }

            // Step 2. (atomic owning and ref props with multiple elements)
            dto = dtoRepos.AllInstancesSansSubclasses("LexEntry").First();
            var element = XElement.Parse(dto.Xml);
            // Atomic owning prop
            var propertyElement = element.Element("LexemeForm");

            Assert.AreEqual(1, propertyElement.Elements().Count());
            Assert.AreEqual("c1ede2e7-e382-11de-8a39-0800200c9a66", propertyElement.Element("objsur").Attribute("guid").Value);
            Assert.Throws <ArgumentException>(() => dtoRepos.GetDTO("5aedaa5f-6f71-4859-953b-a9bb1b78a813"));
            // Atomic reference prop
            dto             = dtoRepos.GetDTO("c1ede2e7-e382-11de-8a39-0800200c9a66");
            element         = XElement.Parse(dto.Xml);
            propertyElement = element.Element("StemName");
            Assert.AreEqual(1, propertyElement.Elements().Count());
            Assert.AreEqual("c1ede2e4-e382-11de-8a39-0800200c9a66", propertyElement.Element("objsur").Attribute("guid").Value);

            // Step 3.
            Assert.Throws <ArgumentException>(() => dtoRepos.GetDTO("003018c0-eba6-43b7-b6e2-5a71ac049f6a"));
            Assert.Throws <ArgumentException>(() => dtoRepos.GetDTO("d06d329f-9dc5-4c1c-aecd-b447cd010bdb"));
            Assert.Throws <ArgumentException>(() => dtoRepos.GetDTO("968caa2b-fae0-479a-9f4a-45d2c6827aa5"));
            Assert.Throws <ArgumentException>(() => dtoRepos.GetDTO("7a62eb69-4738-4514-a94e-b29237d5c188"));

            // Step 4.
            dto             = dtoRepos.AllInstancesSansSubclasses("LexEntry").First();
            element         = XElement.Parse(dto.Xml);
            propertyElement = element.Element("MorphoSyntaxAnalyses");
            Assert.AreEqual(1, propertyElement.Elements().Count());
            Assert.AreEqual("c1ede2e5-e382-11de-8a39-0800200c9a66", propertyElement.Element("objsur").Attribute("guid").Value);
            Assert.Throws <ArgumentException>(() => dtoRepos.GetDTO("c1ede2e6-e382-11de-8a39-0800200c9a66"));
            Assert.Throws <ArgumentException>(() => dtoRepos.GetDTO("304b0aea-dccd-4865-9fad-923e89871b7e"));

            Assert.AreEqual(7000061, dtoRepos.CurrentModelVersion, "Wrong updated version.");
        }
コード例 #28
0
        public void DataMigration7000003Test()
        {
            var dtos = new HashSet <DomainObjectDTO>();
            var sb   = new StringBuilder();

            // 1. Add barebones LP.
            sb.Append("<rt class=\"LangProject\" guid=\"9719A466-2240-4DEA-9722-9FE0746A30A6\">");
            sb.Append("<LangProject>");
            sb.Append("<TranslatedScripture>");
            sb.Append("<objsur guid=\"2c5c1f5f-1f08-41d7-99fe-23893ee4ceef\" t=\"o\" />");
            sb.Append("</TranslatedScripture>");
            sb.Append("</LangProject>");
            sb.Append("</rt>");
            var lpDto = new DomainObjectDTO("9719A466-2240-4DEA-9722-9FE0746A30A6",
                                            "LangProject",
                                            sb.ToString());

            dtos.Add(lpDto);

            // 2. Add Scripture
            sb = new StringBuilder();
            sb.Append("<rt class=\"Scripture\" guid=\"2c5c1f5f-1f08-41d7-99fe-23893ee4ceef\" ownerguid=\"9719A466-2240-4DEA-9722-9FE0746A30A6\" owningflid=\"6001040\" owningord=\"0\">");
            sb.Append("<Scripture>");
            sb.Append("<Books>");
            sb.Append("<objsur guid=\"f213db11-7007-4a2f-9b94-06d6c96014ca\" t=\"o\" />");
            sb.Append("</Books>");
            sb.Append("</Scripture>");
            sb.Append("</rt>");
            var scrDto = new DomainObjectDTO("2c5c1f5f-1f08-41d7-99fe-23893ee4ceef",
                                             "Scripture",
                                             sb.ToString());

            dtos.Add(scrDto);

            // 3. Add a ScrBook
            sb = new StringBuilder();
            sb.Append("<rt class=\"ScrBook\" guid=\"f213db11-7007-4a2f-9b94-06d6c96014ca\" ownerguid=\"2c5c1f5f-1f08-41d7-99fe-23893ee4ceef\" owningflid=\"3001001\" owningord=\"0\">");
            sb.Append("<ScrBook>");
            sb.Append("<Name>");
            sb.Append("<AUni ws=\"fr\">Genesis</AUni>");
            sb.Append("</Name>");
            sb.Append("<Footnotes>");
            var footnoteGuids = new StTextAndParaInfo("StFootnote", "f213db11-7007-4a2f-9b94-06d6c96014ca", "Title Main");

            sb.Append("<objsur guid=\"" + footnoteGuids.textGuid + "\" t=\"o\" />");
            sb.Append("</Footnotes>");
            sb.Append("</ScrBook>");
            sb.Append("</rt>");
            var bookDto = new DomainObjectDTO("f213db11-7007-4a2f-9b94-06d6c96014ca",
                                              "ScrBook",
                                              sb.ToString());

            dtos.Add(bookDto);
            // Add footnote
            var footnoteDto = new DomainObjectDTO(footnoteGuids.textGuid.ToString(),
                                                  "StFootnote",
                                                  footnoteGuids.textXml);

            dtos.Add(footnoteDto);
            // Footnote para
            var footnoteParaDto = new DomainObjectDTO(footnoteGuids.paraGuid.ToString(),
                                                      "StTxtPara",
                                                      footnoteGuids.paraXml);

            dtos.Add(footnoteParaDto);

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

            mockMDC.AddClass(1, "CmObject", null, new List <string> {
                "LangProject", "StText",
                "Scripture", "ScrBook", "StPara"
            });
            mockMDC.AddClass(2, "LangProject", "CmObject", new List <string>());
            mockMDC.AddClass(3, "StText", "CmObject", new List <string> {
                "StFootnote"
            });
            mockMDC.AddClass(4, "Scripture", "CmObject", new List <string>());
            mockMDC.AddClass(5, "ScrBook", "CmObject", new List <string>());
            mockMDC.AddClass(6, "StFootnote", "CmObject", new List <string> {
                "ScrFootnote"
            });
            mockMDC.AddClass(8, "StTxtPara", "CmObject", new List <string> {
                "ScrTxtPara"
            });
            mockMDC.AddClass(9, "ScrFootnote", "CmObject", new List <string>());
            mockMDC.AddClass(10, "ScrTxtPara", "CmObject", new List <string>());
            mockMDC.AddClass(11, "StPara", "CmObject", new List <string> {
                "StTxtPara"
            });
            IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000002, dtos, mockMDC, null,
                                                                                TestDirectoryFinder.LcmDirectories);

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

            // Check the footnote to make sure it is the correct class
            XElement footnoteElement = XElement.Parse(footnoteDto.Xml);

            Assert.AreEqual("ScrFootnote", footnoteDto.Classname, "Oops. Class was not changed.");
            Assert.AreEqual("ScrFootnote", footnoteElement.Attribute("class").Value, "Oops. Class was not changed.");
            Assert.IsNotNull(footnoteElement.Element("ScrFootnote"));
            Assert.IsTrue(footnoteElement.Element("ScrFootnote").IsEmpty);
        }
コード例 #29
0
        public void DataMigration7000030Test()
        {
            //Bring in data from xml file.
            var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000030.xml");

            //Now create all the Mock classes for the classes in my test data.
            //eg LangProject base class is CmProject which has a base class of CmObject
            //eg LexEntry base class is CmObject
            var mockMDC = new MockMDCForDataMigration();

            mockMDC.AddClass(1, "CmObject", null, new List <string>
            {
                "CmProject",
                "CmMajorObject",
                "LexEntry",
                "LexSense",
                "CmPicture",
                "CmFolder",
                "CmFile",
                "CmPossibility",
                "StText",
                "StPara"
            });
            mockMDC.AddClass(2, "CmProject", "CmObject", new List <string> {
                "LangProject"
            });
            mockMDC.AddClass(3, "LangProject", "CmProject", new List <string>());

            //In the List, put each class in this test which derives from this class.
            mockMDC.AddClass(4, "CmMajorObject", "CmObject", new List <string> {
                "LexDb", "CmPossibilityList"
            });
            mockMDC.AddClass(5, "LexDb", "CmMajorObject", new List <string>());

            mockMDC.AddClass(6, "LexEntry", "CmObject", new List <string>());
            mockMDC.AddClass(7, "LexSense", "CmObject", new List <string>());
            mockMDC.AddClass(8, "CmPicture", "CmObject", new List <string>());
            mockMDC.AddClass(9, "CmFolder", "CmObject", new List <string>());
            mockMDC.AddClass(10, "CmFile", "CmObject", new List <string>());

            //This class CmPossibilityList needs to be in the List of the CmMajorObject class
            mockMDC.AddClass(11, "CmPossibilityList", "CmMajorObject", new List <string>());

            mockMDC.AddClass(12, "CmPossibility", "CmObject", new List <string> {
                "MoMorphType"
            });
            mockMDC.AddClass(13, "MoMorphType", "CmPossibility", new List <string>());

            mockMDC.AddClass(14, "StText", "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(7000029, dtos, mockMDC,
                                                                                @"C:\FwWW\DistFiles\Projects\Sena 3", TestDirectoryFinder.LcmDirectories);


            //Get the Element <rt guid="b8bdad3d-9006-46f0-83e8-ae1d1726f2ad" class="LangProject">
            var langProjDto     = dtoRepos.AllInstancesSansSubclasses("LangProject").First();
            var langProjElement = XElement.Parse(langProjDto.Xml);

            var langProjLinkedFilesRootDir = langProjElement.XPathSelectElement("LinkedFilesRootDir");

            Assert.That(langProjLinkedFilesRootDir, Is.Not.Null, "Before the migration we should have a 'ExtLinkRootDir' element on LangProj");

            var langProjPictures = langProjElement.XPathSelectElement("Pictures");

            Assert.That(langProjPictures, Is.Not.Null, "Before the migration we should have a 'Pictures' element on LangProj");
            var langProjMedia = langProjElement.XPathSelectElement("Media");

            Assert.That(langProjMedia, Is.Not.Null, "Before the migration we should have a 'Media' element on LangProj");
            var langProjFilePathsInTsStrings = langProjElement.XPathSelectElement("FilePathsInTsStrings");

            Assert.That(langProjFilePathsInTsStrings, Is.Null, "Before the migration we should NOT have a 'FilePathsInTsStrings' element on LangProj");

            //Get the Elements  for class="CmFolder"
            var CmFolderDtos = dtoRepos.AllInstancesSansSubclasses("CmFolder");              //should we check for FilePathsInTsStrings CmFolder???

            Assert.True(CmFolderDtos.Count() == 2, "The number of CmFolders should be 2.");
            var CmFolders = new Dictionary <string, HashSet <String> >();

            GetCmFolderNamesAndObjsurs(CmFolderDtos, CmFolders);
            CheckCmFoldersAndCountsBeforeMigration(CmFolders);

            //Get the Elements  for class="CmFile"
            var CmFileDtosBeforeMigration = dtoRepos.AllInstancesSansSubclasses("CmFile");
            //Get all the file paths (as strings) for the CmFile's in the project
            var filesPathsBeforeMigration = new List <String>();

            foreach (var fileDto in CmFileDtosBeforeMigration)
            {
                filesPathsBeforeMigration.Add(GetCmFilePath(fileDto));
            }
            CheckCmFilePathsBeforeMigration(filesPathsBeforeMigration);


            var filesPathsInTsStringsBeforeMigration = GetAllExternalLinksInTsStrings(dtoRepos);

            CheckExternalLinksInTsStringsBeforeMigration(filesPathsInTsStringsBeforeMigration);

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

            //make sure the version was updated.
            Assert.AreEqual(7000030, dtoRepos.CurrentModelVersion, "Wrong updated version.");


            //Make sure all file paths in TsStrings are now corrected if they are relative to LinkedFilesRootDir
            var filesPathsInTsStringsAfterMigration = GetAllExternalLinksInTsStrings(dtoRepos);

            CheckExternalLinksInTsStringsAfterMigration(filesPathsInTsStringsAfterMigration);

            //Now make sure we have a CmFolder called FilePathsInTsStrings as part of LangProject
            langProjDto     = dtoRepos.AllInstancesSansSubclasses("LangProject").First();
            langProjElement = XElement.Parse(langProjDto.Xml);

            langProjPictures = langProjElement.XPathSelectElement("Pictures");
            Assert.That(langProjPictures, Is.Not.Null, "After the migration we should have a 'Pictures' element on LangProj");
            langProjMedia = langProjElement.XPathSelectElement("Media");
            Assert.That(langProjMedia, Is.Not.Null, "After the migration we should have a 'Media' element on LangProj");
            langProjFilePathsInTsStrings = langProjElement.XPathSelectElement("FilePathsInTsStrings");
            Assert.That(langProjFilePathsInTsStrings, Is.Not.Null, "After the migration we should  have a 'FilePathsInTsStrings' element on LangProj");

            //Get the Elements  for class="CmFolder"
            CmFolderDtos = dtoRepos.AllInstancesSansSubclasses("CmFolder");              //should we check for FilePathsInTsStrings CmFolder???
            Assert.True(CmFolderDtos.Count() == 3, "The number of CmFolders should be 3.");


            CmFolders.Clear();
            GetCmFolderNamesAndObjsurs(CmFolderDtos, CmFolders);
            CheckCmFoldersAndCountsAfterMigration(CmFolders);

            //Now check that all the CmFile's have paths which are correct.
            //Get the Elements  for class="CmFile"
            var CmFileDtosAfterMigration = dtoRepos.AllInstancesSansSubclasses("CmFile");

            //Get all the file paths (as strings) for the CmFile's in the project
            var filesPathsAfterMigration  = new List <String>();
            var CmFileGuidsAfterMigration = new List <String>();

            foreach (var fileDto in CmFileDtosAfterMigration)
            {
                filesPathsAfterMigration.Add(GetCmFilePath(fileDto));
                CmFileGuidsAfterMigration.Add(GetCmFileGuid(fileDto));
            }
            CheckCmFilePathsAfterMigration(filesPathsAfterMigration);
            CheckThereIsACmFileForEachGuidInNewCmFolder(CmFolders, CmFileGuidsAfterMigration);
        }
コード例 #30
0
        public void DataMigration7000011Test()
        {
            var dtos = new HashSet <DomainObjectDTO>();
            var sb   = new StringBuilder();

            // 1. Add barebones Notebook.
            sb.Append("<rt class=\"RnResearchNbk\" guid=\"2E237D40-853C-49D5-AAC6-EFF01121AC25\">");
            sb.Append("<RnResearchNbk>");
            sb.Append("<RecTypes><objsur t=\"o\" guid=\"513B370D-8EFC-4C94-8192-7707677A6F98\" /></RecTypes>");
            sb.Append("<Records>");
            sb.Append("<objsur t=\"o\" guid=\"C84B721B-3617-43DE-A436-9E0538837A66\" />");
            sb.Append("</Records>");
            sb.Append("</RnResearchNbk>");
            sb.Append("</rt>");
            var nbkDto = new DomainObjectDTO("2E237D40-853C-49D5-AAC6-EFF01121AC25", "RnResearchNbk", sb.ToString());

            dtos.Add(nbkDto);

            sb = new StringBuilder();
            // 2. Add barebones RecTypes List
            sb.Append("<rt class=\"CmPossibilityList\" guid=\"513B370D-8EFC-4C94-8192-7707677A6F98\" ownerguid=\"2E237D40-853C-49D5-AAC6-EFF01121AC25\">");
            sb.Append("<CmPossibilityList>");
            sb.Append("<Possibilities>");
            sb.Append("<objsur t=\"o\" guid=\"27C32299-3B41-4FAD-A85C-F47657BCF95A\" />");
            sb.Append("<objsur t=\"o\" guid=\"5E3D9C56-404C-44C5-B3CB-99BF390E322E\" />");
            sb.Append("</Possibilities>");
            sb.Append("</CmPossibilityList>");
            sb.Append("</rt>");
            var recTypesDto = new DomainObjectDTO("513B370D-8EFC-4C94-8192-7707677A6F98", "CmPossibilityList", sb.ToString());

            dtos.Add(recTypesDto);

            sb = new StringBuilder();
            // 3. Add barebones Conversation
            sb.Append("<rt class=\"CmPossibility\" guid=\"27C32299-3B41-4FAD-A85C-F47657BCF95A\" ownerguid=\"513B370D-8EFC-4C94-8192-7707677A6F98\">");
            sb.Append("<CmPossibility>");
            sb.Append("<Abbreviation><AUni ws=\"en\">Con</AUni></Abbreviation>");
            sb.Append("</CmPossibility>");
            sb.Append("</rt>");
            var conDto = new DomainObjectDTO("27C32299-3B41-4FAD-A85C-F47657BCF95A", "CmPossibility", sb.ToString());

            dtos.Add(conDto);

            sb = new StringBuilder();
            // 4. Add barebones Observation
            sb.Append("<rt class=\"CmPossibility\" guid=\"5E3D9C56-404C-44C5-B3CB-99BF390E322E\" ownerguid=\"513B370D-8EFC-4C94-8192-7707677A6F98\">");
            sb.Append("<CmPossibility>");
            sb.Append("<Abbreviation><AUni ws=\"en\">Obs</AUni></Abbreviation>");
            sb.Append("<SubPossibilities>");
            sb.Append("<objsur t=\"o\" guid=\"9827CBE0-31F3-434E-80F7-5D5354C110B0\" />");
            sb.Append("</SubPossibilities>");
            sb.Append("</CmPossibility>");
            sb.Append("</rt>");
            var obsDto = new DomainObjectDTO("5E3D9C56-404C-44C5-B3CB-99BF390E322E", "CmPossibility", sb.ToString());

            dtos.Add(obsDto);

            sb = new StringBuilder();
            // 5. Add barebones Performance
            sb.Append("<rt class=\"CmPossibility\" guid=\"9827CBE0-31F3-434E-80F7-5D5354C110B0\" ownerguid=\"5E3D9C56-404C-44C5-B3CB-99BF390E322E\">");
            sb.Append("<CmPossibility>");
            sb.Append("<Abbreviation><AUni ws=\"en\">Per</AUni></Abbreviation>");
            sb.Append("</CmPossibility>");
            sb.Append("</rt>");
            var perDto = new DomainObjectDTO("9827CBE0-31F3-434E-80F7-5D5354C110B0", "CmPossibility", sb.ToString());

            dtos.Add(perDto);

            sb = new StringBuilder();
            // 6. Add barebones RnGenericRec
            sb.Append("<rt class=\"RnGenericRec\" guid=\"c84b721b-3617-43de-a436-9e0538837a66\" ownerguid=\"2E237D40-853C-49D5-AAC6-EFF01121AC25\">");
            sb.Append("<RnGenericRec>");
            sb.Append("<Type><objsur guid=\"27c32299-3b41-4fad-a85c-f47657bcf95a\" t=\"r\" /></Type>");
            sb.Append("</RnGenericRec>");
            sb.Append("</rt>");
            var recDto = new DomainObjectDTO("c84b721b-3617-43de-a436-9e0538837a66", "RnGenericRec", sb.ToString());

            dtos.Add(recDto);

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

            mockMDC.AddClass(1, "CmObject", null, new List <string> {
                "RnResearchNbk", "CmPossibilityList", "CmPossibility", "RnGenericRec"
            });
            mockMDC.AddClass(2, "RnResearchNbk", "CmObject", new List <string>());
            mockMDC.AddClass(3, "CmPossibilityList", "CmObject", new List <string>());
            mockMDC.AddClass(4, "CmPossibility", "CmObject", new List <string>());
            mockMDC.AddClass(5, "RnGenericRec", "CmObject", new List <string>());
            IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000010, dtos, mockMDC, null,
                                                                                TestDirectoryFinder.LcmDirectories);

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

            XElement nbkElem = XElement.Parse(nbkDto.Xml);

            Assert.AreEqual("D9D55B12-EA5E-11DE-95EF-0013722F8DEC",
                            (string)nbkElem.XPathSelectElement("RnResearchNbk/RecTypes/objsur").Attribute("guid"));

            DataMigrationTestServices.CheckDtoRemoved(dtoRepos, recTypesDto);
            recTypesDto = dtoRepos.GetDTO("D9D55B12-EA5E-11DE-95EF-0013722F8DEC");
            XElement        recTypesElem = XElement.Parse(recTypesDto.Xml);
            List <XElement> objSurElems  = recTypesElem.XPathSelectElements("CmPossibilityList/Possibilities/objsur").ToList();

            Assert.AreEqual(2, objSurElems.Count);
            Assert.AreEqual("B7B37B86-EA5E-11DE-80E9-0013722F8DEC", (string)objSurElems[0].Attribute("guid"));
            Assert.AreEqual("B7EA5156-EA5E-11DE-9F9C-0013722F8DEC", (string)objSurElems[1].Attribute("guid"));

            DataMigrationTestServices.CheckDtoRemoved(dtoRepos, conDto);
            conDto = dtoRepos.GetDTO("B7B37B86-EA5E-11DE-80E9-0013722F8DEC");
            XElement conElem = XElement.Parse(conDto.Xml);

            Assert.AreEqual("Con", (string)conElem.XPathSelectElement("CmPossibility/Abbreviation/AUni[@ws='en']"));
            Assert.AreEqual("D9D55B12-EA5E-11DE-95EF-0013722F8DEC", (string)conElem.Attribute("ownerguid"));

            DataMigrationTestServices.CheckDtoRemoved(dtoRepos, obsDto);
            obsDto = dtoRepos.GetDTO("B7EA5156-EA5E-11DE-9F9C-0013722F8DEC");
            XElement obsElem = XElement.Parse(obsDto.Xml);

            Assert.AreEqual("Obs", (string)obsElem.XPathSelectElement("CmPossibility/Abbreviation/AUni[@ws='en']"));
            Assert.AreEqual("B7F63D0E-EA5E-11DE-9F02-0013722F8DEC",
                            (string)obsElem.XPathSelectElement("CmPossibility/SubPossibilities/objsur").Attribute("guid"));
            Assert.AreEqual("D9D55B12-EA5E-11DE-95EF-0013722F8DEC", (string)obsElem.Attribute("ownerguid"));

            DataMigrationTestServices.CheckDtoRemoved(dtoRepos, perDto);
            perDto = dtoRepos.GetDTO("B7F63D0E-EA5E-11DE-9F02-0013722F8DEC");
            XElement perElem = XElement.Parse(perDto.Xml);

            Assert.AreEqual("Per", (string)perElem.XPathSelectElement("CmPossibility/Abbreviation/AUni[@ws='en']"));
            Assert.AreEqual("B7EA5156-EA5E-11DE-9F9C-0013722F8DEC", (string)perElem.Attribute("ownerguid"));

            XElement recElem = XElement.Parse(recDto.Xml);

            Assert.AreEqual("B7B37B86-EA5E-11DE-80E9-0013722F8DEC", (string)recElem.XPathSelectElement("RnGenericRec/Type/objsur").Attribute("guid"));
        }