Browse Source

Switched to NUnit testing

Martin Edlund 5 years ago
parent
commit
de0ab374f1

+ 10 - 4
SketchAssistant/SketchAssistantTestSuite/SketchAssistantTestSuite.csproj → SketchAssistant/NUnitTestProject1/NUnitTestProject1.csproj

@@ -4,16 +4,22 @@
     <TargetFramework>netcoreapp2.1</TargetFramework>
 
     <IsPackable>false</IsPackable>
+
+    <ApplicationIcon />
+
+    <OutputType>Exe</OutputType>
+
+    <StartupObject />
   </PropertyGroup>
 
   <ItemGroup>
-    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
-    <PackageReference Include="MSTest.TestAdapter" Version="1.3.2" />
-    <PackageReference Include="MSTest.TestFramework" Version="1.3.2" />
+    <PackageReference Include="nunit" Version="3.10.1" />
+    <PackageReference Include="NUnit3TestAdapter" Version="3.10.0" />
+    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
   </ItemGroup>
 
   <ItemGroup>
     <ProjectReference Include="..\SketchAssistant\SketchAssistant.csproj" />
   </ItemGroup>
 
-</Project>
+</Project>

+ 16 - 17
SketchAssistant/SketchAssistantTestSuite/UnitTest1.cs → SketchAssistant/NUnitTestProject1/UnitTest1.cs

@@ -1,19 +1,18 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
+using NUnit.Framework;
+using System.Drawing;
 using System;
 using System.Collections.Generic;
-using System.Drawing;
 using SketchAssistant;
 
-namespace SketchAssistantTestSuite
+namespace Tests
 {
-    [TestClass]
-    public class LineTests
+    class LineTests
     {
         //========================//
         //= Bresenham Line Tests =//
         //========================//
 
-        [TestMethod]
+        [Test]
         public void BresenhamLineTest1()
         {
             //Test point
@@ -27,7 +26,7 @@ namespace SketchAssistantTestSuite
             }
         }
 
-        [TestMethod]
+        [Test]
         public void BresenhamLineTest2()
         {
             //Test line going from left to right
@@ -41,7 +40,7 @@ namespace SketchAssistantTestSuite
             }
         }
 
-        [TestMethod]
+        [Test]
         public void BresenhamLineTest3()
         {
             //Test line going from right to left
@@ -55,7 +54,7 @@ namespace SketchAssistantTestSuite
             }
         }
 
-        [TestMethod]
+        [Test]
         public void BresenhamLineTest4()
         {
             //Test line going from top to bottom
@@ -69,7 +68,7 @@ namespace SketchAssistantTestSuite
             }
         }
 
-        [TestMethod]
+        [Test]
         public void BresenhamLineTest5()
         {
             //Test line going from bottom to top
@@ -83,7 +82,7 @@ namespace SketchAssistantTestSuite
             }
         }
 
-        [TestMethod]
+        [Test]
         public void BresenhamLineTest6()
         {
             //Test exactly diagonal line from top left to bottom right
@@ -97,7 +96,7 @@ namespace SketchAssistantTestSuite
             }
         }
 
-        [TestMethod]
+        [Test]
         public void BresenhamLineTest7()
         {
             //Test exactly diagonal line from bottom right to top left
@@ -115,7 +114,7 @@ namespace SketchAssistantTestSuite
         //= Matrix Population Tests =//
         //===========================//
 
-        [TestMethod]
+        [Test]
         public void MatrixTest1()
         {
             //Populate Matrix for temporary Line
@@ -138,7 +137,7 @@ namespace SketchAssistantTestSuite
             }
         }
 
-        [TestMethod]
+        [Test]
         public void MatrixTest2()
         {
             //Populate Matrix for non-temporary Line
@@ -178,7 +177,7 @@ namespace SketchAssistantTestSuite
         //= Line Constructor Test =//
         //=========================//
 
-        [TestMethod]
+        [Test]
         public void ConstructorTest()
         {
             //Create non-temporary Line and check points
@@ -196,8 +195,8 @@ namespace SketchAssistantTestSuite
             Assert.AreEqual(comparisonPoints.Count, returnedPoints.Count);
             for (int i = 0; i < returnedPoints.Count; i++)
             {
-                Assert.AreEqual(comparisonPoints[i],returnedPoints[i]);
+                Assert.AreEqual(comparisonPoints[i], returnedPoints[i]);
             }
         }
     }
-}
+}

+ 5 - 5
SketchAssistant/SketchAssistant.sln

