test/Misc/EFTools/E2ETests/WhiteE2ETests.cs
/// <summary>
///     Simple E2E test that selects empty model in the wizard
/// </summary>
Simple E2E test that selects empty model in the wizard
Simple E2E test that selects empty model in the wizard
[TestMethod]
        [HostType("VS IDE")]
        [TestCategory("DoNotRunOnCI")]
        public void AddAnEmptyModel()
        {
            Exception exceptionCaught = null;
            Trace.WriteLine(DateTime.Now.ToLongTimeString() + "Starting the test");
            var project = Dte.CreateProject(
                TestContext.TestRunDirectory,
                "EmptyModelTest",
                DteExtensions.ProjectKind.Executable,
                DteExtensions.ProjectLanguage.CSharp);
            Assert.IsNotNull(project, "Could not create project");
            var wizardDiscoveryThread = ExecuteThreadedAction(
                () =>
                {
                    try
                    {
                        _visualStudio = Application.Attach(Process.GetCurrentProcess().Id);
                        _visualStudioMainWindow = _visualStudio.GetWindow(
                            SearchCriteria.ByAutomationId("VisualStudioMainWindow"),
                            InitializeOption.NoCache);
                        var newItemWindow = _visualStudioMainWindow.Popup;
                        var extensions = newItemWindow.Get<ListView>(SearchCriteria.ByText("Extensions"));
                        extensions.Select("ADO.NET Entity Data Model");
                        var addButton = newItemWindow.Get<Button>(SearchCriteria.ByAutomationId("btn_OK"));
                        addButton.Click();
                        _wizard = GetWizard("WizardFormDialog_Title");
                        CreateEmptyModel();
                    }
                    catch (Exception ex)
                    {
                        exceptionCaught = ex;
                    }
                }, "UIExecutor");
            Dte.ExecuteCommand("Project.AddNewItem");
            wizardDiscoveryThread.Join();
            if (exceptionCaught != null)
            {
                throw exceptionCaught;
            }
            Trace.WriteLine(DateTime.Now.ToLongTimeString() + "wizardDiscoveryThread returned");
            var csfile = project.GetProjectItemByName("Model1.designer.cs");
            Assert.IsNotNull(csfile, "csfile is not null");
            var diagramFile = project.GetProjectItemByName("Model1.edmx.diagram");
            Assert.IsNotNull(diagramFile, "diagramfile not null");
            var errors = Build();
            Assert.IsTrue(errors == null || errors.Count == 0);
            var entities = AddEntities();
            AddAssociations(entities);
            var designerSurface = _visualStudioMainWindow.Get<Panel>(SearchCriteria.ByText("Modeling Design Surface"));
            AddInheritance(designerSurface, entities[1], entities[3]);
            AddEnum(designerSurface);
            project.Save();
            CheckFilesEmptyModel(project);
        }
[ TestMethod ] [ HostType ( " " ) ] [ TestCategory ( " " ) ] public void AddAnEmptyModel ( ) { Exception exceptionCaught = null ; Trace . WriteLine ( DateTime . Now . ToLongTimeString ( ) + " " ) ; var project = Dte . CreateProject ( TestContext . TestRunDirectory , " " , DteExtensions . ProjectKind . Executable , DteExtensions . ProjectLanguage . CSharp ) ; Assert . IsNotNull ( project , " " ) ; var wizardDiscoveryThread = ExecuteThreadedAction ( ( ) => { try { _visualStudio = Application . Attach ( Process . GetCurrentProcess ( ) . Id ) ; _visualStudioMainWindow = _visualStudio . GetWindow ( SearchCriteria . ByAutomationId ( " " ) , InitializeOption . NoCache ) ; var newItemWindow = _visualStudioMainWindow . Popup ; var extensions = newItemWindow . Get < ListView > ( SearchCriteria . ByText ( " " ) ) ; extensions . Select ( " " ) ; var addButton = newItemWindow . Get < Button > ( SearchCriteria . ByAutomationId ( " " ) ) ; addButton . Click ( ) ; _wizard = GetWizard ( " " ) ; CreateEmptyModel ( ) ; } catch ( Exception ex ) { exceptionCaught = ex ; } } , " " ) ; Dte . ExecuteCommand ( " " ) ; wizardDiscoveryThread . Join ( ) ; if ( exceptionCaught != null ) { throw exceptionCaught ; } Trace . WriteLine ( DateTime . Now . ToLongTimeString ( ) + " " ) ; var csfile = project . GetProjectItemByName ( " " ) ; Assert . IsNotNull ( csfile , " " ) ; var diagramFile = project . GetProjectItemByName ( " " ) ; Assert . IsNotNull ( diagramFile , " " ) ; var errors = Build ( ) ; Assert . IsTrue ( errors == null || errors . Count == 0 ) ; var entities = AddEntities ( ) ; AddAssociations ( entities ) ; var designerSurface = _visualStudioMainWindow . Get < Panel > ( SearchCriteria . ByText ( " " ) ) ; AddInheritance ( designerSurface , entities [ 1 ] , entities [ 3 ] ) ; AddEnum ( designerSurface ) ; project . Save ( ) ; CheckFilesEmptyModel ( project ) ; }
Simple E2E test that selects empty model in the wizard
Simple E2E test that selects empty model in the wizard
// Walk thru the Empty model selection // Make sure the expected files are created