public void DeleteWeatherListAndField() { var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000017.xml"); var mockMdc = SetupMdc(); IDomainObjectDTORepository repoDTO = new DomainObjectDtoRepository(7000016, dtos, mockMdc, null, FwDirectoryFinder.FdoDirectories); // SUT: Do the migration. m_dataMigrationManager.PerformMigration(repoDTO, 7000017, new DummyProgressDlg()); // Verification Phase Assert.AreEqual(7000017, repoDTO.CurrentModelVersion, "Wrong updated version."); DomainObjectDTO dtoLP = null; foreach (DomainObjectDTO dto in repoDTO.AllInstancesSansSubclasses("LangProject")) { Assert.IsNull(dtoLP, "Only one LangProject object should exist"); dtoLP = dto; } Assert.NotNull(dtoLP, "The LangProject object should exist"); string sXml = dtoLP.Xml; Assert.IsFalse(sXml.Contains("<WeatherConditions>"), "The <WeatherConditions> element should have disappeared"); string sLpOwnerGuid = GetGuidAsOwnerGuid(sXml); DomainObjectDTO dtoNbk = null; foreach (DomainObjectDTO dto in repoDTO.AllInstancesSansSubclasses("RnResearchNbk")) { Assert.IsNull(dtoNbk, "Only one RnResearchNbk should exist"); Assert.IsTrue(dto.Xml.Contains(sLpOwnerGuid), "The RnResearchNbk should be owned by the LangProject"); dtoNbk = dto; } Assert.NotNull(dtoNbk, "The RnResearchNbk should exist"); string sNbkOwnerGuid = GetGuidAsOwnerGuid(dtoNbk.Xml); int cList = 0; foreach (DomainObjectDTO dto in repoDTO.AllInstancesSansSubclasses("CmPossibilityList")) { sXml = dto.Xml; Assert.IsTrue(sXml.Contains(sNbkOwnerGuid), "Possibility List must be owned by Data Notebook"); ++cList; } Assert.AreEqual(1, cList, "Only one CmPossibilityList should exist"); foreach (DomainObjectDTO dto in repoDTO.AllInstancesWithSubclasses("RnGenericRec")) { Assert.IsFalse(dto.Xml.Contains("<Weather"), "Any <Weather> element should have disappeared"); Assert.IsFalse(dto.Xml.Contains("<Custom name="), "No <Custom> element should have been created"); } // This test file has three overlays; the first refers to a weather item and the weather possibility list, // and should be delted. The second refers to a non-weather possibility, and the third to a non-weather // possibility list; they should survive. Assert.That(repoDTO.AllInstancesSansSubclasses("CmOverlay"), Has.Count.EqualTo(2)); }
public void PerformMigration7000018() { var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000018.xml"); var mockMdc = SetupMdc(); IDomainObjectDTORepository repoDTO = new DomainObjectDtoRepository(7000017, dtos, mockMdc, null, FwDirectoryFinder.FdoDirectories); // 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 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, FwDirectoryFinder.FdoDirectories); 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 DtosByClassButNoSubclassesTest() { var dtos = new HashSet <DomainObjectDTO>(); // 1. Add barebones LP. const string lpGuid = "9719A466-2240-4DEA-9722-9FE0746A30A6"; CreatoDTO(dtos, lpGuid, "LangProject", null); IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(1, dtos, m_mdc, null, FwDirectoryFinder.FdoDirectories); var result = new List <DomainObjectDTO>(dtoRepos.AllInstancesSansSubclasses("CmObject")); Assert.AreEqual(0, result.Count, "Wrong number of DTOs (expected 0)."); result = new List <DomainObjectDTO>(dtoRepos.AllInstancesSansSubclasses("LangProject")); Assert.AreEqual(1, result.Count, "Wrong number of DTOs (expected 1)."); }
public void 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); 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")); }
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(7000061, dtos, mockMdc, null); 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."); }
public void DataMigration7000016Test() { var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000016.xml"); var mockMdc = SetupMdc(); IDomainObjectDTORepository repoDTO = new DomainObjectDtoRepository(7000015, dtos, mockMdc, null); // SUT: Do the migration. m_dataMigrationManager.PerformMigration(repoDTO, 7000016, new DummyProgressDlg()); // Verification Phase Assert.AreEqual(7000016, repoDTO.CurrentModelVersion, "Wrong updated version."); DomainObjectDTO nbkDto = null; foreach (DomainObjectDTO dot in repoDTO.AllInstancesSansSubclasses("RnResearchNbk")) { nbkDto = dot; break; } Assert.NotNull(nbkDto); XElement nbkElem = XElement.Parse(nbkDto.Xml); var recTypesGuid = (string)nbkElem.XPathSelectElement("RecTypes/objsur").Attribute("guid"); Assert.AreEqual(recTypesGuid.ToLowerInvariant(), ksguidRecTypesList); // All we can guarantee being able to check are those items that we create, and to a // limited degree, those items that are moved to belong to a created item. bool fFoundEvent = false; bool fFoundMethod = false; bool fFoundWeather = false; foreach (DomainObjectDTO dto in repoDTO.GetDirectlyOwnedDTOs(ksguidRecTypesList)) { string sguid = dto.Guid.ToLowerInvariant(); Assert.AreNotEqual(sguid, ksguidObservation); Assert.AreNotEqual(sguid, ksguidConversation); Assert.AreNotEqual(sguid, ksguidInterview); Assert.AreNotEqual(sguid, ksguidPerformance); if (sguid == ksguidEvent) { fFoundEvent = true; CheckEventSubTypes(repoDTO); } else if (sguid == ksguidMethodology) { fFoundMethod = true; } else if (sguid == ksguidWeather) { fFoundWeather = true; } } Assert.IsTrue(fFoundEvent); Assert.IsTrue(fFoundMethod); Assert.IsTrue(fFoundWeather); }
public void 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, FwDirectoryFinder.FdoDirectories); 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 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, FwDirectoryFinder.FdoDirectories); 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 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, FwDirectoryFinder.FdoDirectories); 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()); }
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, FwDirectoryFinder.FdoDirectories); 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, FwDirectoryFinder.FdoDirectories); 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, FwDirectoryFinder.FdoDirectories); 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 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, FwDirectoryFinder.FdoDirectories); //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 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); 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 DataMigration7000020Test() { var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000020.xml"); IFwMetaDataCacheManaged mockMdc = SetupMdc(); IDomainObjectDTORepository repoDto = new DomainObjectDtoRepository(7000019, dtos, mockMdc, Path.GetTempPath()); // 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 AddNewDtoTest() { var dtos = new HashSet <DomainObjectDTO>(); // 1. Add barebones LP. const string lpGuid = "9719A466-2240-4DEA-9722-9FE0746A30A6"; CreatoDTO(dtos, lpGuid, "LangProject", null); const string lexDbGuid = "6C84F84A-5B99-4CF5-A7D5-A308DDC604E0"; CreatoDTO(dtos, lexDbGuid, "LexDb", null); IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(1, dtos, m_mdc, null, FwDirectoryFinder.FdoDirectories); // Create new DTO and add it. var newGuid = Guid.NewGuid(); var newby = new DomainObjectDTO(newGuid.ToString(), "LexEntry", "<rt />"); dtoRepos.Add(newby); Assert.AreSame(newby, dtoRepos.GetDTO(newGuid.ToString()), "Wrong new DTO from guid."); Assert.AreSame(newby, dtoRepos.AllInstancesSansSubclasses("LexEntry").First(), "Wrong new DTO from class."); Assert.IsTrue(((DomainObjectDtoRepository)dtoRepos).Newbies.Contains(newby), "Newby not in newbies set."); }
public void RemoveDtoTest() { var dtos = new HashSet <DomainObjectDTO>(); // 1. Add barebones LP. const string lpGuid = "9719A466-2240-4DEA-9722-9FE0746A30A6"; var lpDto = CreatoDTO(dtos, lpGuid, "LangProject", null); IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(1, dtos, m_mdc, null, FwDirectoryFinder.FdoDirectories); dtoRepos.Remove(lpDto); Assert.IsTrue(((DomainObjectDtoRepository)dtoRepos).Goners.Contains(lpDto), "Goner not in goners set."); Assert.IsNull(dtoRepos.AllInstancesSansSubclasses("LexEntry").FirstOrDefault(), "Found goner by class."); try { dtoRepos.GetDTO(lpDto.Guid); Assert.Fail("Found deleted DTO by guid."); } catch (ArgumentException) { // Eat expected exception. } }
public void DataMigration7000059Test() { //Bring in data from xml file. var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000059.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, "CmMajorObject", "CmObject", new List <string>() { "RnResearchNbk", "Text" }); mockMDC.AddClass(5, "RnResearchNbk", "CmMajorObject", new List <string>()); mockMDC.AddClass(6, "Text", "CmMajorObject", new List <string>()); mockMDC.AddClass(7, "RnGenericRec", "CmObject", new List <string> ()); IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000058, dtos, mockMDC, null); m_dataMigrationManager.PerformMigration(dtoRepos, 7000059, new DummyProgressDlg()); // The Texts property of the LangProject should be gone. var lp = dtoRepos.AllInstancesSansSubclasses("LangProject").First(); var lpElement = XElement.Parse(lp.Xml); var textsElt = lpElement.Element("Texts"); Assert.That(lpElement.Name.LocalName, Is.EqualTo("rt")); Assert.That(textsElt, Is.Null); // The Text property of the RnGenericRec should be Reference Atomic instead of owned. var rnRec = dtoRepos.AllInstancesSansSubclasses("RnGenericRec").First(); var rnRecElement = XElement.Parse(rnRec.Xml); var textElt = rnRecElement.Element("Text"); Assert.That(rnRecElement.Name.LocalName, Is.EqualTo("rt")); Assert.That(textElt, Is.Not.Null); var objsurType = GetObjsurType(textElt); Assert.AreEqual("r", objsurType, "Should have changed from owned to reference type"); // Texts should no longer know owners. // First test the one that was owned by the LangProject var allTextDtos = dtoRepos.AllInstancesSansSubclasses("Text"); var textDto = allTextDtos.First(); textElt = XElement.Parse(textDto.Xml); var ownerAttr = textElt.Attribute("ownerguid"); Assert.That(ownerAttr, Is.Null); // Then test the one that was owned by the DN record textDto = allTextDtos.Last(); textElt = XElement.Parse(textDto.Xml); ownerAttr = textElt.Attribute("ownerguid"); Assert.That(ownerAttr, Is.Null); Assert.AreEqual(7000059, dtoRepos.CurrentModelVersion, "Wrong updated version."); }
public void DataMigration7000065Test() { var mockMdc = new MockMDCForDataMigration(); mockMdc.AddClass(1, "CmObject", null, new List <string> { "CmMajorObject", "CmPossibility" }); mockMdc.AddClass(2, "CmMajorObject", "CmObject", new List <string>() { "LexDb", "CmPossibilityList", "ReversalIndex" }); mockMdc.AddClass(3, "LexDb", "CmMajorObject", new List <string>()); mockMdc.AddClass(4, "CmPossibilityList", "CmMajorObject", new List <string>()); mockMdc.AddClass(5, "ReversalIndex", "CmMajorObject", new List <string>()); mockMdc.AddClass(6, "CmPossibility", "CmObject", new List <string>() { "PartOfSpeech" }); mockMdc.AddClass(7, "PartOfSpeech", "CmPossibility", new List <string>()); var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000065.xml"); IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000064, dtos, mockMdc, null, FwDirectoryFinder.FdoDirectories); m_dataMigrationManager.PerformMigration(dtoRepos, 7000065, new DummyProgressDlg()); var possListsList = dtoRepos.AllInstancesSansSubclasses("CmPossibilityList").ToArray(); Assert.AreEqual(2, possListsList.Length, "Wrong number of Possibility Lists"); var enPoslist = possListsList[0]; var frPoslist = possListsList[1]; var enPoslistElt = XElement.Parse(enPoslist.Xml); var frPoslistElt = XElement.Parse(frPoslist.Xml); // Check that English Parts of Speech list's Name didn't change var enName = enPoslistElt.Element("Name"); // this one shouldn't change var enNameStrings = enName.Elements("AUni"); Assert.AreEqual(1, enNameStrings.Count(), "Changed number of Name strings."); var enNameStr = enNameStrings.First().Value; Assert.AreEqual("RandomEnglish", enNameStr, "Name of list changed"); // Check that French Parts of Speech list's Name got created. var frName = frPoslistElt.Element("Name"); // should have been created var frNameStrings = frName.Elements("AUni"); Assert.AreEqual(2, frNameStrings.Count(), "Should have created 2 Name strings."); var frNameStr1 = frNameStrings.First().Value; var frNameStr2 = frNameStrings.Last().Value; Assert.AreEqual(string.Format(Strings.ksReversalIndexPOSListName, "French"), frNameStr1, "Name1 was not created correctly."); Assert.AreEqual(string.Format(Strings.ksReversalIndexPOSListName, "German"), frNameStr2, "Name2 was not created correctly."); // Check that ItemClsId was added to French parts of speech list var frItemClsId = frPoslistElt.Element("ItemClsid").Attribute("val").Value; Assert.AreEqual("5049", frItemClsId, "Migration added wrong ItemClsid."); // Check that both IsSorted were changed to 'True' var enIsSorted = enPoslistElt.Element("IsSorted").Attribute("val").Value; Assert.AreEqual("True", enIsSorted, "English IsSorted didn't get changed."); var frIsSorted = frPoslistElt.Element("IsSorted").Attribute("val").Value; Assert.AreEqual("True", frIsSorted, "French IsSorted didn't get changed."); // Check that both Depths were changed to '127' var enDepth = enPoslistElt.Element("Depth").Attribute("val").Value; Assert.AreEqual("127", enDepth, "English Depth didn't get changed."); var frDepth = frPoslistElt.Element("Depth").Attribute("val").Value; Assert.AreEqual("127", frDepth, "French Depth didn't get changed."); Assert.AreEqual(7000065, dtoRepos.CurrentModelVersion, "Wrong updated version."); }
private void ConvertWeatherToCustomListAndField(string datafile) { var dtos = DataMigrationTestServices.ParseProjectFile(datafile); var mockMdc = SetupMdc(); IDomainObjectDTORepository repoDTO = new DomainObjectDtoRepository(7000016, dtos, mockMdc, null, FwDirectoryFinder.FdoDirectories); // 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 DataMigration7000005Test() { var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000005Tests.xml"); // Set up mock MDC. var mockMDC = new MockMDCForDataMigration(); mockMDC.AddClass(1, "CmObject", null, new List <string> { "LangProject", "CmMajorObject", "RnGenericRec", "RnRoledPartic", "StText", "StPara", "CmPossibility" }); mockMDC.AddClass(2, "LangProject", "CmObject", new List <string>()); mockMDC.AddClass(3, "StText", "CmObject", new List <string>()); mockMDC.AddClass(4, "CmMajorObject", "CmObject", new List <string> { "RnResearchNbk", "CmPossibilityList" }); mockMDC.AddClass(5, "RnResearchNbk", "CmMajorObject", new List <string>()); mockMDC.AddClass(6, "RnGenericRec", "CmObject", new List <string> { "RnEvent", "RnAnalysis" }); mockMDC.AddClass(7, "RnRoledPartic", "CmObject", new List <string>()); mockMDC.AddClass(8, "CmPossibility", "CmObject", new List <string> { "CmPerson", "CmAnthroItem" }); mockMDC.AddClass(9, "StPara", "CmObject", new List <string> { "StTxtPara" }); mockMDC.AddClass(10, "StTxtPara", "StPara", new List <string>()); mockMDC.AddClass(11, "CmPossibilityList", "CmMajorObject", new List <string>()); mockMDC.AddClass(12, "RnEvent", "RnGenericRec", new List <string>()); mockMDC.AddClass(13, "RnAnalysis", "RnGenericRec", new List <string>()); mockMDC.AddClass(14, "CmPerson", "CmPossibility", new List <string>()); mockMDC.AddClass(15, "CmAnthroItem", "CmPossibility", new List <string>()); IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000004, dtos, mockMDC, null); m_dataMigrationManager.PerformMigration(dtoRepos, 7000005, new DummyProgressDlg()); var nbkDto = dtoRepos.AllInstancesSansSubclasses("RnResearchNbk").First(); var nbkElement = XElement.Parse(nbkDto.Xml); Assert.AreEqual(7000005, dtoRepos.CurrentModelVersion, "Wrong updated version."); // Get the RecTypes Element in RnResearchNbk Assert.IsNotNull(nbkElement.XPathSelectElement("RnResearchNbk/RecTypes")); // Get the EventTypes Element in RnResearchNbk (should be renamed to RecTypes) Assert.IsNull(nbkElement.XPathSelectElement("RnResearchNbk/EventTypes")); var typesDto = dtoRepos.GetDTO(nbkElement.XPathSelectElement("RnResearchNbk/RecTypes/objsur").Attribute("guid").Value); var typesElement = XElement.Parse(typesDto.Xml); // Should be 5 cmPossibility entries in the list Assert.AreEqual(5, typesElement.XPathSelectElements("CmPossibilityList/Possibilities/objsur").Count()); var anaDto = dtoRepos.GetDTO("82290763-1633-4998-8317-0EC3F5027FBD"); var anaElement = XElement.Parse(anaDto.Xml); Assert.AreEqual("Ana", anaElement.XPathSelectElement("CmPossibility/Abbreviation/AUni[@ws='en']").Value); foreach (var GenRecDto in dtoRepos.AllInstancesSansSubclasses("RnGenericRec")) { var recElement = XElement.Parse(GenRecDto.Xml); var typeSurElement = recElement.XPathSelectElement("RnGenericRec/Type/objsur"); if (typeSurElement.Attribute("guid").Value == "82290763-1633-4998-8317-0EC3F5027FBD") { Assert.IsNotNull(recElement.XPathSelectElement("RnGenericRec/Conclusions")); Assert.AreEqual(19, recElement.Element("RnGenericRec").Elements().Count()); } else { Assert.IsNotNull(recElement.XPathSelectElement("RnGenericRec/Description")); Assert.AreEqual(21, recElement.Elements("RnGenericRec").Elements().Count()); } } // Look for RnEvent records -shouldn't be any Assert.AreEqual(0, dtoRepos.AllInstancesSansSubclasses("RnEvent").Count()); // Look for RnAnalysis records -shouldn't be any Assert.AreEqual(0, dtoRepos.AllInstancesSansSubclasses("RnAnalysis").Count()); }
public void DataMigration7000034Test() { var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000034.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", "CmPicture", "CmFolder", "CmFile", }); 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(8, "CmPicture", "CmObject", new List <string>()); mockMDC.AddClass(9, "CmFolder", "CmObject", new List <string>()); mockMDC.AddClass(10, "CmFile", "CmObject", new List <string>()); IDomainObjectDTORepository repoDto = new DomainObjectDtoRepository(7000033, dtos, mockMDC, Path.GetTempPath()); // Do the migration. m_dataMigrationManager.PerformMigration(repoDto, 7000034, new DummyProgressDlg()); Assert.AreEqual(7000034, repoDto.CurrentModelVersion, "Wrong updated version."); var langProj = repoDto.AllInstancesSansSubclasses("LangProject").First(); var langProjElement = XElement.Parse(langProj.Xml); // Not directly related to this migration, but fixed problem with DataMigrationServices.RemoveIncludingOwnedObjects // and couldn't find a better place to put the test. Need to make sure only empty properties on LangProject // get deleted. Assert.AreEqual("en", langProjElement.Element("AnalysisWss").Element("Uni").Value, "Analysis Writing systems should be preserved."); Assert.IsNull(langProjElement.Element("Styles")); // empty styles in test data should have been removed. // Verify migration worked var pictures = langProjElement.Element("Pictures"); Assert.AreEqual(1, pictures.Elements().Count(), "Should only be one folder in Pictures"); var folder = repoDto.GetDTO(pictures.Elements().First().Attribute("guid").Value); var folderElement = XElement.Parse(folder.Xml); var files = folderElement.Element("Files"); Assert.AreEqual(4, files.Elements().Count(), "Should be four files"); Assert.AreEqual(4, repoDto.AllInstancesSansSubclasses("CmFile").Count(), "Should still be four files"); // Verify ownership is correct foreach (var fileRef in files.Elements()) { var file = repoDto.GetDTO(fileRef.Attribute("guid").Value); var fileElement = XElement.Parse(file.Xml); Assert.AreEqual(folder.Guid, fileElement.Attribute("ownerguid").Value, "All files should be owned by folder"); } // the first CmFile is used in all except CmPictures in the test data var fileGuid = files.Elements().First().Attribute("guid").Value; Assert.AreEqual(4, repoDto.AllInstancesSansSubclasses("CmPicture").Count(), "Should still be four pictures"); int matchCount = 0; foreach (var picture in repoDto.AllInstancesSansSubclasses("CmPicture")) { var pictureElement = XElement.Parse(picture.Xml); if (fileGuid == pictureElement.Element("PictureFile").Element("objsur").Attribute("guid").Value) { matchCount++; } } Assert.AreEqual(3, matchCount, "Should be 3 pictures using first CmFile"); }
public void DataMigration7000024Test1() { int count = 0; var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000024Tests1.xml"); // Set up mock MDC. var mockMDC = new MockMDCForDataMigration(); mockMDC.AddClass(1, "CmObject", null, new List <string> { "CmProject", "CmMajorObject", "RnGenericRec" }); 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> { "RnResearchNbk" }); mockMDC.AddClass(5, "RnResearchNbk", "CmMajorObject", new List <string>()); mockMDC.AddClass(6, "RnGenericRec", "CmObject", new List <string>()); IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000023, dtos, mockMDC, null); m_dataMigrationManager.PerformMigration(dtoRepos, 7000024, new DummyProgressDlg()); //This object should contain a 'Status' property var langProjDto = dtoRepos.AllInstancesSansSubclasses("LangProject").First(); var langProjElement = XElement.Parse(langProjDto.Xml); var langProjStatus = langProjElement.XPathSelectElement("Status/objsur"); Assert.That(langProjStatus, Is.Not.Null, "We should now have a 'Status' element on LangProj"); //This object should not contain an 'AnalysysStatus' property var langProjAnalysisStatus = langProjElement.XPathSelectElement("AnalysisStatus"); Assert.That(langProjAnalysisStatus, Is.Null, "LangProject AnalysisStatus Property should not exist any more"); var langPossListGuid = langProjStatus.Attribute("guid").Value; var langPossListDto = dtoRepos.GetDTO(langPossListGuid); var langPossListElement = XElement.Parse(langPossListDto.Xml); Assert.That(langPossListElement.Attribute("ownerguid").Value.ToLowerInvariant(), Is.EqualTo("b5a90c21-d8b2-4d4a-94f6-1b1fbeac3388"), "Status element should be owned by LangProject"); //There should be 1 possibility in the status list; 'Confirmed'. var possibilities = langPossListElement.XPathSelectElement("Possibilities"); var possibilitiesDto = possibilities.Descendants(); Assert.That(possibilitiesDto.Count(), Is.EqualTo(1), "We should have exactly one status item in the PL"); // Verify that the RnGenericRec Entries are copied over (they won't have statuses). var rnGenericRecDto = dtoRepos.GetDirectlyOwnedDTOs("4e3802af-98cd-48c4-b6ff-3cb0a5fd1310"); Assert.That(rnGenericRecDto.Count(), Is.EqualTo(7), "There should be exactly seven RnGeneric records"); foreach (var rnRec in rnGenericRecDto) { var rnGenericRecElement = XElement.Parse(rnRec.Xml); var rnStatusElem = rnGenericRecElement.XPathSelectElement("Status/objsur"); Assert.That(rnStatusElem, Is.Null, "None of the RnGeneric records should have statuses"); } Assert.AreEqual(7000024, dtoRepos.CurrentModelVersion, "Wrong updated version."); }
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); 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 DataMigration7000019Test() { string storePath = Path.Combine(Path.GetTempPath(), FdoFileHelper.ksWritingSystemsDir); PrepareStore(storePath); string globalStorePath = DirectoryFinder.GlobalWritingSystemStoreDirectory; PrepareStore(globalStorePath); var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000019Tests.xml"); IFwMetaDataCacheManaged mockMdc = SetupMdc(); IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000018, dtos, mockMdc, Path.GetTempPath(), FwDirectoryFinder.FdoDirectories); // 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()); DomainObjectDTO lpDto = dtoRepos.AllInstancesSansSubclasses("LangProject").First(); XElement lpElem = XElement.Parse(lpDto.Xml); 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); var analysisWss = (string)lpElem.Element("AnalysisWss"); //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 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", FwDirectoryFinder.FdoDirectories); //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 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); 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 DataMigration7000022Test() { var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000022.xml"); // Set up mock MDC. var mockMDC = new MockMDCForDataMigration(); mockMDC.AddClass(1, "CmObject", null, new List <string> { "LangProject", "CmMajorObject", "DsDiscourseData" }); mockMDC.AddClass(2, "LangProject", "CmObject", new List <string>()); mockMDC.AddClass(3, "DsDiscourseData", "CmObject", new List <string>()); mockMDC.AddClass(4, "CmMajorObject", "CmObject", new List <string> { "RnResearchNbk", "CmPossibilityList", "LexDb" }); mockMDC.AddClass(5, "RnResearchNbk", "CmMajorObject", new List <string>()); mockMDC.AddClass(6, "LexDb", "CmMajorObject", new List <string>()); mockMDC.AddClass(7, "CmPossibilityList", "CmMajorObject", new List <string>()); IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000021, dtos, mockMDC, null, FwDirectoryFinder.FdoDirectories); // SUT m_dataMigrationManager.PerformMigration(dtoRepos, 7000022, new DummyProgressDlg()); // Verification section Assert.AreEqual(7000022, dtoRepos.CurrentModelVersion, "Wrong updated version."); // We should have 26 migrated possibility lists plus one unowned Custom list // that shouldn't be touched. var lists = dtoRepos.AllInstancesSansSubclasses("CmPossibilityList"); Assert.AreEqual(27, lists.Count(), "Wrong number of Possibility Lists found."); // We need 'LangProject' and its DsDiscourseData, LexDb and RnResearchNbk objects. var lpDto = dtoRepos.AllInstancesSansSubclasses("LangProject").FirstOrDefault(); Assert.IsNotNull(lpDto); var lpElement = XElement.Parse(lpDto.Xml); var discourseDataDto = dtoRepos.AllInstancesSansSubclasses("DsDiscourseData").FirstOrDefault(); Assert.IsNotNull(discourseDataDto); var dsDataElement = XElement.Parse(discourseDataDto.Xml); var lexDbDto = dtoRepos.AllInstancesSansSubclasses("LexDb").FirstOrDefault(); Assert.IsNotNull(lexDbDto); var lexDbElement = XElement.Parse(lexDbDto.Xml); var nbkDto = dtoRepos.AllInstancesSansSubclasses("RnResearchNbk").FirstOrDefault(); Assert.IsNotNull(nbkDto); var nbkElement = XElement.Parse(nbkDto.Xml); // List 1: Get ChartMarkers list from DsDiscourseData var listNameElement = GetPossibilityListNameElement(dtoRepos, dsDataElement, "ChartMarkers"); var altList = AssertNameHasXAlternates(listNameElement, 8); AssertNameAltExists(altList, "en", "Text Chart Markers"); AssertNameAltExists(altList, "es", "Marcadores para la tabla de texto"); AssertNameAltExists(altList, "fa", "نشانه جدول متن"); AssertNameAltExists(altList, "fr", "Étiquettes de tableau de texte"); AssertNameAltExists(altList, "id", "Penanda-penanda Bagan Teks"); AssertNameAltExists(altList, "pt", "Marcadores de Quadro de Textos"); AssertNameAltExists(altList, "ru", "Метки схемы текста"); AssertNameAltExists(altList, "zh-CN", "文本图表标记"); // List 3: Get AffixCategories list from LangProject listNameElement = GetPossibilityListNameElement(dtoRepos, lpElement, "AffixCategories"); altList = AssertNameHasXAlternates(listNameElement, 1); AssertNameAltExists(altList, "en", "Affix Categories"); // List 12: Get Positions list from LangProject listNameElement = GetPossibilityListNameElement(dtoRepos, lpElement, "Positions"); altList = AssertNameHasXAlternates(listNameElement, 7); AssertNameAltExists(altList, "en", "Positions"); AssertNameAltExists(altList, "fa", "شغلها"); AssertNameAltExists(altList, "fr", "Positions"); AssertNameAltExists(altList, "id", "Posisi"); AssertNameAltExists(altList, "pt", "Posições"); AssertNameAltExists(altList, "ru", "Позиции"); AssertNameAltExists(altList, "zh-CN", "位置"); // List 16: Get TimeOfDay list from LangProject listNameElement = GetPossibilityListNameElement(dtoRepos, lpElement, "TimeOfDay"); altList = AssertNameHasXAlternates(listNameElement, 2); AssertNameAltExists(altList, "en", "Time Of Day"); AssertNameAltExists(altList, "fr", "Moment de la journée"); // List 19: Get DomainTypes list from LexDb listNameElement = GetPossibilityListNameElement(dtoRepos, lexDbElement, "DomainTypes"); altList = AssertNameHasXAlternates(listNameElement, 8); AssertNameAltExists(altList, "en", "Academic Domains"); AssertNameAltExists(altList, "es", "Dominios académicos"); AssertNameAltExists(altList, "fa", "حوضههای دانشگاهی و علمی"); AssertNameAltExists(altList, "fr", "Domaines techniques"); AssertNameAltExists(altList, "id", "Ranah Akademis"); AssertNameAltExists(altList, "pt", "Domínios Acadêmicos"); AssertNameAltExists(altList, "ru", "Области знания"); AssertNameAltExists(altList, "zh-CN", "学术领域"); // List 26: Get the RecTypes Element in RnResearchNbk listNameElement = GetPossibilityListNameElement(dtoRepos, nbkElement, "RecTypes"); altList = AssertNameHasXAlternates(listNameElement, 2); AssertNameAltExists(altList, "en", "Notebook Record Types"); AssertNameAltExists(altList, "fr", "Types d'enregistrement de carnet"); }
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", FwDirectoryFinder.FdoDirectories); //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); }
public void DataMigration7000024Test() { int count = 0; var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000024Tests.xml"); // Set up mock MDC. var mockMDC = new MockMDCForDataMigration(); mockMDC.AddClass(1, "CmObject", null, new List <string> { "CmProject", "CmMajorObject", "RnGenericRec", "LexEntry", "LexSense", "CmPossibility" }); 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> { "RnResearchNbk", "CmPossibilityList", "LexDb" }); mockMDC.AddClass(5, "RnResearchNbk", "CmMajorObject", new List <string>()); mockMDC.AddClass(6, "RnGenericRec", "CmObject", new List <string>()); mockMDC.AddClass(7, "CmPossibilityList", "CmMajorObject", new List <string>()); mockMDC.AddClass(8, "LexDb", "CmMajorObject", new List <string> { }); mockMDC.AddClass(9, "LexEntry", "CmObject", new List <string>()); mockMDC.AddClass(10, "LexSense", "CmObject", new List <string>()); mockMDC.AddClass(11, "CmPossibility", "CmObject", new List <string>()); IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000023, dtos, mockMDC, null); m_dataMigrationManager.PerformMigration(dtoRepos, 7000024, new DummyProgressDlg()); //This object should contain a 'Status' property var langProjDto = dtoRepos.AllInstancesSansSubclasses("LangProject").First(); var langProjElement = XElement.Parse(langProjDto.Xml); var langProjStatus = langProjElement.XPathSelectElement("Status/objsur"); Assert.That(langProjStatus, Is.Not.Null, "We should now have a 'Status' element on LangProj"); //This object should not contain an 'AnalysysStatus' property var langProjAnalysisStatus = langProjElement.XPathSelectElement("AnalysisStatus"); Assert.That(langProjAnalysisStatus, Is.Null, "LangProject AnalysisStatus Property should not exist any more"); Assert.That(langProjStatus.Attribute("guid").Value.ToLowerInvariant(), Is.EqualTo("0084b4d9-6c1e-4d63-9c66-ff22764ef171"), "Status element should preserve objsur guid of old Analysis Status"); //This LexDb element should not contain a 'Status' property var lexDbDto = dtoRepos.AllInstancesSansSubclasses("LexDb").First(); var lexDbElement = XElement.Parse(lexDbDto.Xml); var lexDbStatus = lexDbElement.XPathSelectElement("Status"); Assert.That(lexDbStatus, Is.Null, "LexDb Status Property exists but should have been deleted"); //The 5 resulting possibilities should be 'Confirmed', 'Disproved', 'Pending', ''Tentative', and 'Ann'. var possListDto = dtoRepos.GetDirectlyOwnedDTOs("0084B4D9-6C1E-4D63-9C66-FF22764EF171"); Assert.That(possListDto.Count(), Is.EqualTo(6), "We should have exactly six status items in the PL"); var names = new HashSet <string>(); foreach (var possibility in possListDto) { var possElement = XElement.Parse(possibility.Xml); var nameElt = possElement.XPathSelectElement("Name/AUni[@ws='en']"); if (nameElt == null) { nameElt = possElement.XPathSelectElement("Name/AUni[@ws='id']"); } var ttype = nameElt.Value; names.Add(ttype); switch (ttype) { case "Confirmed": case "Tentative": case "Disproved": case "Pending": case "Ann": case "Foreign": break; default: Assert.Fail(ttype + " is in the CmPossibility List"); break; } } Assert.That(names, Has.Count.EqualTo(6), "One of the expected possibilities is missing!"); // Verify that the LexSense Entries point to the new status entries. var lexSenseDto = dtoRepos.GetDirectlyOwnedDTOs("fd6bb890-bb84-4920-954d-40d1e987b683"); Assert.That(lexSenseDto.Count(), Is.EqualTo(5), "There should be exactly five senses"); foreach (var lexSense in lexSenseDto) { var lexSenseElement = XElement.Parse(lexSense.Xml); var ttype = lexSenseElement.XPathSelectElement("Gloss/AUni[@ws='en']").Value; switch (ttype) { case "Aardvark": //Make sure the Status's Guid this LexSense status is the one owned by LangProject. Assert.That(lexSenseElement.XPathSelectElement("Status/objsur").Attribute("guid").Value, Is.EqualTo("8D87FC8A-593E-4C84-A9ED-193879D08585"), ttype + " doesn''t point to the correct possibility."); break; case "Aardvark2": //Make sure the ownerguid of the Possibility for this LexSense status is the cmPossibilityList owned by langProject var aardDto = dtoRepos.GetDTO(lexSenseElement.XPathSelectElement("Status/objsur").Attribute("guid").Value); var aardStatusElement = XElement.Parse(aardDto.Xml); Assert.That(aardStatusElement.Attribute("ownerguid").Value.ToUpperInvariant(), Is.EqualTo("0084B4D9-6C1E-4D63-9C66-FF22764EF171"), ttype + " ownerguid isn't correct."); Assert.AreEqual(aardStatusElement.XPathSelectElement("Name/AUni[@ws='en']").Value, "Ann", ttype + " Possibility pointed to has the wrong name."); break; case "Aardvark3": //Make sure the Status's Guid this LexSense status is the one owned by LangProject. Assert.That(lexSenseElement.XPathSelectElement("Status/objsur").Attribute("guid").Value.ToUpperInvariant, Is.EqualTo("8D87FC8A-593E-4C84-A9ED-193879D08585"), ttype + " doesn''t point to the correct possibility."); break; case "Aardvark4": //Make sure the Status's Guid this LexSense status is the one owned by LangProject. Assert.That(lexSenseElement.XPathSelectElement("Status"), Is.Null, ttype + " does have a status."); break; default: Assert.Pass(ttype + " is in the LexSense List"); break; } } // Verify that the RnGenericRec Entries point to the new status entries. var rnGenericRecDto = dtoRepos.GetDirectlyOwnedDTOs("4e3802af-98cd-48c4-b6ff-3cb0a5fd1310"); Assert.That(rnGenericRecDto.Count(), Is.EqualTo(7), "There should be exactly seven RnGeneric records"); foreach (var rnRec in rnGenericRecDto) { var rnGenericRecElement = XElement.Parse(rnRec.Xml); var rnStatusElem = rnGenericRecElement.XPathSelectElement("Status/objsur"); if (rnStatusElem == null) { continue; } var rnStatusGuid = rnStatusElem.Attribute("guid").Value; var rnPossibilityDto = dtoRepos.GetDTO(rnStatusGuid); var rnPossibilityElement = XElement.Parse(rnPossibilityDto.Xml); var rnNameElem = rnPossibilityElement.XPathSelectElement("Name/AUni[@ws='en']").Value; var rnPossibilityOwnerGuid = rnPossibilityElement.Attribute("ownerguid").Value; switch (rnGenericRecElement.Attribute("guid").Value.ToLowerInvariant()) { case "611739fe-8fe2-4d16-8570-b9d46c339e6e": VerifyOwnerguidAndStatus(rnPossibilityOwnerGuid, "RnGenericRec record 1 status record isn't owned by LangProj.", rnNameElem, "Pending", "RnGenericRec record 1 doesn''t point to a status of ''Pending''."); break; case "612739fe-8fe2-4d16-8570-b9d46c339e6e": VerifyOwnerguidAndStatus(rnPossibilityOwnerGuid, "RnGenericRec record 2 status record isn't owned by LangProj.", rnNameElem, "Confirmed", "RnGenericRec record 2 doesn''t point to a status of ''Confirmed''."); break; case "613739fe-8fe2-4d16-8570-b9d46c339e6e": VerifyOwnerguidAndStatus(rnPossibilityOwnerGuid, "RnGenericRec record 3 status record isn't owned by LangProj.", rnNameElem, "Tentative", "RnGenericRec record 3 doesn''t point to a status of ''Tentative''."); break; case "614739fe-8fe2-4d16-8570-b9d46c339e6e": VerifyOwnerguidAndStatus(rnPossibilityOwnerGuid, "RnGenericRec record 4 status record isn't owned by LangProj.", rnNameElem, "Confirmed", "RnGenericRec record 4 doesn''t point to a status of ''Approved''."); break; case "615739fe-8fe2-4d16-8570-b9d46c339e6e": VerifyOwnerguidAndStatus(rnPossibilityOwnerGuid, "RnGenericRec record 5 status record isn't owned by LangProj.", rnNameElem, "Disproved", "RnGenericRec record 5 doesn''t point to a status of ''Disproved''."); break; case "616739fe-8fe2-4d16-8570-b9d46c339e6e": VerifyOwnerguidAndStatus(rnPossibilityOwnerGuid, "RnGenericRec record 6 status record isn't owned by LangProj.", rnNameElem, "Disproved", "RnGenericRec record 6 doesn''t point to a status of ''Ann''."); break; default: Assert.Fail("There is no RnGenericRec with a guid of: " + rnGenericRecElement.Attribute("guid").Value.ToLowerInvariant()); break; } } Assert.AreEqual(7000024, dtoRepos.CurrentModelVersion, "Wrong updated version."); }