Exemple #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);
            });
        }
 public static EntityType CreateEntityTypeFrom(CreateEntityTypeCommand cmd)
 => new EntityType
 {
     Name = cmd.Name,
     SupportedDocuments = cmd.SupportedDocumentTypesIds
                          .Select(id => new EntityTypeDocumentType {
         DocumentTypeId = id
     }).ToList()
 };
Exemple #3
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);
            }
        }
Exemple #4
0
        public void SimpleAddEntity()
        {
            ExecuteMigrateDiagramNodesTest(
                "SimpleAddEntity",
                (artifact, commandProcessorContext) =>
            {
                var cet =
                    CreateEntityTypeCommand.CreateConceptualEntityTypeAndEntitySetAndProperty(
                        commandProcessorContext,
                        "entity1",
                        "entity1set",
                        true,
                        "id",
                        "String",
                        ModelConstants.StoreGeneratedPattern_Identity,
                        true);
                Assert.IsNotNull(cet != null, "EntityType is not created");

                // Verify that EntityTypeShape is created in diagram1.
                Assert.IsNotNull(
                    artifact.DiagramArtifact.Diagrams.FirstDiagram.EntityTypeShapes.SingleOrDefault(
                        ets => ets.EntityType.Target == cet));
            });
        }
 public IActionResult Post([FromBody] CreateEntityTypeCommand msg)
 => createCommand.Execute(msg).Match(
     Succ: x => x.Match <IActionResult>(Ok, BadRequest),
     Fail: ex => StatusCode(500, ex));
Exemple #6
0
 internal override void Invoke(CommandProcessorContext cpc)
 {
     CreateEntityTypeCommand.CreateEntityTypeAndEntitySetWithDefaultNames(cpc);
 }