public void DataMigration7000042TestD() { // Bring in data from xml file. var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000042D.xml"); // Create the DTO repository, do the migration, and verify the results. VerifyMigration(dtos); }
public void DataMigration7000014Test() { var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000014_Evaluations.xml"); var mockMDC = SetupMDC(); IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000013, dtos, mockMDC, null, TestDirectoryFinder.LcmDirectories); // SUT; Do the migration. m_dataMigrationManager.PerformMigration(dtoRepos, 7000014, new DummyProgressDlg()); // Verification Phase Assert.AreEqual(7000014, dtoRepos.CurrentModelVersion, "Wrong updated version."); // var firstAgent = dtoRepos.GetDTO("c1ec8357-e382-11de-8a39-0800200c9a66"); var secondAgent = dtoRepos.GetDTO("c1ec8357-e382-11de-8a39-0800200c9a67"); var thirdAgent = dtoRepos.GetDTO("c1ec8357-e382-11de-8a39-0800200c9a68"); var emptyAgent = dtoRepos.GetDTO("c1ec8357-e382-11de-8a39-0800200c9a6c"); var firstAnalysis = dtoRepos.GetDTO("c84614e6-168b-4304-a025-0d6ae6573086"); var secondAnalysis = dtoRepos.GetDTO("c84614e6-168b-4304-a025-0d6ae6573087"); string firstApprovesGuid, firstDisapprovesGuid, secondApprovesGuid, secondDisapprovesGuid, thirdApprovesGuid, thirdDisapprovesGuid, emptyApprovesGuid, emptyDisapprovesGuid; VerifyAgent(firstAgent, dtoRepos, out firstApprovesGuid, out firstDisapprovesGuid); VerifyAgent(secondAgent, dtoRepos, out secondApprovesGuid, out secondDisapprovesGuid); VerifyAgent(thirdAgent, dtoRepos, out thirdApprovesGuid, out thirdDisapprovesGuid); VerifyAgent(emptyAgent, dtoRepos, out emptyApprovesGuid, out emptyDisapprovesGuid); VerifyAnalysis(firstAnalysis, new string[] { firstApprovesGuid, secondDisapprovesGuid, thirdApprovesGuid }); VerifyAnalysis(secondAnalysis, new string[] { firstApprovesGuid }); var goners = ((DomainObjectDtoRepository)dtoRepos).Goners; Assert.AreEqual(4, goners.Count, "Wrong number removed."); var gonerGuids = new List <string> { ("c84614e6-168b-4304-a025-0d6ae6573085").ToLower(), ("c84614e6-168b-4304-a025-0d6ae6573088").ToLower(), ("8151a002-a32e-476f-9c32-f95ee48fc71c").ToLower(), ("c84614e6-168b-4304-a025-0d6ae657308a").ToLower() }; foreach (var goner in goners) { Assert.Contains(goner.Guid.ToLower(), gonerGuids, "Goner guid not found."); } }
public void DataMigration7000037Test() { // Bring in data from xml file. var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000037.xml"); // Create all the Mock classes for the classes in my test data. var mockMDC = new MockMDCForDataMigration(); mockMDC.AddClass(1, "CmObject", null, new List <string> { "LexSense", "StPara" }); mockMDC.AddClass(7, "LexSense", "CmObject", new List <string>()); mockMDC.AddClass(15, "StPara", "CmObject", new List <string> { "StTxtPara" }); mockMDC.AddClass(16, "StTxtPara", "StPara", new List <string>()); IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000036, dtos, mockMDC, FileUtils.ChangePathToPlatform("C:\\WW\\DistFiles\\Projects\\TokPisin"), TestDirectoryFinder.LcmDirectories); // Check that the version is correct. Assert.AreEqual(7000036, dtoRepos.CurrentModelVersion, "Wrong original version."); // Collect the link values that shouldn't change. m_cLinks = 0; CollectionNonSilfwLinks(dtoRepos); int cLinksOrig = m_cLinks; Assert.AreEqual(12, m_cLinks, "Should have 12 externalLink attributes in the test data"); // Do Migration m_dataMigrationManager.PerformMigration(dtoRepos, 7000037, new DummyProgressDlg()); // Check that the version was updated. Assert.AreEqual(7000037, dtoRepos.CurrentModelVersion, "Wrong updated version."); // Check that all externalLink values are reasonable, and that we find the right // number of them. m_cLinks = 0; foreach (var dto in dtoRepos.AllInstancesWithValidClasses()) { string xml = dto.Xml; Assert.IsTrue(xml.Contains("externalLink"), "Every object in the test has an externalLink"); var dtoXML = XElement.Parse(xml); foreach (var run in dtoXML.XPathSelectElements("//Run")) { var externalLinkAttr = run.Attribute("externalLink"); if (externalLinkAttr != null) { CheckForValidLinkValue(externalLinkAttr.Value); ++m_cLinks; } } } Assert.AreEqual(cLinksOrig, m_cLinks, "Migration should not change the number of externalLink attributes"); }
public void AllRegularBasicDataPropertiesExistAfterDataMigration66() { var mockMdc = new MockMDCForDataMigration(); mockMdc.AddClass(1, "CmObject", null, new List <string> { "RegularPropertyMagnet" }); mockMdc.AddClass(2, "RegularPropertyMagnet", "CmObject", new List <string>()); // These are all present in the original data file and act as controls. // They should not be changed. var currentFlid = 2000; mockMdc.AddField(++currentFlid, "ExtantOwningAtomic", CellarPropertyType.OwningAtom, 2); mockMdc.AddField(++currentFlid, "ExtantBooleanProperty", CellarPropertyType.Boolean, 0); mockMdc.AddField(++currentFlid, "ExtantGenDateProperty", CellarPropertyType.GenDate, 0); mockMdc.AddField(++currentFlid, "ExtantGuidProperty", CellarPropertyType.Guid, 0); // Not used in model yet (as of 23 march 2013) mockMdc.AddField(++currentFlid, "ExtantFloatProperty", CellarPropertyType.Float, 0); mockMdc.AddField(++currentFlid, "ExtantIntegerProperty", CellarPropertyType.Integer, 0); // Not used in model yet (as of 23 march 2013) var mockMdc.AddField(++currentFlid, "ExtantNumericProperty", CellarPropertyType.Numeric, 0); mockMdc.AddField(++currentFlid, "ExtantTimeProperty", CellarPropertyType.Time, 0); // These are all missing in the original data file. // They should all end up with the default values for the given type of data. mockMdc.AddField(++currentFlid, "NewBooleanProperty", CellarPropertyType.Boolean, 0); mockMdc.AddField(++currentFlid, "NewGenDateProperty", CellarPropertyType.GenDate, 0); mockMdc.AddField(++currentFlid, "NewGuidProperty", CellarPropertyType.Guid, 0); // Not used in model yet (as of 23 march 2013) mockMdc.AddField(++currentFlid, "NewFloatProperty", CellarPropertyType.Float, 0); mockMdc.AddField(++currentFlid, "NewIntegerProperty", CellarPropertyType.Integer, 0); // Not used in model yet (as of 23 march 2013) mockMdc.AddField(++currentFlid, "NewNumericProperty", CellarPropertyType.Numeric, 0); mockMdc.AddField(++currentFlid, "NewTimeProperty", CellarPropertyType.Time, 0); var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000066_RegularPropertyMagnet.xml"); IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000065, dtos, mockMdc, null, TestDirectoryFinder.LcmDirectories); m_dataMigrationManager.PerformMigration(dtoRepos, 7000066, new DummyProgressDlg()); var magnet = XElement.Parse(dtoRepos.AllInstancesSansSubclasses("RegularPropertyMagnet").First().Xml); // Check the 'control' props to make sure they were not changed. Assert.AreEqual("e268fe80-5d9d-4f6b-a68f-37db8218b15d", magnet.Element("ExtantOwningAtomic").Element("objsur").Attribute("guid").Value); Assert.AreEqual("True", GetRegularPropertyValue(magnet, "ExtantBooleanProperty")); Assert.AreEqual("-201303233", GetRegularPropertyValue(magnet, "ExtantGenDateProperty")); Assert.AreEqual("c1ee311b-e382-11de-8a39-0800200c9a66", GetRegularPropertyValue(magnet, "ExtantGuidProperty")); Assert.AreEqual("1", GetRegularPropertyValue(magnet, "ExtantIntegerProperty")); Assert.AreEqual("2006-3-12 18:19:46.87", GetRegularPropertyValue(magnet, "ExtantTimeProperty")); // Check the newly added props to make sure they are present and using default values. Assert.AreEqual("False", GetRegularPropertyValue(magnet, "NewBooleanProperty")); Assert.AreEqual("-000000000", GetRegularPropertyValue(magnet, "NewGenDateProperty")); Assert.AreEqual(Guid.Empty.ToString(), GetRegularPropertyValue(magnet, "NewGuidProperty")); Assert.AreEqual("0", GetRegularPropertyValue(magnet, "NewIntegerProperty")); Assert.IsNotNull(GetRegularPropertyValue(magnet, "NewTimeProperty")); }
public void PerformMigration7000018() { var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000018.xml"); var mockMdc = SetupMdc(); IDomainObjectDTORepository repoDTO = new DomainObjectDtoRepository(7000017, dtos, mockMdc, null, TestDirectoryFinder.LcmDirectories); // SUT: Do the migration. m_dataMigrationManager.PerformMigration(repoDTO, 7000018, new DummyProgressDlg()); // Verification Phase Assert.AreEqual(7000018, repoDTO.CurrentModelVersion, "Wrong updated version."); DomainObjectDTO dtoLP = null; foreach (DomainObjectDTO dto in repoDTO.AllInstancesSansSubclasses("LangProject")) { Assert.IsNull(dtoLP, "Only one Language Project object should exist"); dtoLP = dto; } Assert.NotNull(dtoLP, "The Language Project object should exist"); DomainObjectDTO dtoNtbk = null; foreach (DomainObjectDTO dto in repoDTO.AllInstancesSansSubclasses("RnResearchNbk")) { Assert.IsNull(dtoNtbk, "Only one Data Notebook object should exist"); dtoNtbk = dto; } Assert.NotNull(dtoNtbk, "The Data Notebook object should exist"); DomainObjectDTO dtoLexDb = null; foreach (DomainObjectDTO dto in repoDTO.AllInstancesSansSubclasses("LexDb")) { Assert.IsNull(dtoLexDb, "Only one Lexical Database object should exist"); dtoLexDb = dto; } Assert.NotNull(dtoLexDb, "The Lexical Database object should exist"); string sLexDbXml = dtoLexDb.Xml; Assert.False(sLexDbXml.Contains("<Styles>"), "The Styles field should be gone from the Lexical Database object"); string sLpXml = dtoLP.Xml; Assert.True(sLpXml.Contains("<Styles>"), "The Styles field should still exist in the Language Project object"); VerifyStylesRenamedOrDeleted(repoDTO); VerifyStyleReferencesUpdated(repoDTO); VerifyScriptureStylesUnchanged(repoDTO); VerifyNoDirectFormatting(repoDTO); }
public void DataMigration7000062Test() { var mockMdc = new MockMDCForDataMigration(); mockMdc.AddClass(1, "CmObject", null, new List <string> { "LangProject", "StStyle", "CmResource" }); mockMdc.AddClass(2, "LangProject", "CmObject", new List <string>()); mockMdc.AddClass(3, "StStyle", "CmObject", new List <string>()); mockMdc.AddClass(4, "CmResource", "CmObject", new List <string>()); var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000062.xml"); IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000061, dtos, mockMdc, null, TestDirectoryFinder.LcmDirectories); m_dataMigrationManager.PerformMigration(dtoRepos, 7000062, new DummyProgressDlg()); // Check Step 1.A. // <rt class="StStyle" guid ="bb68f6bc-f233-4cd4-8894-c33b4b4c43ba"> DomainObjectDTO dto; dtoRepos.TryGetValue("bb68f6bc-f233-4cd4-8894-c33b4b4c43ba", out dto); Assert.IsNull(dto); // Step 1.A. Control // <rt class="StStyle" guid ="9d28219c-6185-416e-828b-b9e304de141c" ownerguid="88ddebd1-dfad-4033-8b1c-896081469f66"> dtoRepos.TryGetValue("9d28219c-6185-416e-828b-b9e304de141c", out dto); Assert.IsNotNull(dto); // Check Step 1.B. (Real + control) foreach (var resourceDto in dtoRepos.AllInstancesSansSubclasses("CmResource")) { var resourceElement = XElement.Parse(resourceDto.Xml); var name = resourceElement.Element("Name").Element("Uni").Value; var actualVersion = resourceElement.Element("Version").Attribute("val").Value; var expectedVersion = ""; switch (name) { case "TeStyles": expectedVersion = "700176e1-4f42-4abd-8fb5-3c586670085d"; break; case "FlexStyles": expectedVersion = "13c213b9-e409-41fc-8782-7ca0ee983b2c"; break; case "ControlResource": expectedVersion = "c1ede2e2-e382-11de-8a39-0800200c9a66"; break; } Assert.AreEqual(expectedVersion, actualVersion); } Assert.AreEqual(7000062, dtoRepos.CurrentModelVersion, "Wrong updated version."); }
public void DataMigration7000056Test() { var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000056.xml"); // Set up mock MDC. var mockMDC = new MockMDCForDataMigration(); IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000055, dtos, mockMDC, null, TestDirectoryFinder.LcmDirectories); m_dataMigrationManager.PerformMigration(dtoRepos, 7000056, new DummyProgressDlg()); Assert.AreEqual(7000056, dtoRepos.CurrentModelVersion, "Wrong updated version."); // check that PhPhonData has the PhonRuleFeats possibility list { var dtosList = dtoRepos.AllInstancesSansSubclasses("PhPhonData"); DomainObjectDTO dtoPhPhonDataTest = dtosList.First(); CheckPhPhonData(dtoPhPhonDataTest, dtoRepos); } // In the extremely unlikely event that there is no PhPhonData yet, check that we add it { dtos = new HashSet <DomainObjectDTO>(); var sb = new StringBuilder(); // Add WfiMorphBundle that already has a form. const string sGuid_wmbLangProj = "00b35f9f-86ce-4f07-bde7-b65c28503641"; sb.AppendFormat("<rt class=\"LangProj\" guid=\"{0}\">", sGuid_wmbLangProj); sb.Append("</rt>"); var dtoLangProj = new DomainObjectDTO(sGuid_wmbLangProj, "LangProj", sb.ToString()); dtos.Add(dtoLangProj); sb.Length = 0; mockMDC = new MockMDCForDataMigration(); dtoRepos = new DomainObjectDtoRepository(7000055, dtos, mockMDC, null, TestDirectoryFinder.LcmDirectories); m_dataMigrationManager.PerformMigration(dtoRepos, 7000056, new DummyProgressDlg()); Assert.AreEqual(7000056, dtoRepos.CurrentModelVersion, "Wrong updated version."); var dtosList = dtoRepos.AllInstancesSansSubclasses("LangProj"); DomainObjectDTO dtoLangProjTest = dtosList.First(); var eltWmbLangProjTest = XElement.Parse(dtoLangProjTest.Xml); // get phon rule feats var eltPhonologicalDataTest = eltWmbLangProjTest.Element("PhonologicalData"); Assert.IsNotNull(eltPhonologicalDataTest); var eltObjsurTest = eltPhonologicalDataTest.Element("objsur"); Assert.IsNotNull(eltObjsurTest); // get possibility list itself var guidPhPhonDataTest = eltObjsurTest.Attribute("guid").Value; Assert.IsNotNull(guidPhPhonDataTest); DomainObjectDTO dtoPhPhonDataTest; dtoRepos.TryGetValue(guidPhPhonDataTest, out dtoPhPhonDataTest); Assert.IsNotNull(dtoPhPhonDataTest); CheckPhPhonData(dtoPhPhonDataTest, dtoRepos); } }
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) }
public void DataMigration7000057Test_SubInflTypes() { var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000057_SubInflTypes.xml"); // Set up mock MDC. var mockMdc = new MockMDCForDataMigration(); IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000056, dtos, mockMdc, null, TestDirectoryFinder.LcmDirectories); m_dataMigrationManager.PerformMigration(dtoRepos, 7000057, new DummyProgressDlg()); Assert.AreEqual(7000057, dtoRepos.CurrentModelVersion, "Wrong updated version."); const string guidNonStandard = "1df6f9da-7b69-44e4-b98d-13a0cee17b77"; const string guidNonStandardChild = "208cc589-f10f-485b-bdcc-843f046d4146"; const string guidPluralChild = "2bd3437f-8bde-495c-a12b-d0c8feb7c3e9"; const string guidPastChild = "7c607ea9-c1a0-4b7f-aee7-06ead42ac299"; // test that non-standard (user created) Irregularly Inflected Form has the right class { var nonStandard = dtoRepos.GetDTO(guidNonStandard); Assert.That(nonStandard.Classname, Is.EqualTo(LexEntryInflTypeTags.kClassName)); var nonStandardElt = XElement.Parse(nonStandard.Xml); Assert.That(nonStandardElt.XPathSelectElement("Name/AUni").Value, Is.EqualTo("NonStandard")); } // test that non-standard child has correct class { var nonStandardChild = dtoRepos.GetDTO(guidNonStandardChild); Assert.That(nonStandardChild.Classname, Is.EqualTo(LexEntryInflTypeTags.kClassName)); var nonStandardChildElt = XElement.Parse(nonStandardChild.Xml); Assert.That(nonStandardChildElt.XPathSelectElement("Name/AUni").Value, Is.EqualTo("NonStandardChild")); } // test that plural child has correct class { var varTypePluralChild = dtoRepos.GetDTO(guidPluralChild); Assert.That(varTypePluralChild.Classname, Is.EqualTo(LexEntryInflTypeTags.kClassName)); var varTypePluralChildElt = XElement.Parse(varTypePluralChild.Xml); Assert.That(varTypePluralChildElt.XPathSelectElement("Name/AUni").Value, Is.EqualTo("PluralChild")); } // test that past child has correct class { var varTypePastChild = dtoRepos.GetDTO(guidPastChild); Assert.That(varTypePastChild.Classname, Is.EqualTo(LexEntryInflTypeTags.kClassName)); var varTypePastChildElt = XElement.Parse(varTypePastChild.Xml); Assert.That(varTypePastChildElt.XPathSelectElement("Name/AUni").Value, Is.EqualTo("PastChild")); } }
public void DataMigration7000072Test() { var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000072.xml"); var mockMdc = new MockMDCForDataMigration(); IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000071, dtos, mockMdc, null, TestDirectoryFinder.LcmDirectories); m_dataMigrationManager.PerformMigration(dtoRepos, 7000072, new DummyProgressDlg()); // Test to Check whether the given Reversal Index Entry has the added senses // Get the Reversal Index Entry with the specified guid var aReversalIndexEntry = dtoRepos.GetDTO("2d1fb89c-5671-43de-8cdd-4624f4648ef4"); var reversalIndexElement = XElement.Parse(aReversalIndexEntry.Xml); // Check for the Senses Tag var sensesElement = reversalIndexElement.Element("Senses"); Assert.NotNull(sensesElement, "No senses‽"); var objsurElementsList = sensesElement.Elements("objsur"); var guidList = new ArrayList(); foreach (var objsurElement in objsurElementsList) { guidList.Add(objsurElement.Attribute("guid")?.Value); } Assert.AreEqual(guidList[0], "c836e945-92d3-4560-9622-bfd9656551c8"); Assert.AreEqual(guidList[1], "d3d19eae-d840-484e-8de2-0100336808ed"); // Test to check whether Reversal Entries collection has been removed from LexSense var allLexSenses = dtoRepos.AllInstancesWithSubclasses("LexSense"); foreach (var aLexSense in allLexSenses) { var lexSenseElement = XElement.Parse(aLexSense.Xml); var reveralEntriesElement = lexSenseElement.Element("ReversalEntries"); Assert.AreEqual(reveralEntriesElement, null); } // Test to check whether the Referring Senses value has been changed to Senses under VirtualOrdering var allOrderings = dtoRepos.AllInstancesWithSubclasses("VirtualOrdering"); foreach (var anOrdering in allOrderings) { var orderingElement = XElement.Parse(anOrdering.Xml); var field = orderingElement.Element("Field"); Assert.NotNull(field, "field should not be null"); var uniValue = field.Element("Uni"); Assert.NotNull(uniValue, "uniValue should not be null"); Assert.AreEqual("Senses", uniValue.Value); } }
private static IDomainObjectDTORepository DoCommonBasics(IEnumerable <string> extraDataFiles) { var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000013_CommonData.xml"); foreach (var extraDataFile in extraDataFiles) { dtos.UnionWith(DataMigrationTestServices.ParseProjectFile(extraDataFile)); } var mockMDC = SetupMDC(); IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000012, dtos, mockMDC, null, TestDirectoryFinder.LcmDirectories); return(dtoRepos); }
public void DataMigration7000057Test_Normal() { var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000057_Normal.xml"); // Set up mock MDC. var mockMdc = new MockMDCForDataMigration(); IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000056, dtos, mockMdc, null, TestDirectoryFinder.LcmDirectories); m_dataMigrationManager.PerformMigration(dtoRepos, 7000057, new DummyProgressDlg()); Assert.AreEqual(7000057, dtoRepos.CurrentModelVersion, "Wrong updated version."); // check that Irregularly Inflected Form Type has new class { var iifNew = dtoRepos.GetDTO(kguidLexTypIrregInflectionVar); Assert.That(iifNew.Classname, Is.EqualTo(LexEntryInflTypeTags.kClassName)); var iifNewElt = XElement.Parse(iifNew.Xml); Assert.That(iifNewElt.XPathSelectElement("Name/AUni").Value, Is.EqualTo("Irregularly Inflected Form")); } // check that we haven't changed another owned object class { // Discussion for Irregularly Inflected Form Type var iifDiscussion = dtoRepos.GetDTO("b6f4c056-ea5e-11de-8a9c-0013722f8dec"); Assert.That(iifDiscussion.Classname, Is.EqualTo(StTextTags.kClassName)); } // check that Irregularly Inflected Form Type (Plural) has new class { var iifNewPlural = dtoRepos.GetDTO(kguidLexTypPluralVar); Assert.That(iifNewPlural, Is.Not.Null); Assert.That(iifNewPlural.Classname, Is.EqualTo(LexEntryInflTypeTags.kClassName)); var iifNewPluralElt = XElement.Parse(iifNewPlural.Xml); Assert.That(iifNewPluralElt.XPathSelectElement("Name/AUni").Value, Is.EqualTo("Plural")); } // check that Irregularly Inflected Form Type (Past) has new class { var iifNewPast = dtoRepos.GetDTO(kguidLexTypPastVar); Assert.That(iifNewPast, Is.Not.Null); Assert.That(iifNewPast.Classname, Is.EqualTo(LexEntryInflTypeTags.kClassName)); var iifNewPastElt = XElement.Parse(iifNewPast.Xml); Assert.That(iifNewPastElt.XPathSelectElement("Name/AUni").Value, Is.EqualTo("Past")); } }
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); }
public void DataMigration7000020Test() { var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000020.xml"); IFwMetaDataCacheManaged mockMdc = SetupMdc(); IDomainObjectDTORepository repoDto = new DomainObjectDtoRepository(7000019, dtos, mockMdc, Path.GetTempPath(), TestDirectoryFinder.LcmDirectories); // Initial check that data was read properly. var cObjects = repoDto.AllInstances().Count(); Assert.AreEqual(378, cObjects, "Before migrating, should be 378 objects"); var cLangProject = repoDto.AllInstancesSansSubclasses("LangProject").Count(); Assert.AreEqual(1, cLangProject, "Before migrating, should be 1 LangProject object"); var cUserView = repoDto.AllInstancesSansSubclasses("UserView").Count(); Assert.AreEqual(17, cUserView, "Before migrating, should be 17 UserView objects"); var cUserViewRec = repoDto.AllInstancesSansSubclasses("UserViewRec").Count(); Assert.AreEqual(31, cUserViewRec, "Before migrating, should be 31 UserViewRec objects"); var cUserViewField = repoDto.AllInstancesSansSubclasses("UserViewField").Count(); Assert.AreEqual(329, cUserViewField, "Before migrating, should be 329 UserViewField objects"); // Do the migration. m_dataMigrationManager.PerformMigration(repoDto, 7000020, new DummyProgressDlg()); // Verification Phase Assert.AreEqual(7000020, repoDto.CurrentModelVersion, "Wrong updated version."); cObjects = repoDto.AllInstances().Count(); Assert.AreEqual(31, cObjects, "After migrating, should be 31 objects"); cLangProject = repoDto.AllInstancesSansSubclasses("LangProject").Count(); Assert.AreEqual(1, cLangProject, "After migrating, should be 1 LangProject object"); cUserView = repoDto.AllInstancesSansSubclasses("UserView").Count(); Assert.AreEqual(12, cUserView, "After migrating, should be 12 UserView objects"); cUserViewRec = repoDto.AllInstancesSansSubclasses("UserViewRec").Count(); Assert.AreEqual(3, cUserViewRec, "After migrating, should be 3 UserViewRec objects"); cUserViewField = repoDto.AllInstancesSansSubclasses("UserViewField").Count(); Assert.AreEqual(15, cUserViewField, "After migrating, should be 15 UserViewField objects"); }
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."); }
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"); }
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."); }
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."); } }
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"); }
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 }
public void DataMigration7000015Test() { var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000015.xml"); var mockMdc = SetupMdc(); IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000014, dtos, mockMdc, null, TestDirectoryFinder.LcmDirectories); // SUT: Do the migration. m_dataMigrationManager.PerformMigration(dtoRepos, 7000015, new DummyProgressDlg()); // Verification Phase Assert.AreEqual(7000015, dtoRepos.CurrentModelVersion, "Wrong updated version."); // PhSimpleContextBdry var oldClassElementNames = new List <string> { "CmObject", "PhContextOrVar", "PhPhonContext", "PhSimpleContext", "PhSimpleContextBdry" }; var expectedPropertyElements = new List <string> { "Name", "Description", "FeatureStructure" }; VerifyObject(dtoRepos.GetDTO("9719A466-2240-4DEA-9722-9FE0746A30A6"), oldClassElementNames, expectedPropertyElements); // StText oldClassElementNames = new List <string> { "CmObject", "StText" }; expectedPropertyElements = new List <string>(); VerifyObject(dtoRepos.GetDTO("C83E33DD-2A79-4A4B-84F6-92343C4F5324"), oldClassElementNames, expectedPropertyElements); // PhBdryMarker oldClassElementNames = new List <string> { "CmObject", "PhTerminalUnit", "PhBdryMarker" }; expectedPropertyElements = new List <string>(); VerifyObject(dtoRepos.GetDTO("C83E33DD-2A79-4A4B-84F6-92343C4F5325"), oldClassElementNames, expectedPropertyElements); }
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); }
private void ConvertWeatherToCustomListAndField(string datafile) { var dtos = DataMigrationTestServices.ParseProjectFile(datafile); var mockMdc = SetupMdc(); IDomainObjectDTORepository repoDTO = new DomainObjectDtoRepository(7000016, dtos, mockMdc, null, TestDirectoryFinder.LcmDirectories); // SUT: Do the migration. m_dataMigrationManager.PerformMigration(repoDTO, 7000017, new DummyProgressDlg()); // Verification Phase Assert.AreEqual(7000017, repoDTO.CurrentModelVersion, "Wrong updated version."); DomainObjectDTO dtoLP = null; foreach (DomainObjectDTO dto in repoDTO.AllInstancesSansSubclasses("LangProject")) { Assert.IsNull(dtoLP, "Only one LangProject object should exist"); dtoLP = dto; } Assert.NotNull(dtoLP, "The LangProject object should exist"); string sXml = dtoLP.Xml; Assert.IsFalse(sXml.Contains("<WeatherConditions>"), "The <WeatherConditions> element should have disappeared"); string sLpOwnerGuid = GetGuidAsOwnerGuid(sXml); DomainObjectDTO dtoNbk = null; foreach (DomainObjectDTO dto in repoDTO.AllInstancesSansSubclasses("RnResearchNbk")) { Assert.IsNull(dtoNbk, "Only one RnResearchNbk should exist"); Assert.IsTrue(dto.Xml.Contains(sLpOwnerGuid), "The RnResearchNbk should be owned by the LangProject"); dtoNbk = dto; } Assert.NotNull(dtoNbk, "The RnResearchNbk should exist"); string sNbkOwnerGuid = GetGuidAsOwnerGuid(dtoNbk.Xml); int cList = 0; DomainObjectDTO dtoTypeList = null; foreach (DomainObjectDTO dto in repoDTO.AllInstancesSansSubclasses("CmPossibilityList")) { sXml = dto.Xml; if (sXml.Contains(" ownerguid=")) { Assert.IsTrue(sXml.Contains(sNbkOwnerGuid), "Any remaining owned Possibility List must be owned by Data Notebook"); Assert.IsNull(dtoTypeList, "Only one list should be owned by the Data Notebook"); dtoTypeList = dto; } ++cList; } Assert.AreEqual(2, cList, "Two CmPossibilityList objects should still exist"); foreach (DomainObjectDTO dto in repoDTO.AllInstancesWithSubclasses("RnGenericRec")) { sXml = dto.Xml; Assert.IsFalse(sXml.Contains("<Weather"), "Any <Weather> element should have disappeared"); int idxCustom = sXml.IndexOf("<Custom"); if (idxCustom >= 0) { string sCustom = sXml.Substring(idxCustom); Assert.IsTrue(sCustom.StartsWith("<Custom name=\"Weather\">"), "Converted weather element has proper start element"); Assert.IsTrue(sCustom.Contains("</Custom>"), "Converted weather element has proper end element"); } } Assert.IsTrue(mockMdc.FieldExists("RnGenericRec", "Weather", false), "Weather field exists in RnGenericRec"); int flid = mockMdc.GetFieldId("RnGenericRec", "Weather", false); Assert.IsTrue(mockMdc.IsCustom(flid), "Weather field is a custom field"); // This test file has three overlays; none should be deleted, since we are keeping the weather list. Assert.That(repoDTO.AllInstancesSansSubclasses("CmOverlay"), Has.Count.EqualTo(3)); }
public void DataMigration7000012_Unneeded_UserViewField_Removed_Test() { var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000012_UserViewField.xml"); // Set up mock MDC. var mockMDC = new MockMDCForDataMigration(); mockMDC.AddClass(1, "CmObject", null, new List <string> { "UserViewField" }); mockMDC.AddClass(2, "UserViewField", "CmObject", new List <string>()); IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000011, dtos, mockMDC, null, TestDirectoryFinder.LcmDirectories); Assert.AreEqual(40, dtoRepos.AllInstancesWithSubclasses("UserViewField").Count()); // Collect the UserViewField values. var userViewFieldDtos = new Dictionary <string, DomainObjectDTO>(); foreach (var uvfDto in dtoRepos.AllInstancesWithSubclasses("UserViewField")) { userViewFieldDtos.Add(uvfDto.Guid.ToUpper(), uvfDto); } m_dataMigrationManager.PerformMigration(dtoRepos, 7000012, new DummyProgressDlg()); // Counts for fields that should not have been removed. int countRequired = 0; int countStyle = 0; int countHelpString = 0; int countFlid = 0; int countType = 0; foreach (var userViewField in dtoRepos.AllInstancesSansSubclasses("UserViewField")) { var uvfElement = XElement.Parse(userViewField.Xml); // Confirm that needed fields are still present. // Increment counter for fields occurring in UserViewField (but some may not always be present). if (uvfElement.XPathSelectElement("UserViewField/Required") != null) { countRequired++; } if (uvfElement.XPathSelectElement("UserViewField/Style") != null) { countStyle++; } if (uvfElement.XPathSelectElement("UserViewField/HelpString") != null) { countHelpString++; } if (uvfElement.XPathSelectElement("UserViewField/Flid") != null) { countFlid++; } if (uvfElement.XPathSelectElement("UserViewField/Type") != null) { countType++; } // Try to get the unused elements in UserViewField (should be gone) Assert.IsNull(uvfElement.XPathSelectElement("UserViewField/Details")); Assert.IsNull(uvfElement.XPathSelectElement("UserViewField/Visibility")); Assert.IsNull(uvfElement.XPathSelectElement("UserViewField/SubfieldOf")); Assert.IsNull(uvfElement.XPathSelectElement("UserViewField/IsCustomField")); } // Expectations for occurrences of fields that should not have been removed from XML file Assert.AreEqual(1, countStyle, "Unexpected number of Style fields"); Assert.AreEqual(3, countRequired, "Unexpected number of Required fields"); Assert.AreEqual(36, countHelpString, "Unexpected number of HelpString fields"); Assert.AreEqual(40, countFlid, "Unexpected number of Flid fields"); Assert.AreEqual(40, countType, "Unexpected number of Type fields"); }
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"))); }
public void DataMigration7000025Test() { var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000025.xml"); // Set up mock MDC. var mockMdc = new MockMDCForDataMigration(); mockMdc.AddClass(1, "CmObject", null, new List <string> { "CmProject", "CmMajorObject", "RnGenericRec", "LexEntry", "CmAnnotation", "CmPossibility", "StJournalText", // Really a subclass of StText, but StText is not needed for the test. "ScrDraft", "ScrCheckRun" }); 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> { "CmPossibilityList" }); mockMdc.AddClass(5, "CmPossibilityList", "CmMajorObject", new List <string>()); mockMdc.AddClass(6, "CmPossibility", "CmObject", new List <string> { "PartOfSpeech" }); mockMdc.AddClass(7, "PartOfSpeech", "CmPossibility", new List <string>()); mockMdc.AddClass(8, "CmAnnotation", "CmObject", new List <string> { "CmBaseAnnotation" }); mockMdc.AddClass(9, "CmBaseAnnotation", "CmAnnotation", new List <string> { "ScrScriptureNote" }); mockMdc.AddClass(10, "ScrScriptureNote", "CmBaseAnnotation", new List <string>()); mockMdc.AddClass(11, "StJournalText", "CmObject", new List <string>()); mockMdc.AddClass(12, "LexEntry", "CmObject", new List <string>()); mockMdc.AddClass(13, "RnGenericRec", "CmObject", new List <string>()); mockMdc.AddClass(14, "ScrDraft", "CmObject", new List <string>()); mockMdc.AddClass(15, "ScrCheckRun", "CmObject", new List <string>()); IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000024, dtos, mockMdc, null, TestDirectoryFinder.LcmDirectories); // SUT m_dataMigrationManager.PerformMigration(dtoRepos, 7000025, new DummyProgressDlg()); var dict = new Dictionary <string, string> { { _utcCreatedAsString, "DateCreated" }, { _utcModifiedAsString, "DateModified" } }; // Check what happened on LangProject (derives from CmProject, which defines the props) CheckMainObject(dtoRepos, "c1ecd171-e382-11de-8a39-0800200c9a66", dict); // Check what happened on CmPossibilityList (defines the props) CheckMainObject(dtoRepos, "c1ecd172-e382-11de-8a39-0800200c9a66", dict); // Check what happened on CmPossibility (defines the props) CheckMainObject(dtoRepos, "c1ecd173-e382-11de-8a39-0800200c9a66", dict); // Check what happened on PartOfSpeech (derives from CmPossibility) CheckMainObject(dtoRepos, "c1ecd174-e382-11de-8a39-0800200c9a66", dict); // Check what happened on CmBaseAnnotation (derives from CmAnnotation, which defines the props) CheckMainObject(dtoRepos, "c1ecd175-e382-11de-8a39-0800200c9a66", dict); // Check what happened on StJournalText (derives from StText, which defines the props) CheckMainObject(dtoRepos, "c1ecd177-e382-11de-8a39-0800200c9a66", dict); // Check what happened on LexEntry (defines the props) CheckMainObject(dtoRepos, "c1ecd178-e382-11de-8a39-0800200c9a66", dict); // Check what happened on RnGenericRec (defines the props) CheckMainObject(dtoRepos, "c1ecd179-e382-11de-8a39-0800200c9a66", dict); // Check what happened on ScrScriptureNote (derives from CmBaseAnnotation) dict.Add(_utcResolvedAsString, "DateResolved"); CheckMainObject(dtoRepos, "c1ecd176-e382-11de-8a39-0800200c9a66", dict); dict.Remove(_utcResolvedAsString); // Check what happened on ScrDraft (defines the props) dict.Remove(_utcModifiedAsString); CheckMainObject(dtoRepos, "c1ecd17a-e382-11de-8a39-0800200c9a66", dict); // Check what happened on ScrCheckRun (defines the props) dict[_utcCreatedAsString] = "RunDate"; CheckMainObject(dtoRepos, "c1ecd17b-e382-11de-8a39-0800200c9a66", dict); Assert.AreEqual(7000025, dtoRepos.CurrentModelVersion, "Wrong updated version."); }
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."); }
public void DataMigration7000023Test() { var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000023.xml"); // Set up mock MDC. var mockMDC = new MockMDCForDataMigration(); mockMDC.AddClass(1, "CmObject", null, new List <string> { "LangProject", "DsDiscourseData", "LexDb", "RnResearchNbk", "CmPossibilityList", "CmFilter", "UserView", "UserAppFeatAct", "CmResource", "ScrCheckRun" }); mockMDC.AddClass(2, "LangProject", "CmObject", new List <string>()); mockMDC.AddClass(3, "DsDiscourseData", "CmObject", new List <string>()); mockMDC.AddClass(4, "LexDb", "CmObject", new List <string>()); mockMDC.AddClass(5, "CmPossibilityList", "CmObject", new List <string>()); mockMDC.AddClass(6, "CmFilter", "CmObject", new List <string>()); mockMDC.AddClass(7, "UserView", "CmObject", new List <string>()); mockMDC.AddClass(8, "UserAppFeatAct", "CmObject", new List <string>()); mockMDC.AddClass(9, "CmResource", "CmObject", new List <string>()); mockMDC.AddClass(10, "ScrCheckRun", "CmObject", new List <string>()); mockMDC.AddClass(11, "RnResearchNbk", "CmObject", new List <string>()); IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000022, dtos, mockMDC, null, TestDirectoryFinder.LcmDirectories); //SUT m_dataMigrationManager.PerformMigration(dtoRepos, 7000023, new DummyProgressDlg()); // Verification section var dto = dtoRepos.GetDTO("c1ecaa73-e382-11de-8a39-0800200c9a66"); var rtElement = XElement.Parse(dto.Xml); CheckGuid(rtElement.Element("LexDb").Element("objsur").Attribute("guid").Value); dto = dtoRepos.GetDTO("c1ec5c4c-e382-11de-8a39-0800200c9a66"); rtElement = XElement.Parse(dto.Xml); CheckGuid(rtElement.Attribute("ownerguid").Value); dto = dtoRepos.GetDTO("c1Ecaa74-e382-11de-8a39-0800200c9a66"); rtElement = XElement.Parse(dto.Xml); CheckGuid(rtElement.Attribute("guid").Value); dto = dtoRepos.GetDTO("AF26D792-EA5E-11DE-8F7E-0013722F8DEC"); rtElement = XElement.Parse(dto.Xml); CheckGuid(rtElement.Attribute("guid").Value); dto = dtoRepos.GetDTO("1FBDC211-32E4-4203-9B7F-9CAACBF31DBD"); rtElement = XElement.Parse(dto.Xml); CheckGuid(rtElement.Attribute("guid").Value); CheckGuid(rtElement.Element("ListVersion").Attribute("val").Value); dto = dtoRepos.GetDTO("c1ecaa77-e382-11de-8a39-0800200c9a66"); rtElement = XElement.Parse(dto.Xml); CheckGuid(rtElement.Element("App").Attribute("val").Value); dto = dtoRepos.GetDTO("c1ecaa78-e382-11de-8a39-0800200c9a66"); rtElement = XElement.Parse(dto.Xml); CheckGuid(rtElement.Element("App").Attribute("val").Value); dto = dtoRepos.GetDTO("c1ecaa79-e382-11de-8a39-0800200c9a66"); rtElement = XElement.Parse(dto.Xml); CheckGuid(rtElement.Element("ApplicationId").Attribute("val").Value); dto = dtoRepos.GetDTO("c1ecaa7a-e382-11de-8a39-0800200c9a66"); rtElement = XElement.Parse(dto.Xml); CheckGuid(rtElement.Element("Version").Attribute("val").Value); dto = dtoRepos.GetDTO("c1ecd170-e382-11de-8a39-0800200c9a66"); rtElement = XElement.Parse(dto.Xml); CheckGuid(rtElement.Element("CheckId").Attribute("val").Value); Assert.AreEqual(7000023, dtoRepos.CurrentModelVersion, "Wrong updated version."); }
public void DataMigration7000019Test() { string storePath = Path.Combine(Path.GetTempPath(), LcmFileHelper.ksWritingSystemsDir); PrepareStore(storePath); string globalStorePath = LcmFileHelper.OldGlobalWritingSystemStoreDirectory; PrepareStore(globalStorePath); var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000019Tests.xml"); IFwMetaDataCacheManaged mockMdc = SetupMdc(); IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000018, dtos, mockMdc, Path.GetTempPath(), TestDirectoryFinder.LcmDirectories); // Do the migration. m_dataMigrationManager.PerformMigration(dtoRepos, 7000019, new DummyProgressDlg()); // Verification Phase Assert.AreEqual(7000019, dtoRepos.CurrentModelVersion, "Wrong updated version."); Assert.AreEqual(0, dtoRepos.AllInstancesSansSubclasses("LgWritingSystem").Count()); Assert.AreEqual(0, dtoRepos.AllInstancesSansSubclasses("LgCollation").Count()); Assert.AreEqual(0, dtoRepos.AllInstancesSansSubclasses("CmSortSpec").Count()); var kalabaPath = Path.Combine(storePath, "x-kal.ldml"); // Note this migration does NOT yet convert to qaa-x-kal var kalabaNode = XDocument.Parse(Encoding.UTF8.GetString(File.ReadAllBytes(kalabaPath))).Root; Assert.That(kalabaNode.Name.LocalName, Is.EqualTo("ldml")); var identityNode = kalabaNode.Element("identity"); Assert.That(identityNode.Element("language").Attribute("type").Value, Is.EqualTo("x-kal")); var specialNode = kalabaNode.Element("special"); XNamespace xmlns = "http://www.w3.org/2000/xmlns/"; Assert.That(specialNode.Attribute(xmlns + "palaso").Value, Is.EqualTo("urn://palaso.org/ldmlExtensions/v1")); XNamespace palaso = "urn://palaso.org/ldmlExtensions/v1"; Assert.That(specialNode.Element(palaso + "languageName").Attribute("value").Value, Is.EqualTo("Kalaba")); Assert.That(specialNode.Element(palaso + "abbreviation").Attribute("value").Value, Is.EqualTo("Kal")); // Todo: check a lot more things. //Assert.AreEqual(1033, kalaba.LCID); //IWritingSystem frIpa = wsManager.Get("fr-fonipa-x-etic"); //Assert.AreEqual("FrnI", frIpa.Abbreviation); //Assert.AreEqual("IPA Unicode 1.0", frIpa.Keyboard); //foreach (string id in analysisWss.Split(' ')) // Assert.IsTrue(wsManager.Exists(id)); //var vernWss = (string)lpElem.Element("VernWss"); //foreach (string id in vernWss.Split(' ')) // Assert.IsTrue(wsManager.Exists(id)); //CheckWsProperty(dtoRepos.AllInstancesWithSubclasses("CmPossibilityList"), wsManager); //foreach (DomainObjectDTO dto in dtoRepos.AllInstancesWithValidClasses()) // CheckStringWsIds(wsManager, dto); DomainObjectDTO importSourceDto = dtoRepos.AllInstancesWithSubclasses("ScrImportSource").First(); XElement importSourceElem = XElement.Parse(importSourceDto.Xml); Assert.AreEqual("x-kal", (string)importSourceElem.Element("WritingSystem").Element("Uni")); Assert.IsNull(importSourceElem.Element("ICULocale")); DomainObjectDTO mappingDto = dtoRepos.AllInstancesWithSubclasses("ScrMarkerMapping").First(); XElement mappingElem = XElement.Parse(mappingDto.Xml); Assert.AreEqual("fr-fonipa-x-etic", (string)mappingElem.Element("WritingSystem").Element("Uni")); Assert.IsNull(mappingElem.Element("ICULocale")); DomainObjectDTO styleDto = dtoRepos.AllInstancesWithSubclasses("StStyle").First(); XElement styleElem = XElement.Parse(styleDto.Xml); Assert.AreEqual("<default font>", (string)styleElem.Element("Rules").Element("Prop").Attribute("fontFamily")); }
public void DataMigration7000044Test() { var projectFolder = Path.GetTempPath(); var storePath = Path.Combine(projectFolder, LcmFileHelper.ksWritingSystemsDir); PrepareStore(storePath); var testEnglishPath = Path.Combine(storePath, "en.ldml"); File.Copy(Path.Combine(TestDirectoryFinder.TestDataDirectory, "en_7000043.ldml"), testEnglishPath); File.SetAttributes(testEnglishPath, FileAttributes.Normal); // don't want to copy readonly property. var xkalPath = Path.Combine(storePath, "x-kal.ldml"); File.Copy(Path.Combine(TestDirectoryFinder.TestDataDirectory, "x-kal_7000043.ldml"), xkalPath); File.SetAttributes(xkalPath, FileAttributes.Normal); // don't want to copy readonly property. var xkalFonipaPath = Path.Combine(storePath, "x-kal-fonipa.ldml"); File.Copy(Path.Combine(TestDirectoryFinder.TestDataDirectory, "x-kal-fonipa_7000043.ldml"), xkalFonipaPath); File.SetAttributes(xkalFonipaPath, FileAttributes.Normal); // don't want to copy readonly property. var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000044.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", "LangProject", "LexSense", "LexDb", "ReversalEntry", "StStyle", "CmPossibilityList", "CmBaseAnnotation" }); mockMDC.AddClass(2, "LangProject", "CmObject", new List <string>()); mockMDC.AddClass(3, "LexEntry", "CmObject", new List <string>()); mockMDC.AddClass(4, "LexSense", "CmObject", new List <string>()); mockMDC.AddClass(5, "LexDb", "CmObject", new List <string>()); mockMDC.AddClass(6, "ReversalEntry", "CmObject", new List <string>()); mockMDC.AddClass(7, "StStyle", "CmObject", new List <string>()); mockMDC.AddClass(8, "CmPossibilityList", "CmObject", new List <string>()); mockMDC.AddClass(9, "CmBaseAnnotation", "CmObject", new List <string>()); var settingsFolder = Path.Combine(projectFolder, LcmFileHelper.ksConfigurationSettingsDir); Directory.CreateDirectory(settingsFolder); var sampleLayout = Path.Combine(settingsFolder, "Test_Layouts.xml"); File.WriteAllText(sampleLayout, sampleLayoutData, Encoding.UTF8); var sampleSettings = Path.Combine(settingsFolder, "db$local$Settings.xml"); File.WriteAllText(sampleSettings, sampleLocalSettingsData, Encoding.UTF8); IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000043, dtos, mockMDC, projectFolder, TestDirectoryFinder.LcmDirectories); // Do the migration. m_dataMigrationManager.PerformMigration(dtoRepos, 7000044, new DummyProgressDlg()); // Verification Phase Assert.AreEqual(7000044, dtoRepos.CurrentModelVersion, "Wrong updated version."); // Todo: // Verify that en.ldml is unchanged. Assert.That(File.Exists(testEnglishPath)); // Verify that x-kal.ldml is renamed to qaa-x-kal and content changed Assert.That(File.Exists(Path.Combine(storePath, "qaa-x-kal.ldml"))); // Verify that x-kal-fonipa.ldml is renamed to qaa-fonipa-x-kal and content changed Assert.That(File.Exists(Path.Combine(storePath, "qaa-x-kal-fonipa.ldml"))); // Verify that AUni data in LexEntry" guid="7ecbb299-bf35-4795-a5cc-8d38ce8b891c tag is changed to qaa-x-kal var entry = XElement.Parse(dtoRepos.GetDTO("7ecbb299-bf35-4795-a5cc-8d38ce8b891c").Xml); Assert.That(entry.Element("CitationForm").Element("AUni").Attribute("ws").Value, Is.EqualTo("qaa-x-kal")); // Verify that AStr data in LexSense" guid="e3c2d179-3ccd-431e-ac2e-100bdb883680" tag is changed to qaa-x-kal var sense = XElement.Parse(dtoRepos.GetDTO("e3c2d179-3ccd-431e-ac2e-100bdb883680").Xml); Assert.That(sense.Element("Definition").Elements("AStr").Skip(1).First().Attribute("ws").Value, Is.EqualTo("qaa-x-kal")); Assert.That(sense.Element("Definition").Elements("AStr").Count(), Is.EqualTo(2), "french should be deleted because empty"); // Verify that the empty alternatives get removed. Assert.That(sense.Element("Bibliography").Elements("AUni").First().Attribute("ws").Value, Is.EqualTo("en")); Assert.That(sense.Element("Bibliography").Elements("AUni").Count(), Is.EqualTo(1)); // Verify that Run data in LexSense" guid="e3c2d179-3ccd-431e-ac2e-100bdb883680" tag is changed to qaa-x-kal Assert.That(sense.Element("Definition").Element("AStr").Elements("Run").Skip(1).First().Attribute("ws").Value, Is.EqualTo("qaa-x-kal")); // Check LiftResidue lang attributes are fixed; note that a result containing lang="qaa-x-kal" // would also be acceptable, perhaps even more to be expected, but converting the " s here to " is acceptable. Assert.That(sense.Element("LiftResidue").Element("Uni").Value.Contains("lang=\"qaa-x-kal\"")); // Verify that WsProp data in StStyle guid="4d312f11-439e-11d4-b5e7-00400543a266" is changed to qaa-x-kal var style = XElement.Parse(dtoRepos.GetDTO("4d312f11-439e-11d4-b5e7-00400543a266").Xml); Assert.That(style.Element("Rules").Element("Prop").Element("WsStyles9999").Elements("WsProp").Skip(1).First().Attribute("ws").Value, Is.EqualTo("qaa-x-kal")); // Verify that x-kal is changed to qaa-x-kal in xWss properties of LangProject b8bdad3d-9006-46f0-83e8-ae1d1726f2ad. var langProj = XElement.Parse(dtoRepos.GetDTO("b8bdad3d-9006-46f0-83e8-ae1d1726f2ad").Xml); Assert.That(langProj.Element("AnalysisWss").Element("Uni").Value, Is.EqualTo("en qaa-x-kal")); Assert.That(langProj.Element("CurVernWss").Element("Uni").Value, Is.EqualTo("seh qaa-x-kal fr")); Assert.That(langProj.Element("CurAnalysisWss").Element("Uni").Value, Is.EqualTo("en qaa-x-kal")); Assert.That(langProj.Element("CurPronunWss").Element("Uni").Value, Is.EqualTo("qaa-x-kal")); Assert.That(langProj.Element("VernWss").Element("Uni").Value, Is.EqualTo("qaa-x-kal")); // Verify that WritingSystem/Uni is changed to qaa-x-kal in ReversalIndex" guid="62105696-da6c-405e-b87f-a2a0294bb179 var ri = XElement.Parse(dtoRepos.GetDTO("62105696-da6c-405e-b87f-a2a0294bb179").Xml); Assert.That(ri.Element("WritingSystem").Element("Uni").Value, Is.EqualTo("qaa-x-kal")); // and CmPossibilityList" guid="b30aa28d-7510-49e6-b9ac-bc1902398ce6" var pl = XElement.Parse(dtoRepos.GetDTO("b30aa28d-7510-49e6-b9ac-bc1902398ce6").Xml); Assert.That(pl.Element("WritingSystem").Element("Uni").Value, Is.EqualTo("qaa-x-kal")); // and CmBaseAnnotation" guid="dc747a85-ceb6-491e-8b54-7fc37d7b2f80" var cba = XElement.Parse(dtoRepos.GetDTO("dc747a85-ceb6-491e-8b54-7fc37d7b2f80").Xml); Assert.That(cba.Element("WritingSystem").Element("Uni").Value, Is.EqualTo("qaa-x-kal")); // Several other classes have WritingSystem, but we're checking ALL objects, so I think three test cases is plenty. // Check the layout var layoutElt = XElement.Parse(File.ReadAllText(sampleLayout, Encoding.UTF8)); Assert.That(layoutElt.Element("layout").Element("part").Attribute("ws").Value, Is.EqualTo("qaa-x-kal")); Assert.That(layoutElt.Element("layout").Elements("part").Skip(1).First().Attribute("ws").Value, Is.EqualTo("vernacular")); Assert.That(layoutElt.Element("layout").Elements("part").Skip(2).First().Attribute("ws").Value, Is.EqualTo("$ws=all analysis")); Assert.That(layoutElt.Element("layout").Elements("part").Skip(3).First().Attribute("ws").Value, Is.EqualTo("$ws=qaa-x-kal")); Assert.That(layoutElt.Element("layout").Elements("part").Skip(4).First().Attribute("ws").Value, Is.EqualTo("qaa-x-kal-fonipa,qaa-x-kal")); Assert.That(layoutElt.Element("layout").Elements("part").Skip(4).First().Attribute("visibleWritingSystems").Value, Is.EqualTo("qaa-x-kal-fonipa,qaa-x-kal")); // Check the local settings. var propTable = XElement.Parse(File.ReadAllText(sampleSettings, Encoding.UTF8)); Assert.That(propTable.Element("Property").Element("value").Value.Contains("5062001%qaa-x-kal")); Assert.That(propTable.Element("Property").Element("value").Value.Contains("5112002%qaa-x-kal")); Assert.That(propTable.Element("Property").Element("value").Value.Contains("103%qaa-x-kal")); Assert.That(propTable.Elements("Property").Skip(1).First().Element("value").Value.Contains("ws=\"qaa-x-kal\"")); Assert.That(propTable.Elements("Property").Skip(2).First().Element("value").Value.Contains("ws=\"$ws=qaa-x-kal\"")); Assert.That(propTable.Elements("Property").Skip(3).First().Element("value").Value.Contains("ws=\"$wsName\"")); Assert.That(propTable.Elements("Property").Skip(4).First().Element("value").Value.Contains("ws=\"$ws=reversal\"")); Assert.That(propTable.Elements("Property").Skip(5).First().Element("value").Value, Is.EqualTo("qaa-x-kal")); Assert.That(propTable.Elements("Property").Skip(6).First().Element("value").Value.Contains("ws=\"qaa-x-kal\"")); Assert.That(propTable.Elements("Property").Skip(7).First().Element("value").Value.Contains("ws=\"$ws=qaa-x-kal\"")); }