Martin Edlund 5 years ago
parent
commit
6b52a6b63f

+ 18 - 0
SketchAssistant/SketchAssistantWPF/CustomCanvas.cs

@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Automation.Peers;
+using System.Windows.Controls;
+
+namespace SketchAssistantWPF
+{
+    public class CustomCanvas : Canvas
+    {
+        protected override AutomationPeer OnCreateAutomationPeer()
+        {
+            return new FrameworkElementAutomationPeer(this);
+        }
+    }
+}

+ 49 - 41
SketchAssistant/SketchAssistantWPF/InternalLine.cs

@@ -26,6 +26,14 @@ namespace SketchAssistantWPF
         /// A collection of the original Points defining the line.
         /// </summary>
         private PointCollection pointColl;
+        /// <summary>
+        /// Indicates if this is a single point.
+        /// </summary>
+        public bool isPoint { get; private set; }
+        /// <summary>
+        /// The location of the point, if this is a point
+        /// </summary>
+        public Point point { get; private set; }
 
         /// <summary>
         /// The constructor for lines which are only temporary.
@@ -78,24 +86,7 @@ namespace SketchAssistantWPF
         {
             return pointColl;
         }
-        /*
-        /// <summary>
-        /// A function that takes a Graphics element and returns it with
-        /// the line drawn on it.
-        /// </summary>
-        /// <param name="canvas">The Graphics element on which the line shall be drawn</param>
-        /// <returns>The given Graphics element with the additional line</returns>
-        public Graphics DrawLine(Graphics canvas)
-        {
-            for (int i = 0; i < linePoints.Count - 1; i++)
-            {
-                canvas.DrawLine(Pens.Black, linePoints[i], linePoints[i + 1]);
-            }
-            //If there is only one point
-            if (linePoints.Count == 1) { canvas.FillRectangle(Brushes.Black, linePoints[0].X, linePoints[0].Y, 1, 1); }
-            return canvas;
-        }
-        */
+
         /// <summary>
         /// A function that will take to matrixes and populate the with the line data of this line object
         /// </summary>
@@ -128,36 +119,53 @@ namespace SketchAssistantWPF
         {
             if (linePoints.Count > 1)
             {
-                List<Point> newList = new List<Point>();
-                List<Point> tempList = new List<Point>();
-                //Since Point is non-nullable, we must ensure the nullPoints, 
-                //which we remove can not possibly be points of the original given line.
-                int nullValue = (int) linePoints[0].X + 1;
-                //Fill the gaps between points
-                for (int i = 0; i < linePoints.Count - 1; i++)
+                //if this is a point or not
+                bool isP = true;
+                //check if its a point
+                foreach(Point p in linePoints)
                 {
-                    nullValue += (int) linePoints[i + 1].X;
-                    List<Point> partialList = GeometryCalculator.BresenhamLineAlgorithm(linePoints[i], linePoints[i + 1]);
-                    tempList.AddRange(partialList);
+                    if (p.X != linePoints[0].X || p.Y != linePoints[0].Y)
+                        isP = false;
                 }
-                Point nullPoint = new Point(nullValue, 0);
-                //Set duplicate points to the null point
-                for (int i = 1; i < tempList.Count; i++)
-                {
-                    if ((tempList[i].X == tempList[i - 1].X) && (tempList[i].Y == tempList[i - 1].Y))
+                if (!isP) {
+                    List<Point> newList = new List<Point>();
+                    List<Point> tempList = new List<Point>();
+                    //Since Point is non-nullable, we must ensure the nullPoints, 
+                    //which we remove can not possibly be points of the original given line.
+                    int nullValue = (int) linePoints[0].X + 1;
+                    //Fill the gaps between points
+                    for (int i = 0; i < linePoints.Count - 1; i++)
                     {
-                        tempList[i - 1] = nullPoint;
+                        nullValue += (int) linePoints[i + 1].X;
+                        List<Point> partialList = GeometryCalculator.BresenhamLineAlgorithm(linePoints[i], linePoints[i + 1]);
+                        tempList.AddRange(partialList);
                     }
-                }
-                //remove the null points
-                foreach (Point tempPoint in tempList)
-                {
-                    if (tempPoint.X != nullValue)
+                    Point nullPoint = new Point(nullValue, 0);
+                    //Set duplicate points to the null point
+                    for (int i = 1; i < tempList.Count; i++)
                     {
-                        newList.Add(tempPoint);
+                        if ((tempList[i].X == tempList[i - 1].X) && (tempList[i].Y == tempList[i - 1].Y))
+                        {
+                            tempList[i - 1] = nullPoint;
+                        }
                     }
+                    //remove the null points
+                    foreach (Point tempPoint in tempList)
+                    {
+                        if (tempPoint.X != nullValue)
+                        {
+                            newList.Add(tempPoint);
+                        }
+                    }
+                    linePoints = new List<Point>(newList);
+                }
+                else
+                {
+                    isPoint = true;
+                    point = linePoints[0];
+                    linePoints = new List<Point>();
+                    linePoints.Add(point);
                 }
-                linePoints = new List<Point>(newList);
             }
         }
     }

