public virtual void Teardown() { try { ValidateIdeLogMessages(); LoggingService.RemoveLogger(Logger.Name); Logger.Dispose(); } finally { var testStatus = TestContext.CurrentContext.Result.Status; if (testStatus != TestStatus.Passed) { try { TakeScreenShot(string.Format("{0}-Test-Failed", TestContext.CurrentContext.Test.Name)); } catch (Exception e) { Session.DebugObject.Debug("Final Screenshot failed"); } } File.WriteAllText(Path.Combine(currentTestResultFolder, "MemoryUsage.json"), JsonConvert.SerializeObject(Session.MemoryStats, Formatting.Indented)); Ide.CloseAll(); TestService.EndSession(); OnCleanUp(); if (testStatus == TestStatus.Passed) { if (Directory.Exists(currentTestResultScreenshotFolder)) { Directory.Delete(currentTestResultScreenshotFolder, true); } } } }
public void OpenEditCompile() { var slnFile = Ide.OpenTestSolution("ConsoleApp-VS2010/ConsoleApplication.sln"); var slnDir = slnFile.ParentDirectory; var exe = slnDir.Combine("bin", "Debug", "ConsoleApplication.exe"); Assert.IsFalse(File.Exists(exe)); Ide.OpenFile(slnFile.ParentDirectory.Combine("Program.cs")); Ide.BuildSolution(); AssertExeHasOutput(exe, ""); //select text editor, move down 10 lines, and insert a statement Session.SelectActiveWidget(); for (int n = 0; n < 10; n++) { Session.ExecuteCommand(TextEditorCommands.LineDown); } Session.ExecuteCommand(TextEditorCommands.LineEnd); Session.TypeText("\nConsole.WriteLine (\"Hello World!\");"); Ide.BuildSolution(); AssertExeHasOutput(exe, "Hello World!"); Ide.CloseAll(); }
public void CreateBuildProject() { string projectName = "TestFoo"; string projectCategory = "C#"; string projectKind = "Console Project"; var projectDirectory = Util.CreateTmpDir(projectName); Ide.CreateProject(projectName, projectCategory, projectKind, projectDirectory); Ide.BuildSolution(); Ide.CloseAll(); }
public virtual void Teardown() { File.WriteAllText(Path.Combine(memoryUsageFolder, TestContext.CurrentContext.Test.FullName), JsonConvert.SerializeObject(Session.MemoryStats, Formatting.Indented)); Ide.CloseAll(); TestService.EndSession(); OnCleanUp(); if (TestContext.CurrentContext.Result.Status == TestStatus.Passed) { if (Directory.Exists(currentTestResultFolder)) { Directory.Delete(currentTestResultFolder, true); } } }
public virtual void Teardown() { try { bool isInconclusive = false; var testStatus = TestContext.CurrentContext.Result.Status; if (testStatus != TestStatus.Passed) { try { var updateOpened = Session.Query(IdeQuery.XamarinUpdate); if (updateOpened != null && updateOpened.Any()) { isInconclusive = true; } TakeScreenShot(string.Format("{0}-Test-Failed", TestContext.CurrentContext.Test.Name)); } catch (Exception e) { Session.DebugObject.Debug("Final Screenshot failed"); Session.DebugObject.Debug(e.ToString()); } } File.WriteAllText(Path.Combine(currentTestResultFolder, "MemoryUsage.json"), JsonConvert.SerializeObject(Session.MemoryStats, Formatting.Indented)); Ide.CloseAll(); TestService.EndSession(); ValidateIdeLogMessages(); OnCleanUp(); if (testStatus == TestStatus.Passed) { if (Directory.Exists(currentTestResultScreenshotFolder)) { Directory.Delete(currentTestResultScreenshotFolder, true); } } if (isInconclusive) { Assert.Inconclusive("Xamarin Update is blocking the application focus"); } } finally { LoggingService.RemoveLogger(Logger.Name); Logger.Dispose(); } }
public void OpenEditCompile() { var slnFile = Ide.OpenTestSolution("ConsoleApp-VS2010/ConsoleApplication.sln"); var slnDir = slnFile.ParentDirectory; var exe = slnDir.Combine("bin", "Debug", "ConsoleApplication.exe"); Assert.IsFalse(File.Exists(exe)); Ide.OpenFile(slnFile.ParentDirectory.Combine("Program.cs")); //select text editor, move down 10 lines, and insert a statement Session.SelectActiveWidget(); Session.ExecuteCommand(TextEditorCommands.DocumentStart); // Delete all the code already existing for (int i = 0; i < 20; i++) { Session.ExecuteCommand(TextEditorCommands.DeleteLine); } // Entering Program With an Error Session.TypeText("\nusing System;"); Session.TypeText("\nnamespace ConsoleProject {"); Session.TypeText("\nclass MainClass {"); Session.TypeText("\npublic static void Main (string[] args) {"); Session.TypeText("\nList<string> s = new List<string> () {\"one\", \"two\", \"three\"};"); Session.TypeText("\nConsole.WriteLine (\"Hello Xamarin!\"); }"); Session.TypeText("\n} }"); Ide.BuildSolution(); AssertExeHasOutput(exe, "Hello Xamarin!"); Ide.CloseAll(); }
public void ZCorrectIt() { var slnFile = Ide.OpenTestSolution("ConsoleApp-VS2010/ConsoleApplication.sln"); var slnDir = slnFile.ParentDirectory; var exe = slnDir.Combine("bin", "Debug", "ConsoleApplication.exe"); Assert.IsFalse(File.Exists(exe)); Ide.OpenFile(slnFile.ParentDirectory.Combine("Program.cs")); Session.SelectActiveWidget(); for (int i = 0; i < 20; i++) { Session.ExecuteCommand(TextEditorCommands.DeleteLine); } Session.ExecuteCommand(TextEditorCommands.DocumentStart); Session.ExecuteCommand(TextEditorCommands.InsertNewLine); // Entering the Correct Program Session.TypeText("\nusing System;"); Session.TypeText("\nusing System.Collections.Generic;"); Session.TypeText("\nnamespace ConsoleProject {"); Session.TypeText("\nclass MainClass {"); Session.TypeText("\npublic static void Main (string[] args) {"); Session.TypeText("\nList<string> s = new List<string> () {\"one\", \"two\", \"three\"};"); Session.TypeText("\nConsole.WriteLine (\"Hello Xamarin!\"); }"); Session.TypeText("\n} }"); Session.ExecuteCommand(TextEditorCommands.LineDown); Ide.BuildSolution(); AssertExeHasOutput(exe, "Hello Xamarin!"); Ide.CloseAll(); }
public void CreateBuildProject(string projectName, string categoryRoot, string category, string kindRoot, string kind, Action beforeBuild) { var solutionParentDirectory = Util.CreateTmpDir(projectName); string actualSolutionDirectory = string.Empty; try { var newProject = new NewProjectController(); newProject.Open(); SelectTemplate(newProject, categoryRoot, category, kindRoot, kind); Assert.IsTrue(newProject.Next()); // Wait until the next page is displayed Session.WaitForElement(c => c.Textfield().Marked("solutionNameTextBox")); EnterProjectDetails(newProject, projectName, projectName, solutionParentDirectory); Assert.IsTrue(newProject.CreateProjectInSolutionDirectory(false)); Assert.IsTrue(newProject.UseGit(true, false)); Session.RunAndWaitForTimer(() => newProject.Next(), "Ide.Shell.SolutionOpened"); actualSolutionDirectory = GetSolutionDirectory(); beforeBuild(); Assert.IsTrue(Ide.BuildSolution()); } finally { Ide.CloseAll(); try { if (Directory.Exists(actualSolutionDirectory)) { Directory.Delete(actualSolutionDirectory, true); } } catch (IOException) { } } }