Пример #1
0
        public void SimpleUndoRedo()
        {
            ExecuteMigrateDiagramNodesTest(
                "SimpleUndoRedo",
                (artifact, commandProcessorContext) =>
            {
                var baseType =
                    (ConceptualEntityType)
                    CreateEntityTypeCommand.CreateEntityTypeAndEntitySetWithDefaultNames(commandProcessorContext);
                var derivedType = CreateEntityTypeCommand.CreateDerivedEntityType(
                    commandProcessorContext, "SubType", baseType, true);

                Dte.ExecuteCommandForOpenDocument(artifact.LocalPath(), "Edit.Undo");
                Assert.IsTrue(!artifact.ConceptualModel.EntityTypes().Any(et => et.LocalName.Value == derivedType.LocalName.Value));

                Dte.ExecuteCommandForOpenDocument(artifact.LocalPath(), "Edit.Undo");
                Assert.IsTrue(!artifact.ConceptualModel.EntityTypes().Any(et => et.LocalName.Value == baseType.LocalName.Value));

                Dte.ExecuteCommandForOpenDocument(artifact.LocalPath(), "Edit.Redo");
                Dte.ExecuteCommandForOpenDocument(artifact.LocalPath(), "Edit.Redo");

                Assert.IsNotNull(
                    artifact.ConceptualModel.EntityTypes().SingleOrDefault(et => et.LocalName.Value == baseType.LocalName.Value));

                // Verify that derived type and inheritance are recreated.
                derivedType =
                    (ConceptualEntityType)
                    artifact.ConceptualModel.EntityTypes().SingleOrDefault(et => et.LocalName.Value == derivedType.LocalName.Value);
                Assert.IsNotNull(derivedType);
                Assert.AreEqual(baseType.LocalName.Value, derivedType.BaseType.Target.LocalName.Value);
            });
        }
Пример #2
0
        internal override void Invoke(CommandProcessorContext cpc)
        {
            EntityType modelEntity = null;

            if (_dialog.BaseEntityType != null)
            {
                modelEntity = CreateEntityTypeCommand.CreateDerivedEntityType(cpc, _dialog.EntityName, _dialog.BaseEntityType, false);
            }
            else
            {
                modelEntity = CreateEntityTypeCommand.CreateConceptualEntityTypeAndEntitySetAndProperty(
                    cpc,
                    _dialog.EntityName,
                    _dialog.EntitySetName,
                    _dialog.CreateKeyProperty,
                    _dialog.KeyPropertyName,
                    _dialog.KeyPropertyType,
                    ModelHelper.CanTypeSupportIdentity(_dialog.KeyPropertyType)
                        ? ModelConstants.StoreGeneratedPattern_Identity
                        : ModelConstants.StoreGeneratedPattern_None,
                    false);
            }
        }