+ 3 - 8
SketchAssistant/SketchAssistantWPF/MVP_Model.cs

@@ -35,10 +35,6 @@ namespace SketchAssistantWPF
         /// </summary>
         bool inDrawingMode;
         /// <summary>
-        /// If the mouse is currently pressed or not.
-        /// </summary>
-        bool mousePressed;
-        /// <summary>
         /// Size of deletion area
         /// </summary>
         int deletionRadius = 5;
@@ -348,10 +344,10 @@ namespace SketchAssistantWPF
         /// </summary>
         public void MouseDown()
         {
-            mousePressed = true;
             if (inDrawingMode)
             {
                 currentLine.Clear();
+                currentLine.Add(currentCursorPosition);
             }
         }
 
@@ -360,7 +356,6 @@ namespace SketchAssistantWPF
         /// </summary>
         public void MouseUp()
         {
-            mousePressed = false;
             if (inDrawingMode && currentLine.Count > 0)
             {
                 InternalLine newLine = new InternalLine(currentLine, rightLineList.Count);
@@ -384,13 +379,13 @@ namespace SketchAssistantWPF
             else { previousCursorPosition = currentCursorPosition; }
             cursorPositions.Enqueue(currentCursorPosition);
             //Drawing
-            if (inDrawingMode && mousePressed)
+            if (inDrawingMode && programPresenter.IsMousePressed())
             {
                 currentLine.Add(currentCursorPosition);
                 programPresenter.UpdateCurrentLine(currentLine);
             }
             //Deleting
-            if (!inDrawingMode && mousePressed)
+            if (!inDrawingMode && programPresenter.IsMousePressed())
             {
                 List<Point> uncheckedPoints = GeometryCalculator.BresenhamLineAlgorithm(previousCursorPosition, currentCursorPosition);
                 foreach (Point currPoint in uncheckedPoints)

+ 36 - 7
SketchAssistant/SketchAssistantWPF/MVP_Presenter.cs

@@ -24,7 +24,7 @@ namespace SketchAssistantWPF
         /// <summary>
         /// A dictionary connecting the id of an InternalLine with the respective Polyline in the right canvas.
         /// </summary>
-        Dictionary<int, Polyline> rightPolyLines;
+        Dictionary<int, Shape> rightPolyLines;
 
         ImageDimension CanvasSizeLeft = new ImageDimension(0,0);
 
@@ -209,6 +209,15 @@ namespace SketchAssistantWPF
         /*** FUNCTIONS MODEL -> PRESENTER ***/
         /************************************/
 
+        /// <summary>
+        /// Return the position of the cursor
+        /// </summary>
+        /// <returns>The position of the cursor</returns>
+        public Point GetCursorPosition()
+        {
+            return programView.GetCursorPosition();
+        }
+
         /// <summary>
         /// Updates the currentline
         /// </summary>
@@ -227,7 +236,7 @@ namespace SketchAssistantWPF
         public void ClearRightLines()
         {
             programView.RemoveAllRightLines();
-            rightPolyLines = new Dictionary<int, Polyline>();
+            rightPolyLines = new Dictionary<int, Shape>();
         }
 
         /// <summary>
@@ -241,10 +250,21 @@ namespace SketchAssistantWPF
                 var line = tup.Item2;
                 if (!rightPolyLines.ContainsKey(line.GetID()))
                 {
-                    Polyline newLine = new Polyline();
-                    newLine.Points = line.GetPointCollection();
-                    rightPolyLines.Add(line.GetID(), newLine);
-                    programView.AddNewLineRight(newLine);
+                    if (!line.isPoint)
+                    {
+                        Polyline newLine = new Polyline();
+                        newLine.Points = line.GetPointCollection();
+                        rightPolyLines.Add(line.GetID(), newLine);
+                        programView.AddNewLineRight(newLine);
+                    }
+                    else
+                    {
+                        Ellipse newPoint = new Ellipse();
+                        newPoint.SetValue(Canvas.LeftProperty, line.point.X);
+                        newPoint.SetValue(Canvas.TopProperty, line.point.Y);
+                        rightPolyLines.Add(line.GetID(), newPoint);
+                        programView.AddNewPointRight(newPoint);
+                    }
                 }
                 SetVisibility(rightPolyLines[line.GetID()], status);
             }
@@ -324,6 +344,15 @@ namespace SketchAssistantWPF
             programView.SetLastActionTakenText(msg);
         }
 
+        /// <summary>
+        /// Passes whether or not the mouse is pressed.
+        /// </summary>
+        /// <returns>Whether or not the mouse is pressed</returns>
+        public bool IsMousePressed()
+        {
+            return programView.IsMousePressed();
+        }
+
         /*************************/
         /*** HELPING FUNCTIONS ***/
         /*************************/
@@ -333,7 +362,7 @@ namespace SketchAssistantWPF
         /// </summary>
         /// <param name="line">The polyline</param>
         /// <param name="visible">Whether or not it should be visible.</param>
-        private void SetVisibility(Polyline line, bool visible)
+        private void SetVisibility(Shape line, bool visible)
         {
             if (!visible)
             {

+ 25 - 0
SketchAssistant/SketchAssistantWPF/MVP_View.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Shapes;
 
@@ -94,5 +95,29 @@ namespace SketchAssistantWPF
         /// <param name="message">The message of the warning.</param>
         /// <returns>True if the user confirms (Yes), negative if he doesn't (No)</returns>
         bool ShowWarning(String message);
+
+        /// <summary>
+        /// If the mouse is pressed or not.
+        /// </summary>
+        /// <returns>Whether or not the mouse is pressed.</returns>
+        bool IsMousePressed();
+
+        /// <summary>
+        /// Adds a point to the right canvas
+        /// </summary>
+        /// <param name="newPoint">The point</param>
+        void AddNewPointRight(Ellipse newPoint);
+
+        /// <summary>
+        /// Adds a point to the left canvas
+        /// </summary>
+        /// <param name="newPoint">The point</param>
+        void AddNewPointLeft(Ellipse newPoint);
+
+        /// <summary>
+        /// Returns the cursor position.
+        /// </summary>
+        /// <returns>The cursor Position</returns>
+        Point GetCursorPosition();
     }
 }

+ 17 - 16
SketchAssistant/SketchAssistantWPF/MainWindow.xaml

@@ -1,9 +1,9 @@
 <Window x:Class="SketchAssistantWPF.MainWindow"
+        xmlns:local="clr-namespace:SketchAssistantWPF"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
-        xmlns:local="clr-namespace:SketchAssistantWPF"
         mc:Ignorable="d"
         Title="Sketch Assistant" Height="612" Width="914" SizeChanged="Window_SizeChanged">
     <Grid>
@@ -26,18 +26,19 @@
         <ToolBar x:Name="MenuToolbar" Grid.Column="0" Grid.ColumnSpan="4" Grid.Row="0" Background="LightGray">
             <Menu Background="LightGray">
                 <MenuItem x:Name="LoadMenuButton" Header="Load">
-                    <MenuItem Header="Load SVG File" Click="MenuItem_Click" AutomationProperties.AutomationId="SVG_MENU_BUTTON"/>
+                    <MenuItem x:Name="SVGMenuButton" Header="Load SVG File" Click="MenuItem_Click"/>
                 </MenuItem>
                 <MenuItem x:Name="EditMenuButton" Header="Edit">
-                    <MenuItem Header="New Canvas" Click="CanvasButton_Click" AutomationProperties.AutomationId="CANVAS_MENU_BUTTON"/>
-                    <MenuItem Header="Undo" Click="UndoButton_Click" AutomationProperties.AutomationId="UNDO_MENU_BUTTON"/>
-                    <MenuItem Header="Redo" Click="RedoButton_Click" AutomationProperties.AutomationId="REDO_MENU_BUTTON"/>
+                    <MenuItem x:Name="CanvasMenuButton" Header="New Canvas" Click="CanvasButton_Click"/>
+                    <MenuItem x:Name="UndoMenuButton" Header="Undo" Click="UndoButton_Click"/>
+                    <MenuItem x:Name="RedoMenuButton" Header="Redo" Click="RedoButton_Click"/>
+                    <MenuItem x:Name="DebugMode" Header="Start Test Input" Click="DebugButton"/>
                 </MenuItem>
             </Menu>
         </ToolBar>
         <!-- All Icons in the Toolbar taken from openclipart.org -->
         <ToolBar x:Name="DrawingToolBar" Grid.Column="5" Grid.Row="0" Grid.ColumnSpan="2" Background="LightGray">
-            <Button x:Name="CanvasButton" ToolTip="Create a new Canvas" Click="CanvasButton_Click" AutomationProperties.AutomationId="CANVAS_BUTTON">
+            <Button x:Name="CanvasButton" ToolTip="Create a new Canvas" Click="CanvasButton_Click">
                 <Rectangle Width="30" Height="30">
                     <Rectangle.Fill>
                         <DrawingBrush>
@@ -66,7 +67,7 @@
                     </Rectangle.Fill>
                 </Rectangle>
             </Button>
-            <ToggleButton x:Name="DrawButton" ToolTip="Enter Drawing Mode" Click="DrawButton_Click" AutomationProperties.AutomationId="DRAW_BUTTON">
+            <ToggleButton x:Name="DrawButton" ToolTip="Enter Drawing Mode" Click="DrawButton_Click">
                 <Rectangle Width="30" Height="30">
                     <Rectangle.Fill>
                         <DrawingBrush>
@@ -81,7 +82,7 @@
                     </Rectangle.Fill>
                 </Rectangle>
             </ToggleButton>
-            <ToggleButton x:Name="DeleteButton" ToolTip="Enter Deletion Mode" Click="DeleteButton_Click" AutomationProperties.AutomationId="DELETE_BUTTON">
+            <ToggleButton x:Name="DeleteButton" ToolTip="Enter Deletion Mode" Click="DeleteButton_Click">
                 <Rectangle Width="30" Height="30">
                     <Rectangle.Fill>
                         <DrawingBrush>
@@ -123,7 +124,7 @@
                     </Rectangle.Fill>
                 </Rectangle>
             </ToggleButton>
-            <Button x:Name="UndoButton" ToolTip="Undo the last action" Click="UndoButton_Click" AutomationProperties.AutomationId="UNDO_BUTTON">
+            <Button x:Name="UndoButton" ToolTip="Undo the last action" Click="UndoButton_Click">
                 <Rectangle Width="30" Height="30">
                     <Rectangle.Fill>
                         <DrawingBrush>
@@ -145,7 +146,7 @@
                     </Rectangle.Fill>
                 </Rectangle>
             </Button>
-            <Button x:Name="RedoButton" ToolTip="Redo the last undone action" Click="RedoButton_Click" AutomationProperties.AutomationId="REDO_BUTTON">
+            <Button x:Name="RedoButton" ToolTip="Redo the last undone action" Click="RedoButton_Click">
                 <Rectangle Width="30" Height="30">
                     <Rectangle.Fill>
                         <DrawingBrush>
@@ -170,17 +171,17 @@
                 </Rectangle>
             </Button>
         </ToolBar>
-        <Canvas Name="LeftCanvas" Background="SlateGray" Grid.Column="2" Grid.Row="1" Height="auto" Grid.ColumnSpan="2" AutomationProperties.AutomationId="LEFT_CANVAS"/>
+        <local:CustomCanvas x:Name="LeftCanvas" Background="SlateGray" Grid.Column="2" Grid.Row="1" Height="auto" Grid.ColumnSpan="2"/>
         <Canvas Name="CanvasSeperator" Grid.Column="4" Grid.Row="1" Background="LightGray"/>
-        <Canvas Name="RightCanvas" Background="SlateGray" Grid.Column="5" Grid.Row="1" Height="auto"
-            MouseDown="RightCanvas_MouseDown" MouseUp="RightCanvas_MouseUp" MouseMove="RightCanvas_MouseMove" Grid.ColumnSpan="2" MouseLeave="RightCanvas_MouseLeave"
-                AutomationProperties.AutomationId="RIGHT_CANVAS"/>
+        <local:CustomCanvas x:Name="RightCanvas" Background="SlateGray" Grid.Column="5" Grid.Row="1" Height="auto"
+            MouseDown="RightCanvas_MouseDown" MouseUp="RightCanvas_MouseUp" MouseMove="RightCanvas_MouseMove" Grid.ColumnSpan="2" MouseLeave="RightCanvas_MouseLeave" TouchLeave="RightCanvas_TouchLeave" />
+
 
         <DockPanel Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="7">
             <StatusBar DockPanel.Dock="Bottom" Name="StatusBar"  Background="LightGray">
-                <TextBox Name="LoadStatusBox" Text="nothing loaded" Background="LightGray" AutomationProperties.AutomationId="LOAD_STATUS_BOX"/>
+                <TextBox Name="LoadStatusBox" Text="nothing loaded" Background="LightGray"/>
                 <Separator/>
-                <TextBox Name="LastActionBox" Text="none" Background="LightGray" AutomationProperties.AutomationId="LAST_ACTION_TAKEN_BOX"/>
+                <TextBox Name="LastActionBox" Text="none" Background="LightGray"/>
             </StatusBar>
         </DockPanel>
     </Grid>

+ 65 - 1
SketchAssistant/SketchAssistantWPF/MainWindow.xaml.cs

@@ -4,6 +4,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Reflection;
 using System.Text;
+using System.Threading;
 using System.Threading.Tasks;
 using System.Timers;
 using System.Windows;
@@ -32,7 +33,7 @@ namespace SketchAssistantWPF
             //  DispatcherTimer setup
             dispatcherTimer = new DispatcherTimer(DispatcherPriority.Render);
             dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
-            dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 5);
+            dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 10);
             ProgramPresenter.Resize(new Tuple<int, int>((int)LeftCanvas.Width, (int)LeftCanvas.Height),
                 new Tuple<int, int>((int)RightCanvas.Width, (int)RightCanvas.Height));
         }
