test/Misc/EFTools/InProcTests/UndoRedoTestsRemote.cs
/// <summary>
///     Simple Inheritance tests:
///     1. Undo/Redo Creation of Inheritance
///     2. Undo/Redo Deletion of Inheritance
///     3. Undo/Redo Changing BaseType of Derived EntityType
///     4. Multiple successive undos/redos of creating 3-level inheritance
/// </summary>
Simple Inheritance tests:
1. Undo/Redo Creation of Inheritance
2. Undo/Redo Deletion of Inheritance
3. Undo/Redo Changing BaseType of Derived EntityType
4. Multiple successive undos/redos of creating 3-level inheritance
Simple Inheritance tests : 1 . Undo / Redo Creation of Inheritance 2 . Undo / Redo Deletion of Inheritance 3 . Undo / Redo Changing BaseType of Derived EntityType 4 . Multiple successive undos / redos of creating 3 - level inheritance
[TestMethod]
        [HostType("VS IDE")]
        public void Simple_Inheritance()
        {
            UITestRunner.Execute(TestContext.TestName, 
                () =>
                    {
                        const string typePrefix = "Simple_Inheritance";
                        const string testName = "UndoRedo." + typePrefix;
                        ExecuteUndoRedoTest(
                            testName, "BlankModel.edmx", (commandProcessorContext, artifact) =>
                                {
                                    const string entity1TypeName = typePrefix + "_EntityType1";
                                    const string entity2TypeName = typePrefix + "_EntityType2";
                                    const string entity3TypeName = typePrefix + "_EntityType3";
                                    var dte = VsIdeTestHostContext.Dte;
                                    ConceptualEntityType entityType1;
                                    ConceptualEntityType entityType2;
                                    ConceptualEntityType entityType3;
                                    CreateDefaultEntityType(commandProcessorContext, entity1TypeName, typePrefix + "_EntitySet1");
                                    CreateDefaultEntityType(commandProcessorContext, entity2TypeName, typePrefix + "_EntitySet2");
                                    CreateDefaultEntityType(commandProcessorContext, entity3TypeName, typePrefix + "_EntitySet3");
                                    entityType1 = artifact.GetFreshConceptualEntity(entity1TypeName);
                                    entityType2 = artifact.GetFreshConceptualEntity(entity2TypeName);
                                    Assert.IsNull(entityType2.BaseType.Target);
                                    new CommandProcessor(commandProcessorContext, new CreateInheritanceCommand(entityType2, entityType1))
                                        .Invoke();
                                    Assert.AreEqual(
                                        artifact.GetFreshConceptualEntity(entity1TypeName),
                                        artifact.GetFreshConceptualEntity(entity2TypeName).BaseType.Target);
                                    dte.ExecuteCommandForOpenDocument(artifact.LocalPath(), UndoCommand);
                                    Assert.IsNull(artifact.GetFreshConceptualEntity(entity2TypeName).BaseType.Target);
                                    dte.ExecuteCommandForOpenDocument(artifact.LocalPath(), RedoCommand);
                                    Assert.AreEqual(
                                        artifact.GetFreshConceptualEntity(entity1TypeName),
                                        artifact.GetFreshConceptualEntity(entity2TypeName).BaseType.Target);
                                    new CommandProcessor(
                                        commandProcessorContext,
                                        new DeleteInheritanceCommand(entityType2)).Invoke();
                                    Assert.IsNull(artifact.GetFreshConceptualEntity(entity2TypeName).BaseType.Target);
                                    dte.ExecuteCommandForOpenDocument(artifact.LocalPath(), UndoCommand);
                                    Assert.AreEqual(
                                        artifact.GetFreshConceptualEntity(entity1TypeName),
                                        artifact.GetFreshConceptualEntity(entity2TypeName).BaseType.Target);
                                    dte.ExecuteCommandForOpenDocument(artifact.LocalPath(), RedoCommand);
                                    Assert.IsNull(artifact.GetFreshConceptualEntity(entity2TypeName).BaseType.Target);
                                    dte.ExecuteCommandForOpenDocument(artifact.LocalPath(), UndoCommand);
                                    Assert.AreEqual(
                                        artifact.GetFreshConceptualEntity(entity1TypeName),
                                        artifact.GetFreshConceptualEntity(entity2TypeName).BaseType.Target);
                                    entityType3 = artifact.GetFreshConceptualEntity(entity3TypeName);
                                    ViewUtils.SetBaseEntityType(commandProcessorContext, entityType2, entityType3);
                                    Assert.AreEqual(
                                        artifact.GetFreshConceptualEntity(entity3TypeName),
                                        artifact.GetFreshConceptualEntity(entity2TypeName).BaseType.Target);
                                    dte.ExecuteCommandForOpenDocument(artifact.LocalPath(), UndoCommand);
                                    Assert.AreEqual(
                                        artifact.GetFreshConceptualEntity(entity1TypeName),
                                        artifact.GetFreshConceptualEntity(entity2TypeName).BaseType.Target);
                                    dte.ExecuteCommandForOpenDocument(artifact.LocalPath(), RedoCommand);
                                    Assert.AreEqual(
                                        artifact.GetFreshConceptualEntity(entity3TypeName),
                                        artifact.GetFreshConceptualEntity(entity2TypeName).BaseType.Target);
                                    entityType1 = artifact.GetFreshConceptualEntity(entity1TypeName);
                                    entityType2 = artifact.GetFreshConceptualEntity(entity2TypeName);
                                    new CommandProcessor(
                                        commandProcessorContext,
                                        new CreateInheritanceCommand(entityType1, entityType2)).Invoke();
                                    Assert.AreEqual(
                                        artifact.GetFreshConceptualEntity(entity3TypeName),
                                        artifact.GetFreshConceptualEntity(entity2TypeName).BaseType.Target);
                                    Assert.AreEqual(
                                        artifact.GetFreshConceptualEntity(entity2TypeName),
                                        artifact.GetFreshConceptualEntity(entity1TypeName).BaseType.Target);
                                    dte.ExecuteCommandForOpenDocument(artifact.LocalPath(), UndoCommand);
                                    dte.ExecuteCommandForOpenDocument(artifact.LocalPath(), UndoCommand);
                                    Assert.AreEqual(
                                        artifact.GetFreshConceptualEntity(entity1TypeName),
                                        artifact.GetFreshConceptualEntity(entity2TypeName).BaseType.Target);
                                    Assert.IsNull(artifact.GetFreshConceptualEntity(entity1TypeName).BaseType.Target);
                                    dte.ExecuteCommandForOpenDocument(artifact.LocalPath(), RedoCommand);
                                    dte.ExecuteCommandForOpenDocument(artifact.LocalPath(), RedoCommand);
                                    Assert.AreEqual(
                                        artifact.GetFreshConceptualEntity(entity3TypeName),
                                        artifact.GetFreshConceptualEntity(entity2TypeName).BaseType.Target);
                                    Assert.AreEqual(
                                        artifact.GetFreshConceptualEntity(entity2TypeName),
                                        artifact.GetFreshConceptualEntity(entity1TypeName).BaseType.Target);
                                     2, DELETE ENTITY TYPE1, UNDO 2, REDO 2
                                    new CommandProcessor(commandProcessorContext, new DeleteInheritanceCommand(entityType1)).Invoke();
                                    entityType1 = artifact.GetFreshConceptualEntity(entity1TypeName);
                                    Assert.IsNull(entityType1.BaseType.Target);
                                    new CommandProcessor(commandProcessorContext, entityType1.GetDeleteCommand()).Invoke();
                                    Assert.IsNull(artifact.GetFreshConceptualEntity(entity1TypeName));
                                    dte.ExecuteCommandForOpenDocument(artifact.LocalPath(), UndoCommand);
                                    dte.ExecuteCommandForOpenDocument(artifact.LocalPath(), UndoCommand);
                                    Assert.IsNotNull(artifact.GetFreshConceptualEntity(entity1TypeName));
                                    Assert.AreEqual(
                                        artifact.GetFreshConceptualEntity(entity3TypeName),
                                        artifact.GetFreshConceptualEntity(entity2TypeName).BaseType.Target);
                                    Assert.AreEqual(
                                        artifact.GetFreshConceptualEntity(entity2TypeName),
                                        artifact.GetFreshConceptualEntity(entity1TypeName).BaseType.Target);
                                    dte.ExecuteCommandForOpenDocument(artifact.LocalPath(), RedoCommand);
                                    dte.ExecuteCommandForOpenDocument(artifact.LocalPath(), RedoCommand);
                                    Assert.IsNull(artifact.GetFreshConceptualEntity(entity1TypeName));
                                });
                    });
        }
