UITest.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. using SketchAssistantWPF;
  11. using System.Windows;
  12. namespace WhiteTests
  13. {
  14. [TestClass]
  15. public class UITest
  16. {
  17. private TestStack.White.Application application;
  18. public void setupapp()
  19. {
  20. string outputDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
  21. string editedDir = outputDir.Replace("WhiteTests", "SketchAssistantWPF");
  22. string app_path = editedDir + @"\SketchAssistantWPF.exe";
  23. application = Application.Launch(app_path);
  24. Window mainWindow = application.GetWindow("Sketch Assistant");
  25. }
  26. [TestMethod]
  27. public void CreateCanvasTest()
  28. {
  29. setupapp();
  30. Window mainWindow = application.GetWindow("Sketch Assistant");
  31. Thread.Sleep(100);
  32. Assert.AreEqual("none", mainWindow.Get<TextBox>(SearchCriteria.ByAutomationId("LastActionBox")).Text.ToString());
  33. mainWindow.Get<Button>(SearchCriteria.ByAutomationId("CanvasButton")).Click();
  34. Thread.Sleep(100);
  35. Assert.AreEqual("Last Action: A new canvas was created.", mainWindow.Get<TextBox>(SearchCriteria.ByAutomationId("LastActionBox")).Text.ToString());
  36. mainWindow.Close();
  37. }
  38. }
  39. }