@@ -134,6 +135,14 @@ namespace SketchAssistantWPF
         {
             ProgramPresenter.MouseEvent(MVP_Presenter.MouseAction.Up);
         }
+        
+        /// <summary>
+        /// If the finger leaves the canvas, it is treated as if the finger was released.
+        /// </summary>
+        private void RightCanvas_TouchLeave(object sender, TouchEventArgs e)
+        {
+            ProgramPresenter.MouseEvent(MVP_Presenter.MouseAction.Up);
+        }
 
         /// <summary>
         /// Get current Mouse positon within the right picture box.
@@ -153,6 +162,21 @@ namespace SketchAssistantWPF
             ProgramPresenter.NewCanvas();
         }
 
+        /// <summary>
+        /// Sends inputs to the presenter simulating drawing, used for testing and debugging.
+        /// </summary>
+        private void DebugButton(object sender, RoutedEventArgs e)
+        {
+            dispatcherTimer.Stop();
+            ProgramPresenter.NewCanvas(); Thread.Sleep(50); ProgramPresenter.Tick(); Thread.Sleep(200);
+            ProgramPresenter.MouseEvent(MVP_Presenter.MouseAction.Move, new Point(20,20)); Thread.Sleep(50); ProgramPresenter.Tick(); Thread.Sleep(50);
+            ProgramPresenter.MouseEvent(MVP_Presenter.MouseAction.Down); Thread.Sleep(50); ProgramPresenter.Tick(); Thread.Sleep(50);
+            ProgramPresenter.MouseEvent(MVP_Presenter.MouseAction.Move, new Point(200, 200)); Thread.Sleep(50); ProgramPresenter.Tick(); Thread.Sleep(50);
+            ProgramPresenter.MouseEvent(MVP_Presenter.MouseAction.Move, new Point(30, 80)); Thread.Sleep(50); ProgramPresenter.Tick(); Thread.Sleep(50);
+            ProgramPresenter.MouseEvent(MVP_Presenter.MouseAction.Up); Thread.Sleep(50); ProgramPresenter.Tick(); Thread.Sleep(50);
+            dispatcherTimer.Start();
+        }
+
         /// <summary>
         /// Ticks the Presenter.
         /// </summary>
