test/Misc/EFTools/InProcTests/UndoRedoTestsRemote.cs
/// <summary>
///     Various condition tests:
///     1. Undo/Redo Creation of Condition
///     2. Undo/Redo Creation of Condition on derived class
///     3. Undo/Redo Change Condition predicate
///     4. Delete condition
/// </summary>
Various condition tests:
1. Undo/Redo Creation of Condition
2. Undo/Redo Creation of Condition on derived class
3. Undo/Redo Change Condition predicate
4. Delete condition
Various condition tests : 1 . Undo / Redo Creation of Condition 2 . Undo / Redo Creation of Condition on derived class 3 . Undo / Redo Change Condition predicate 4 . Delete condition
[TestMethod]
        [HostType("VS IDE")]
        public void Mapping_Conditions()
        {
            UITestRunner.Execute(TestContext.TestName, 
                () =>
                    {
                        const string typePrefix = "Mapping_Conditions";
                        const string testName = "UndoRedo." + typePrefix;
                        ExecuteUndoRedoTest(
                            testName, "NorthwindModel.edmx", (commandProcessorContext, artifact) =>
                                {
                                    var dte = VsIdeTestHostContext.Dte;
                                    new CommandProcessor(
                                        commandProcessorContext,
                                        new CreateFragmentConditionCommand(
                                            artifact.GetFreshConceptualEntity("Customers"),
                                            (Property)artifact.GetFreshStorageEntity("Customers").GetFirstNamedChildByLocalName("City"),
                                            null,
                                            "Redmond")).Invoke();
                                    Assert.AreEqual("Redmond", artifact.GetFreshCondition("Customers", "City").Value.Value);
                                    dte.ExecuteCommandForOpenDocument(artifact.LocalPath(), UndoCommand);
                                    Assert.IsNull(artifact.GetFreshCondition("Customers", "Redmond"));
                                    dte.ExecuteCommandForOpenDocument(artifact.LocalPath(), RedoCommand);
                                    Assert.AreEqual("Redmond", artifact.GetFreshCondition("Customers", "City").Value.Value);
                                     ON DERIVED TYPE
                                    new CommandProcessor(
                                        commandProcessorContext,
                                        new CreateFragmentConditionCommand(
                                            artifact.GetFreshConceptualEntity("Order_Details_Extended"),
                                            (Property)
                                            artifact.GetFreshStorageEntity("Order Details Extended")
                                                .GetFirstNamedChildByLocalName("ProductName"),
                                            false,
                                            String.Empty)).Invoke();
                                    Assert.AreEqual("false", artifact.GetFreshCondition("Order_Details", "ProductName").IsNull.Value);
                                    dte.ExecuteCommandForOpenDocument(artifact.LocalPath(), UndoCommand);
                                    Assert.IsNull(artifact.GetFreshCondition("Order_Details", "ProductName"));
                                    dte.ExecuteCommandForOpenDocument(artifact.LocalPath(), RedoCommand);
                                    Assert.AreEqual("false", artifact.GetFreshCondition("Order_Details", "ProductName").IsNull.Value);
                                    CommandProcessor.InvokeSingleCommand(
                                        commandProcessorContext,
                                        new ChangeConditionPredicateCommand(
                                            artifact.GetFreshCondition("Order_Details", "ProductName"),
                                            null,
                                            "Escher"));
                                    Assert.IsNull(artifact.GetFreshCondition("Order_Details", "ProductName").IsNull.Value);
                                    Assert.AreEqual("Escher", artifact.GetFreshCondition("Order_Details", "ProductName").Value.Value);
                                    dte.ExecuteCommandForOpenDocument(artifact.LocalPath(), UndoCommand);
                                    Assert.IsNull(artifact.GetFreshCondition("Order_Details", "ProductName").Value.Value);
                                    Assert.AreEqual("false", artifact.GetFreshCondition("Order_Details", "ProductName").IsNull.Value);
                                    dte.ExecuteCommandForOpenDocument(artifact.LocalPath(), RedoCommand);
                                    Assert.IsNull(artifact.GetFreshCondition("Order_Details", "ProductName").IsNull.Value);
                                    Assert.AreEqual("Escher", artifact.GetFreshCondition("Order_Details", "ProductName").Value.Value);
                                    new CommandProcessor(
                                        commandProcessorContext,
                                        artifact.GetFreshCondition("Order_Details", "ProductName").GetDeleteCommand()).Invoke();
                                    Assert.IsNull(artifact.GetFreshCondition("Order_Details", "ProductName"));
                                    dte.ExecuteCommandForOpenDocument(artifact.LocalPath(), UndoCommand);
                                    Assert.IsNull(artifact.GetFreshCondition("Order_Details", "ProductName").IsNull.Value);
                                    Assert.AreEqual("Escher", artifact.GetFreshCondition("Order_Details", "ProductName").Value.Value);
                                    dte.ExecuteCommandForOpenDocument(artifact.LocalPath(), RedoCommand);
                                    Assert.IsNull(artifact.GetFreshCondition("Order_Details", "ProductName"));
                                    dte.ExecuteCommandForOpenDocument(artifact.LocalPath(), UndoCommand);
                                    Assert.IsNull(artifact.GetFreshCondition("Order_Details", "ProductName").IsNull.Value);
                                    Assert.AreEqual("Escher", artifact.GetFreshCondition("Order_Details", "ProductName").Value.Value);
                                });
                    });
        }
