Beispiel #1
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"));
        }