@@ -173,6 +197,24 @@ namespace SketchAssistantWPF
         /*** PRESENTER -> VIEW ***/
         /*************************/
 
+        /// <summary>
+        /// Returns the cursor position.
+        /// </summary>
+        /// <returns>The cursor Position</returns>
+        public Point GetCursorPosition()
+        {
+            return Mouse.GetPosition(RightCanvas);
+        }
+
+        /// <summary>
+        /// If the mouse is pressed or not.
+        /// </summary>
+        /// <returns>Whether or not the mouse is pressed.</returns>
+        public bool IsMousePressed()
+        {
+            return (Mouse.LeftButton.Equals(MouseButtonState.Pressed) || Mouse.RightButton.Equals(MouseButtonState.Pressed));
+        }
+
         /// <summary>
         /// Remove the current line.
         /// </summary>
@@ -233,6 +275,28 @@ namespace SketchAssistantWPF
             RightCanvas.Children.Add(newLine);
         }
 
+        /// <summary>
+        /// Adds a point to the right canvas
+        /// </summary>
+        /// <param name="newPoint">The point</param>
+        public void AddNewPointRight(Ellipse newPoint)
+        {
+            newPoint.Height = 3; newPoint.Width = 3;
+            newPoint.Fill = Brushes.Black;
+            RightCanvas.Children.Add(newPoint);
+        }
+
+        /// <summary>
+        /// Adds a point to the left canvas
+        /// </summary>
+        /// <param name="newPoint">The point</param>
+        public void AddNewPointLeft(Ellipse newPoint)
+        {
+            newPoint.Height = 3; newPoint.Width = 3;
+            newPoint.Fill = Brushes.Black;
+            LeftCanvas.Children.Add(newPoint);
+        }
+
         /// <summary>
         /// Enables the timer of the View, which will tick the Presenter.
         /// </summary>

