UITest.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System;
  2. using System.IO;
  3. using System.Reflection;
  4. using Microsoft.VisualStudio.TestTools.UnitTesting;
  5. using TestStack.White;
  6. using TestStack.White.UIItems;
  7. using TestStack.White.UIItems.WindowItems;
  8. using TestStack.White.UIItems.Finders;
  9. using System.Threading;
  10. namespace WhiteTests
  11. {
  12. [TestClass]
  13. public class UITest
  14. {
  15. private TestStack.White.Application application;
  16. public void setupapp()
  17. {
  18. string outputDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
  19. string editedDir = outputDir.Replace("WhiteTests", "SketchAssistantWPF");
  20. string app_path = editedDir + @"\SketchAssistantWPF.exe";
  21. application = Application.Launch(app_path);
  22. Window mainWindow = application.GetWindow("Sketch Assistant");
  23. }
  24. [TestMethod]
  25. public void CreateCanvasTest()
  26. {
  27. setupapp();
  28. Window mainWindow = application.GetWindow("Sketch Assistant");
  29. Thread.Sleep(100);
  30. Assert.AreEqual("none", mainWindow.Get<TextBox>(SearchCriteria.ByAutomationId("LAST_ACTION_TAKEN_BOX")).Text.ToString());
  31. mainWindow.Get<Button>(SearchCriteria.ByAutomationId("CANVAS_BUTTON")).Click();
  32. Thread.Sleep(100);
  33. Assert.AreEqual("Last Action: A new canvas was created.", mainWindow.Get<TextBox>(SearchCriteria.ByAutomationId("LAST_ACTION_TAKEN_BOX")).Text.ToString());
  34. mainWindow.Close();
  35. }
  36. }
  37. }