[ TestMethod ] [ HostType ( " " ) ] public void Mapping_Conditions ( ) { UITestRunner . Execute ( TestContext . TestName , ( ) => { const string typePrefix = " " ; const string testName = " " + typePrefix ; ExecuteUndoRedoTest ( testName , " " , ( commandProcessorContext , artifact ) => { var dte = VsIdeTestHostContext . Dte ; new CommandProcessor ( commandProcessorContext , new CreateFragmentConditionCommand ( artifact . GetFreshConceptualEntity ( " " ) , ( Property ) artifact . GetFreshStorageEntity ( " " ) . GetFirstNamedChildByLocalName ( " " ) , null , " " ) ) . Invoke ( ) ; Assert . AreEqual ( " " , artifact . GetFreshCondition ( " " , " " ) . Value . Value ) ; dte . ExecuteCommandForOpenDocument ( artifact . LocalPath ( ) , UndoCommand ) ; Assert . IsNull ( artifact . GetFreshCondition ( " " , " " ) ) ; dte . ExecuteCommandForOpenDocument ( artifact . LocalPath ( ) , RedoCommand ) ; Assert . AreEqual ( " " , artifact . GetFreshCondition ( " " , " " ) . Value . Value ) ; new CommandProcessor ( commandProcessorContext , new CreateFragmentConditionCommand ( artifact . GetFreshConceptualEntity ( " " ) , ( Property ) artifact . GetFreshStorageEntity ( " " ) . GetFirstNamedChildByLocalName ( " " ) , false , String . Empty ) ) . Invoke ( ) ; Assert . AreEqual ( " " , artifact . GetFreshCondition ( " " , " " ) . IsNull . Value ) ; dte . ExecuteCommandForOpenDocument ( artifact . LocalPath ( ) , UndoCommand ) ; Assert . IsNull ( artifact . GetFreshCondition ( " " , " " ) ) ; dte . ExecuteCommandForOpenDocument ( artifact . LocalPath ( ) , RedoCommand ) ; Assert . AreEqual ( " " , artifact . GetFreshCondition ( " " , " " ) . IsNull . Value ) ; CommandProcessor . InvokeSingleCommand ( commandProcessorContext , new ChangeConditionPredicateCommand ( artifact . GetFreshCondition ( " " , " " ) , null , " " ) ) ; Assert . IsNull ( artifact . GetFreshCondition ( " " , " " ) . IsNull . Value ) ; Assert . AreEqual ( " " , artifact . GetFreshCondition ( " " , " " ) . Value . Value ) ; dte . ExecuteCommandForOpenDocument ( artifact . LocalPath ( ) , UndoCommand ) ; Assert . IsNull ( artifact . GetFreshCondition ( " " , " " ) . Value . Value ) ; Assert . AreEqual ( " " , artifact . GetFreshCondition ( " " , " " ) . IsNull . Value ) ; dte . ExecuteCommandForOpenDocument ( artifact . LocalPath ( ) , RedoCommand ) ; Assert . IsNull ( artifact . GetFreshCondition ( " " , " " ) . IsNull . Value ) ; Assert . AreEqual ( " " , artifact . GetFreshCondition ( " " , " " ) . Value . Value ) ; new CommandProcessor ( commandProcessorContext , artifact . GetFreshCondition ( " " , " " ) . GetDeleteCommand ( ) ) . Invoke ( ) ; Assert . IsNull ( artifact . GetFreshCondition ( " " , " " ) ) ; dte . ExecuteCommandForOpenDocument ( artifact . LocalPath ( ) , UndoCommand ) ; Assert . IsNull ( artifact . GetFreshCondition ( " " , " " ) . IsNull . Value ) ; Assert . AreEqual ( " " , artifact . GetFreshCondition ( " " , " " ) . Value . Value ) ; dte . ExecuteCommandForOpenDocument ( artifact . LocalPath ( ) , RedoCommand ) ; Assert . IsNull ( artifact . GetFreshCondition ( " " , " " ) ) ; dte . ExecuteCommandForOpenDocument ( artifact . LocalPath ( ) , UndoCommand ) ; Assert . IsNull ( artifact . GetFreshCondition ( " " , " " ) . IsNull . Value ) ; Assert . AreEqual ( " " , artifact . GetFreshCondition ( " " , " " ) . Value . Value ) ; } ) ; } ) ; }
Various condition tests:
1.
Various condition tests : 1 .
// CREATE CONDITION // Undo Redo "Create Condition: Customers.City == Redmond" // CREATE CONDITION ON DERIVED TYPE // Undo Redo "Create Condition on Derived ET: Order_Details_Extended.ProductName IsNull == false" // Undo redo "Change Condition predicate: Order_Details_Extended.ProductName IsNull == false --> ProductName Value == Escher" // Undo redo "Delete Condition on Order_Details_Extended" // Undo "Delete Condition on Order_Details_Extended"