+ 2 - 0
SketchAssistant/SketchAssistantWPF/SketchAssistantWPF.csproj

@@ -74,6 +74,7 @@
       <SubType>Designer</SubType>
     </ApplicationDefinition>
     <Compile Include="ActionHistory.cs" />
+    <Compile Include="CustomCanvas.cs" />
     <Compile Include="FileImporter.cs" />
     <Compile Include="FileImporterException.cs" />
     <Compile Include="GeometryCalculator.cs" />
@@ -114,6 +115,7 @@
       <Generator>ResXFileCodeGenerator</Generator>
       <LastGenOutput>Resources.Designer.cs</LastGenOutput>
     </EmbeddedResource>
+    <None Include="packages.config" />
     <None Include="Properties\Settings.settings">
       <Generator>SettingsSingleFileGenerator</Generator>
       <LastGenOutput>Settings.Designer.cs</LastGenOutput>

+ 4 - 0
SketchAssistant/SketchAssistantWPF/packages.config

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="OpenCover" version="4.6.519" targetFramework="net461" />
+</packages>

+ 5 - 3
SketchAssistant/WhiteTests/UITest.cs

@@ -7,6 +7,8 @@ using TestStack.White.UIItems;
 using TestStack.White.UIItems.WindowItems;
 using TestStack.White.UIItems.Finders;
 using System.Threading;