@@ -5,7 +5,7 @@ VisualStudioVersion = 15.0.28010.2050
 MinimumVisualStudioVersion = 10.0.40219.1
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SketchAssistant", "SketchAssistant\SketchAssistant.csproj", "{0336F628-A2F7-4170-8B2E-9277C23118D4}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SketchAssistantTestSuite", "SketchAssistantTestSuite\SketchAssistantTestSuite.csproj", "{B6EAD3FB-F14C-4409-9D36-E35DE318EA6E}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NUnitTestProject1", "NUnitTestProject1\NUnitTestProject1.csproj", "{F94A09DE-004E-421A-A4BE-961AD5CEC809}"
 EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -17,10 +17,10 @@ Global
 		{0336F628-A2F7-4170-8B2E-9277C23118D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{0336F628-A2F7-4170-8B2E-9277C23118D4}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{0336F628-A2F7-4170-8B2E-9277C23118D4}.Release|Any CPU.Build.0 = Release|Any CPU
-		{B6EAD3FB-F14C-4409-9D36-E35DE318EA6E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{B6EAD3FB-F14C-4409-9D36-E35DE318EA6E}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{B6EAD3FB-F14C-4409-9D36-E35DE318EA6E}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{B6EAD3FB-F14C-4409-9D36-E35DE318EA6E}.Release|Any CPU.Build.0 = Release|Any CPU
+		{F94A09DE-004E-421A-A4BE-961AD5CEC809}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{F94A09DE-004E-421A-A4BE-961AD5CEC809}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{F94A09DE-004E-421A-A4BE-961AD5CEC809}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{F94A09DE-004E-421A-A4BE-961AD5CEC809}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

+ 14 - 0
SketchAssistant/SketchAssistant/SketchAssistant.csproj

@@ -1,5 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="..\packages\NUnit3TestAdapter.3.11.2\build\net35\NUnit3TestAdapter.props" Condition="Exists('..\packages\NUnit3TestAdapter.3.11.2\build\net35\NUnit3TestAdapter.props')" />
+  <Import Project="..\packages\NUnit.3.11.0\build\NUnit.props" Condition="Exists('..\packages\NUnit.3.11.0\build\NUnit.props')" />
   <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -26,6 +28,8 @@
     <IsWebBootstrapper>false</IsWebBootstrapper>
     <UseApplicationTrust>false</UseApplicationTrust>
     <BootstrapperEnabled>true</BootstrapperEnabled>
+    <NuGetPackageImportStamp>
+    </NuGetPackageImportStamp>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <PlatformTarget>AnyCPU</PlatformTarget>
@@ -47,6 +51,9 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="nunit.framework, Version=3.11.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
+      <HintPath>..\packages\NUnit.3.11.0\lib\net45\nunit.framework.dll</HintPath>
+    </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core" />
     <Reference Include="System.Xml.Linq" />
@@ -108,4 +115,11 @@
     </BootstrapperPackage>
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
+    <PropertyGroup>
+      <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
+    </PropertyGroup>
+    <Error Condition="!Exists('..\packages\NUnit.3.11.0\build\NUnit.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit.3.11.0\build\NUnit.props'))" />
+    <Error Condition="!Exists('..\packages\NUnit3TestAdapter.3.11.2\build\net35\NUnit3TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit3TestAdapter.3.11.2\build\net35\NUnit3TestAdapter.props'))" />
+  </Target>
 </Project>

+ 9 - 0
SketchAssistant/SketchAssistant/packages.config

@@ -1,5 +1,14 @@
 <?xml version="1.0" encoding="utf-8"?>
 <packages>
+  <package id="NUnit" version="3.11.0" targetFramework="net461" />
+  <package id="NUnit.Console" version="3.9.0" targetFramework="net461" />
+  <package id="NUnit.ConsoleRunner" version="3.9.0" targetFramework="net461" />
+  <package id="NUnit.Extension.NUnitProjectLoader" version="3.6.0" targetFramework="net461" />
+  <package id="NUnit.Extension.NUnitV2Driver" version="3.7.0" targetFramework="net461" />
+  <package id="NUnit.Extension.NUnitV2ResultWriter" version="3.6.0" targetFramework="net461" />
+  <package id="NUnit.Extension.TeamCityEventListener" version="1.0.5" targetFramework="net461" />
+  <package id="NUnit.Extension.VSProjectLoader" version="3.8.0" targetFramework="net461" />
+  <package id="NUnit3TestAdapter" version="3.11.2" targetFramework="net461" />
   <package id="Svg" version="2.3.0" targetFramework="net461" />
   <package id="SvgNet" version="1.0.8" targetFramework="net461" />
 </packages>