private void ChangeEntityTypesFillColorTest( string projectName, Color fillColor, Action <EntityDesignArtifact, CommandProcessorContext> runTest) { var modelPath = Path.Combine(TestContext.DeploymentDirectory, @"TestData\Model\v3\PubSimple.edmx"); UITestRunner.Execute(TestContext.TestName, () => { EntityDesignArtifact entityDesignArtifact = null; Project project = null; try { project = Dte.CreateProject( TestContext.TestRunDirectory, projectName, DteExtensions.ProjectKind.Executable, DteExtensions.ProjectLanguage.CSharp); var projectItem = Dte.AddExistingItem(modelPath, project); Dte.OpenFile(projectItem.FileNames[0]); entityDesignArtifact = (EntityDesignArtifact) new EFArtifactHelper(EFArtifactHelper.GetEntityDesignModelManager(ServiceProvider)) .GetNewOrExistingArtifact(TestUtils.FileName2Uri(projectItem.FileNames[0])); var editingContext = _package.DocumentFrameMgr.EditingContextManager.GetNewOrExistingContext(entityDesignArtifact.Uri); var commandProcessorContext = new CommandProcessorContext( editingContext, "DiagramTest", "DiagramTestTxn", entityDesignArtifact); foreach (var ets in entityDesignArtifact.DesignerInfo.Diagrams.FirstDiagram.EntityTypeShapes) { CommandProcessor.InvokeSingleCommand( commandProcessorContext, new UpdateDefaultableValueCommand <Color>(ets.FillColor, fillColor)); } runTest(entityDesignArtifact, commandProcessorContext); } finally { if (entityDesignArtifact != null) { entityDesignArtifact.Dispose(); } if (project != null) { Dte.CloseSolution(false); } } }); }
private void ExecuteMigrateDiagramNodesTest(string projectName, Action <EntityDesignArtifact, CommandProcessorContext> runTest) { var modelPath = Path.Combine(TestContext.DeploymentDirectory, @"TestData\Model\v3\PubSimple.edmx"); UITestRunner.Execute( () => { EntityDesignArtifact entityDesignArtifact = null; Project project = null; try { project = Dte.CreateProject( TestContext.TestRunDirectory, projectName, DteExtensions.ProjectKind.Executable, DteExtensions.ProjectLanguage.CSharp); var projectItem = Dte.AddExistingItem(modelPath, project); Dte.OpenFile(projectItem.FileNames[0]); entityDesignArtifact = (EntityDesignArtifact) new EFArtifactHelper(EFArtifactHelper.GetEntityDesignModelManager(ServiceProvider)) .GetNewOrExistingArtifact(TestUtils.FileName2Uri(projectItem.FileNames[0])); Debug.Assert(entityDesignArtifact != null); var editingContext = _package.DocumentFrameMgr.EditingContextManager.GetNewOrExistingContext(entityDesignArtifact.Uri); // Create TransactionContext to indicate that the transactions are done from first diagram. // This is not used by MigrateDiagramInformationCommand but other commands in the callback methods. var transactionContext = new EfiTransactionContext(); transactionContext.Add( EfiTransactionOriginator.TransactionOriginatorDiagramId, new DiagramContextItem(entityDesignArtifact.DesignerInfo.Diagrams.FirstDiagram.Id.Value)); var commandProcessorContext = new CommandProcessorContext( editingContext, "MigrateDiagramNodesTest", projectName + "Txn", entityDesignArtifact, transactionContext); MigrateDiagramInformationCommand.DoMigrate(commandProcessorContext, entityDesignArtifact); Debug.Assert(entityDesignArtifact.DiagramArtifact != null); Debug.Assert( entityDesignArtifact.IsDesignerSafe, "Artifact should not be in safe mode after MigrateDiagramInformationCommand is executed."); Debug.Assert( new Uri(entityDesignArtifact.Uri.LocalPath + EntityDesignArtifact.EXTENSION_DIAGRAM) == entityDesignArtifact.DiagramArtifact.Uri); runTest(entityDesignArtifact, commandProcessorContext); } finally { if (entityDesignArtifact != null) { entityDesignArtifact.Dispose(); } if (project != null) { Dte.CloseSolution(false); } } }); }