+using SketchAssistantWPF;
+using System.Windows;
 
 namespace WhiteTests
 {
@@ -30,10 +32,10 @@ namespace WhiteTests
             setupapp();
             Window mainWindow = application.GetWindow("Sketch Assistant");
             Thread.Sleep(100);
-            Assert.AreEqual("none", mainWindow.Get<TextBox>(SearchCriteria.ByAutomationId("LAST_ACTION_TAKEN_BOX")).Text.ToString());
-            mainWindow.Get<Button>(SearchCriteria.ByAutomationId("CANVAS_BUTTON")).Click();
+            Assert.AreEqual("none", mainWindow.Get<TextBox>(SearchCriteria.ByAutomationId("LastActionBox")).Text.ToString());
+            mainWindow.Get<Button>(SearchCriteria.ByAutomationId("CanvasButton")).Click();
             Thread.Sleep(100);
-            Assert.AreEqual("Last Action: A new canvas was created.", mainWindow.Get<TextBox>(SearchCriteria.ByAutomationId("LAST_ACTION_TAKEN_BOX")).Text.ToString());
+            Assert.AreEqual("Last Action: A new canvas was created.", mainWindow.Get<TextBox>(SearchCriteria.ByAutomationId("LastActionBox")).Text.ToString());
             mainWindow.Close();
         }
     }

