Exemplo n.º 1
0
        public void DataMigration7000037Test()
        {
            // Bring in data from xml file.
            var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000037.xml");

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

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

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

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

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

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

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

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