test/Misc/EFTools/InProcTests/UndoRedoTestsRemote.cs
/// <summary>
///     Delete a complex type which is referenced by a ComplexProperty then undo and redo.
///     Check that the ComplexProperty's Type parameter is resolved at the appropriate time
/// </summary>
Delete a complex type which is referenced by a ComplexProperty then undo and redo.
Check that the ComplexProperty's Type parameter is resolved at the appropriate time
Delete a complex type which is referenced by a ComplexProperty then undo and redo . Check that the ComplexProperty ' s Type parameter is resolved at the appropriate time
[TestMethod]
        [HostType("VS IDE")]
        public void DeleteComplexType()
        {
            UITestRunner.Execute(TestContext.TestName, 
                () =>
                    {
                        const string testName = "UndoRedo.DeleteComplexType";
                        ExecuteUndoRedoTest(
                            testName, "NorthwindModel.edmx", (commandProcessorContext, artifact) =>
                                {
                                    CommandProcessor.InvokeSingleCommand(
                                        commandProcessorContext,
                                        new CreateComplexTypeFromPropertiesCommand(
                                            artifact.GetFreshConceptualEntity("Orders"),
                                            artifact.GetFreshConceptualEntity("Orders")
                                                .Properties()
                                                .Where(p => p.Name.Value == "ShipName" || p.Name.Value == "ShipAddress")
                                                .ToList()));
                                    var complexProperty = (ComplexConceptualProperty)artifact.GetFreshConceptualEntity("Orders")
                                                                                         .Properties()
                                                                                         .SingleOrDefault(
                                                                                             p => p.Name.Value == "ComplexProperty");
                                    Assert.IsNotNull(complexProperty, "Complex property not created");
                                    Assert.AreEqual("ComplexType1", complexProperty.ComplexType.Target.Name.Value);
                                    CommandProcessor.InvokeSingleCommand(
                                        commandProcessorContext,
                                        new DeleteComplexTypeCommand(artifact.GetFreshComplexType("ComplexType1")));
                                    Assert.IsNull(artifact.GetFreshComplexType("ComplexType1"));
                                    Assert.IsNotNull(
                                        artifact.GetFreshConceptualEntity("Orders")
                                            .Properties()
                                            .SingleOrDefault(p => p.Name.Value == "ComplexProperty"));
                                    complexProperty = (ComplexConceptualProperty)artifact.GetFreshConceptualEntity("Orders")
                                                                                     .Properties()
                                                                                     .SingleOrDefault(
                                                                                         p => p.Name.Value == "ComplexProperty");
                                    Assert.IsNull(complexProperty.ComplexType.Target);
                                    VsIdeTestHostContext.Dte.ExecuteCommandForOpenDocument(artifact.LocalPath(), UndoCommand);
                                    Assert.IsNotNull(artifact.GetFreshComplexType("ComplexType1"));
                                    complexProperty = (ComplexConceptualProperty)artifact.GetFreshConceptualEntity("Orders")
                                                                                     .Properties()
                                                                                     .SingleOrDefault(
                                                                                         p => p.Name.Value == "ComplexProperty");
                                    Assert.AreEqual("ComplexType1", complexProperty.ComplexType.Target.Name.Value);
                                });
                    });
        }
[ TestMethod ] [ HostType ( " " ) ] public void DeleteComplexType ( ) { UITestRunner . Execute ( TestContext . TestName , ( ) => { const string testName = " " ; ExecuteUndoRedoTest ( testName , " " , ( commandProcessorContext , artifact ) => { CommandProcessor . InvokeSingleCommand ( commandProcessorContext , new CreateComplexTypeFromPropertiesCommand ( artifact . GetFreshConceptualEntity ( " " ) , artifact . GetFreshConceptualEntity ( " " ) . Properties ( ) . Where ( p => p . Name . Value == " " || p . Name . Value == " " ) . ToList ( ) ) ) ; var complexProperty = ( ComplexConceptualProperty ) artifact . GetFreshConceptualEntity ( " " ) . Properties ( ) . SingleOrDefault ( p => p . Name . Value == " " ) ; Assert . IsNotNull ( complexProperty , " " ) ; Assert . AreEqual ( " " , complexProperty . ComplexType . Target . Name . Value ) ; CommandProcessor . InvokeSingleCommand ( commandProcessorContext , new DeleteComplexTypeCommand ( artifact . GetFreshComplexType ( " " ) ) ) ; Assert . IsNull ( artifact . GetFreshComplexType ( " " ) ) ; Assert . IsNotNull ( artifact . GetFreshConceptualEntity ( " " ) . Properties ( ) . SingleOrDefault ( p => p . Name . Value == " " ) ) ; complexProperty = ( ComplexConceptualProperty ) artifact . GetFreshConceptualEntity ( " " ) . Properties ( ) . SingleOrDefault ( p => p . Name . Value == " " ) ; Assert . IsNull ( complexProperty . ComplexType . Target ) ; VsIdeTestHostContext . Dte . ExecuteCommandForOpenDocument ( artifact . LocalPath ( ) , UndoCommand ) ; Assert . IsNotNull ( artifact . GetFreshComplexType ( " " ) ) ; complexProperty = ( ComplexConceptualProperty ) artifact . GetFreshConceptualEntity ( " " ) . Properties ( ) . SingleOrDefault ( p => p . Name . Value == " " ) ; Assert . AreEqual ( " " , complexProperty . ComplexType . Target . Name . Value ) ; } ) ; } ) ; }
Delete a complex type which is referenced by a ComplexProperty then undo and redo.
Delete a complex type which is referenced by a ComplexProperty then undo and redo .
// Delete the complex type // Undo and test that the ComplexConceptualProperty's ComplexType attribute is re-resolved