+ 7 - 0
SketchAssistant/WhiteTests/WhiteTests.csproj

@@ -54,6 +54,7 @@
     <Reference Include="TestStack.White, Version=0.13.0.0, Culture=neutral, PublicKeyToken=2672efbf3e161801, processorArchitecture=MSIL">
       <HintPath>..\packages\TestStack.White.0.13.3\lib\net40\TestStack.White.dll</HintPath>
     </Reference>
+    <Reference Include="WindowsBase" />
   </ItemGroup>
   <ItemGroup>
     <Compile Include="UITest.cs" />
@@ -63,6 +64,12 @@
     <None Include="app.config" />
     <None Include="packages.config" />
   </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\SketchAssistantWPF\SketchAssistantWPF.csproj">
+      <Project>{ee53ae79-2aa0-4f43-9638-1789b189d5c3}</Project>
+      <Name>SketchAssistantWPF</Name>
+    </ProjectReference>
+  </ItemGroup>
   <Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">

+ 1 - 0
SketchAssistant/WhiteTests/packages.config

@@ -3,5 +3,6 @@
   <package id="Castle.Core" version="4.3.1" targetFramework="net461" />
   <package id="MSTest.TestAdapter" version="1.4.0" targetFramework="net461" />
   <package id="MSTest.TestFramework" version="1.4.0" targetFramework="net461" />
+  <package id="OpenCover" version="4.6.519" targetFramework="net461" />
   <package id="TestStack.White" version="0.13.3" targetFramework="net461" />
 </packages>