コード例 #1
0
        public void UniElementPropertiesAreRemoved()
        {
            var mockMdc = new MockMDCForDataMigration();

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

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

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

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

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

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

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

            instance   = XElement.Parse(dtoRepos.AllInstancesSansSubclasses("ClassWithInheritedUnicodeProperties").First().Xml);
            uniElement = instance.Element("UnicodePropWithAttrs").Element("Uni");
            Assert.IsFalse(uniElement.HasAttributes);
            Assert.AreEqual("Inherited With Attrs", uniElement.Value);
            uniElement = instance.Element("UnicodePropWithoutAttrs").Element("Uni");
            Assert.IsFalse(uniElement.HasAttributes);
            Assert.AreEqual("Inherited Without Attrs", uniElement.Value);
        }
コード例 #2
0
        public void AllInheritedCustomBasicDataPropertiesExistAfterDataMigration66()
        {
            var mockMdc = new MockMDCForDataMigration();

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

            // These are all present in the original data file and act as controls.
            // They should not be changed.
            mockMdc.AddField(1001, "RegularOwningAtomic", CellarPropertyType.OwningAtom, 2);
            mockMdc.AddCustomField("CmObject", "ExtantOwningAtomic", CellarPropertyType.OwningAtom, 2);
            mockMdc.AddCustomField("CmObject", "ExtantBooleanProperty", CellarPropertyType.Boolean, 0);
            mockMdc.AddCustomField("CmObject", "ExtantGenDateProperty", CellarPropertyType.GenDate, 0);
            mockMdc.AddCustomField("CmObject", "ExtantGuidProperty", CellarPropertyType.Guid, 0);
            // Not used in model yet (as of 23 march 2013) var extantFloatFlid = mockMdc.AddCustomField("CmObject", "ExtantFloatProperty", CellarPropertyType.Float, 0);
            mockMdc.AddCustomField("CmObject", "ExtantIntegerProperty", CellarPropertyType.Integer, 0);
            // Not used in model yet (as of 23 march 2013) var extantNumericFlid = mockMdc.AddCustomField("CmObject", "ExtantNumericProperty", CellarPropertyType.Numeric, 0);
            mockMdc.AddCustomField("CmObject", "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.AddCustomField("CmObject", "NewBooleanProperty", CellarPropertyType.Boolean, 0);
            mockMdc.AddCustomField("CmObject", "NewGenDateProperty", CellarPropertyType.GenDate, 0);
            mockMdc.AddCustomField("CmObject", "NewGuidProperty", CellarPropertyType.Guid, 0);
            // Not used in model yet (as of 23 march 2013) var missingFloatFlid = mockMdc.AddCustomField("CmObject", "NewFloatProperty", CellarPropertyType.Float, 0);
            mockMdc.AddCustomField("CmObject", "NewIntegerProperty", CellarPropertyType.Integer, 0);
            // Not used in model yet (as of 23 march 2013) var missingNumericFlid = mockMdc.AddCustomField("CmObject", "NewNumericProperty", CellarPropertyType.Numeric, 0);
            mockMdc.AddCustomField("CmObject", "NewTimeProperty", CellarPropertyType.Time, 0);

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

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

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

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

            // Check the newly added props to make sure they are present and using default values.
            Assert.AreEqual("False", GetCustomPropertyValue(magnet, "NewBooleanProperty"));
            Assert.AreEqual("-000000000", GetCustomPropertyValue(magnet, "NewGenDateProperty"));
            Assert.AreEqual(Guid.Empty.ToString(), GetCustomPropertyValue(magnet, "NewGuidProperty"));
            Assert.AreEqual("0", GetCustomPropertyValue(magnet, "NewIntegerProperty"));
            Assert.IsNotNull(GetCustomPropertyValue(magnet, "NewTimeProperty"));
        }
コード例 #3
0
        public void DataMigration7000061Test()
        {
            var mockMdc = new MockMDCForDataMigration();

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

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

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

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

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

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

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

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

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

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

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

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

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

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