[ TestMethod ] [ HostType ( " " ) ] public void Simple_Inheritance ( ) { UITestRunner . Execute ( TestContext . TestName , ( ) => { const string typePrefix = " " ; const string testName = " " + typePrefix ; ExecuteUndoRedoTest ( testName , " " , ( commandProcessorContext , artifact ) => { const string entity1TypeName = typePrefix + " " ; const string entity2TypeName = typePrefix + " " ; const string entity3TypeName = typePrefix + " " ; var dte = VsIdeTestHostContext . Dte ; ConceptualEntityType entityType1 ; ConceptualEntityType entityType2 ; ConceptualEntityType entityType3 ; CreateDefaultEntityType ( commandProcessorContext , entity1TypeName , typePrefix + " " ) ; CreateDefaultEntityType ( commandProcessorContext , entity2TypeName , typePrefix + " " ) ; CreateDefaultEntityType ( commandProcessorContext , entity3TypeName , typePrefix + " " ) ; entityType1 = artifact . GetFreshConceptualEntity ( entity1TypeName ) ; entityType2 = artifact . GetFreshConceptualEntity ( entity2TypeName ) ; Assert . IsNull ( entityType2 . BaseType . Target ) ; new CommandProcessor ( commandProcessorContext , new CreateInheritanceCommand ( entityType2 , entityType1 ) ) . Invoke ( ) ; Assert . AreEqual ( artifact . GetFreshConceptualEntity ( entity1TypeName ) , artifact . GetFreshConceptualEntity ( entity2TypeName ) . BaseType . Target ) ; dte . ExecuteCommandForOpenDocument ( artifact . LocalPath ( ) , UndoCommand ) ; Assert . IsNull ( artifact . GetFreshConceptualEntity ( entity2TypeName ) . BaseType . Target ) ; dte . ExecuteCommandForOpenDocument ( artifact . LocalPath ( ) , RedoCommand ) ; Assert . AreEqual ( artifact . GetFreshConceptualEntity ( entity1TypeName ) , artifact . GetFreshConceptualEntity ( entity2TypeName ) . BaseType . Target ) ; new CommandProcessor ( commandProcessorContext , new DeleteInheritanceCommand ( entityType2 ) ) . Invoke ( ) ; Assert . IsNull ( artifact . GetFreshConceptualEntity ( entity2TypeName ) . BaseType . Target ) ; dte . ExecuteCommandForOpenDocument ( artifact . LocalPath ( ) , UndoCommand ) ; Assert . AreEqual ( artifact . GetFreshConceptualEntity ( entity1TypeName ) , artifact . GetFreshConceptualEntity ( entity2TypeName ) . BaseType . Target ) ; dte . ExecuteCommandForOpenDocument ( artifact . LocalPath ( ) , RedoCommand ) ; Assert . IsNull ( artifact . GetFreshConceptualEntity ( entity2TypeName ) . BaseType . Target ) ; dte . ExecuteCommandForOpenDocument ( artifact . LocalPath ( ) , UndoCommand ) ; Assert . AreEqual ( artifact . GetFreshConceptualEntity ( entity1TypeName ) , artifact . GetFreshConceptualEntity ( entity2TypeName ) . BaseType . Target ) ; entityType3 = artifact . GetFreshConceptualEntity ( entity3TypeName ) ; ViewUtils . SetBaseEntityType ( commandProcessorContext , entityType2 , entityType3 ) ; Assert . AreEqual ( artifact . GetFreshConceptualEntity ( entity3TypeName ) , artifact . GetFreshConceptualEntity ( entity2TypeName ) . BaseType . Target ) ; dte . ExecuteCommandForOpenDocument ( artifact . LocalPath ( ) , UndoCommand ) ; Assert . AreEqual ( artifact . GetFreshConceptualEntity ( entity1TypeName ) , artifact . GetFreshConceptualEntity ( entity2TypeName ) . BaseType . Target ) ; dte . ExecuteCommandForOpenDocument ( artifact . LocalPath ( ) , RedoCommand ) ; Assert . AreEqual ( artifact . GetFreshConceptualEntity ( entity3TypeName ) , artifact . GetFreshConceptualEntity ( entity2TypeName ) . BaseType . Target ) ; entityType1 = artifact . GetFreshConceptualEntity ( entity1TypeName ) ; entityType2 = artifact . GetFreshConceptualEntity ( entity2TypeName ) ; new CommandProcessor ( commandProcessorContext , new CreateInheritanceCommand ( entityType1 , entityType2 ) ) . Invoke ( ) ; Assert . AreEqual ( artifact . GetFreshConceptualEntity ( entity3TypeName ) , artifact . GetFreshConceptualEntity ( entity2TypeName ) . BaseType . Target ) ; Assert . AreEqual ( artifact . GetFreshConceptualEntity ( entity2TypeName ) , artifact . GetFreshConceptualEntity ( entity1TypeName ) . BaseType . Target ) ; dte . ExecuteCommandForOpenDocument ( artifact . LocalPath ( ) , UndoCommand ) ; dte . ExecuteCommandForOpenDocument ( artifact . LocalPath ( ) , UndoCommand ) ; Assert . AreEqual ( artifact . GetFreshConceptualEntity ( entity1TypeName ) , artifact . GetFreshConceptualEntity ( entity2TypeName ) . BaseType . Target ) ; Assert . IsNull ( artifact . GetFreshConceptualEntity ( entity1TypeName ) . BaseType . Target ) ; dte . ExecuteCommandForOpenDocument ( artifact . LocalPath ( ) , RedoCommand ) ; dte . ExecuteCommandForOpenDocument ( artifact . LocalPath ( ) , RedoCommand ) ; Assert . AreEqual ( artifact . GetFreshConceptualEntity ( entity3TypeName ) , artifact . GetFreshConceptualEntity ( entity2TypeName ) . BaseType . Target ) ; Assert . AreEqual ( artifact . GetFreshConceptualEntity ( entity2TypeName ) , artifact . GetFreshConceptualEntity ( entity1TypeName ) . BaseType . Target ) ; new CommandProcessor ( commandProcessorContext , new DeleteInheritanceCommand ( entityType1 ) ) . Invoke ( ) ; entityType1 = artifact . GetFreshConceptualEntity ( entity1TypeName ) ; Assert . IsNull ( entityType1 . BaseType . Target ) ; new CommandProcessor ( commandProcessorContext , entityType1 . GetDeleteCommand ( ) ) . Invoke ( ) ; Assert . IsNull ( artifact . GetFreshConceptualEntity ( entity1TypeName ) ) ; dte . ExecuteCommandForOpenDocument ( artifact . LocalPath ( ) , UndoCommand ) ; dte . ExecuteCommandForOpenDocument ( artifact . LocalPath ( ) , UndoCommand ) ; Assert . IsNotNull ( artifact . GetFreshConceptualEntity ( entity1TypeName ) ) ; Assert . AreEqual ( artifact . GetFreshConceptualEntity ( entity3TypeName ) , artifact . GetFreshConceptualEntity ( entity2TypeName ) . BaseType . Target ) ; Assert . AreEqual ( artifact . GetFreshConceptualEntity ( entity2TypeName ) , artifact . GetFreshConceptualEntity ( entity1TypeName ) . BaseType . Target ) ; dte . ExecuteCommandForOpenDocument ( artifact . LocalPath ( ) , RedoCommand ) ; dte . ExecuteCommandForOpenDocument ( artifact . LocalPath ( ) , RedoCommand ) ; Assert . IsNull ( artifact . GetFreshConceptualEntity ( entity1TypeName ) ) ; } ) ; } ) ; }
Simple Inheritance tests:
1.
Simple Inheritance tests : 1 .
// Note: we cannot populate these EFObjects as soon as we create them. Since we are undoing/redoing,  // we will create new instances and need to discover them "on-demand" // CREATE THREE ENTITIES // CREATE INHERITANCE // DELETE INHERITANCE // Undo Redo "Delete Inheritance1" // Undo "Delete Inheritance1" // CHANGE BASE TYPE OF DERIVED TYPE // Undo Redo "Change Base Type of EntityType2: EntityType1 --> EntityType3" // CREATE 3-LEVEL INHERITANCE, ROLLBACK ALL THE WAY // undo two times // redo two times // DELETE INHERITANCE 2, DELETE ENTITY TYPE1, UNDO 2, REDO 2 // undo two times // redo two times