Browse Source

Added XUnit to CW_Tests.

I wrote the unit tests for the test-methods in CW_Console.
CW_Tests now references CW_Console.
Ran units tests and they all passed.
merge-requests/1/head
Craig Oates 7 years ago
parent
commit
baa2bbaecd
  1. 10
      Console.Waterworks/CW_Console/CW_Console.csproj
  2. 26
      Console.Waterworks/CW_Console/ConsoleCommands.cs
  3. 4
      Console.Waterworks/CW_Console/packages.config
  4. 117
      Console.Waterworks/CW_Tests/CW_ConsoleTest.cs
  5. 23
      Console.Waterworks/CW_Tests/CW_Tests.csproj
  6. 14
      Console.Waterworks/CW_Tests/UnitTest1.cs
  7. 7
      Console.Waterworks/CW_Tests/packages.config
  8. 6
      Console.Waterworks/Console.Waterworks.sln

10
Console.Waterworks/CW_Console/CW_Console.csproj

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -12,6 +13,8 @@
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@ -49,6 +52,7 @@
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Console.Waterworks\Console.Waterworks.csproj">
@ -57,4 +61,10 @@
</ProjectReference>
</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\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props'))" />
</Target>
</Project>

26
Console.Waterworks/CW_Console/ConsoleCommands.cs

@ -115,19 +115,19 @@ namespace CW_Console
// The template
// public static string paramTest(int param1) => $"Param: {param1}";
public static string StringTest(string param1) => $"Param: {param1}";
public static string Int16Test(Int16 param1) => $"Param: {param1}";
public static string Int32Test(Int32 param1) => $"Param: {param1}";
public static string Int64Test(Int64 param1) => $"Param: {param1}";
public static string BooleanTest(bool param1) => $"Param: {param1}";
public static string ByteTest(byte param1) => $"Param: {param1}";
public static string CharTest(char param1) => $"Param: {param1}";
public static string DateTimeTest(DateTime param1) => $"Param: {param1}";
public static string DecimalTest(Decimal param1) => $"Param: {param1}";
public static string SingleTest(Single param1) => $"Param: {param1}";
public static string UInt16Test(UInt16 param1) => $"Param: {param1}";
public static string UInt32Test(UInt32 param1) => $"Param: {param1}";
public static string UInt64Test(UInt64 param1) => $"Param: {param1}";
public static string StringTest(String param1) => $"{param1}";
public static string Int16Test(Int16 param1) => $"{param1}";
public static string Int32Test(Int32 param1) => $"{param1}";
public static string Int64Test(Int64 param1) => $"{param1}";
public static string BooleanTest(Boolean param1) => $"{param1}";
public static string ByteTest(Byte param1) => $"{param1}";
public static string CharTest(Char param1) => $"{param1}";
public static string DateTimeTest(DateTime param1) => $"{param1}";
public static string DecimalTest(Decimal param1) => $"{param1}";
public static string SingleTest(Single param1) => $"{param1}";
public static string UInt16Test(UInt16 param1) => $"{param1}";
public static string UInt32Test(UInt32 param1) => $"{param1}";
public static string UInt64Test(UInt64 param1) => $"{param1}";
#endregion

4
Console.Waterworks/CW_Console/packages.config

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="xunit.runner.visualstudio" version="2.2.0" targetFramework="net47" developmentDependency="true" />
</packages>

117
Console.Waterworks/CW_Tests/CW_ConsoleTest.cs

@ -0,0 +1,117 @@
using CW_Console;
using System;
using Xunit;
namespace CW_Tests
{
public class CW_ConsoleTest
{
[Fact]
public void StringTest()
{
string testInput = "Test Input";
var realInput = ConsoleCommands.StringTest(testInput);
Assert.Equal(testInput, realInput);
}
[Fact]
public void Int16Test()
{
// Int16 = -32,768 to + 32,767
Int16 testInput = 1;
var realInput = ConsoleCommands.Int16Test(testInput);
Assert.Equal(testInput.ToString(), realInput);
}
[Fact]
public void Int32Test()
{
// Int32 = -2,147,483,648 to +2,147,483,647
Int32 testInput = 10000;
var realInput = ConsoleCommands.Int32Test(testInput);
Assert.Equal(testInput.ToString(), realInput);
}
[Fact]
public void Int64Test()
{
// Int64 = -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807
Int64 testInput = 1000000000;
var realInput = ConsoleCommands.Int64Test(testInput);
Assert.Equal(testInput.ToString(), realInput);
}
[Fact]
public void BooleanTest()
{
Boolean testInput = true;
var realInput = ConsoleCommands.BooleanTest(testInput);
Assert.Equal(testInput.ToString(), realInput);
}
[Fact]
public void ByteTest()
{
Byte testInput = 1;
var realInput = ConsoleCommands.ByteTest(testInput);
Assert.Equal(testInput.ToString(), realInput);
}
[Fact]
public void CharTest()
{
Char testInput = 'a';
var realInput = ConsoleCommands.CharTest(testInput);
Assert.Equal(testInput.ToString(), realInput);
}
[Fact]
public void DateTimeTest()
{
DateTime testInput = DateTime.Today; // Be careful with this.
var realInput = ConsoleCommands.DateTimeTest(testInput);
Assert.Equal(testInput.ToString(), realInput);
}
[Fact]
public void DecimalTest()
{
Decimal testInput = 1.001m;
var realInput = ConsoleCommands.DecimalTest(testInput);
Assert.Equal(testInput.ToString(), realInput);
}
[Fact]
public void SingleTest()
{
Single testInput = 1.001f;
var realInput = ConsoleCommands.SingleTest(testInput);
Assert.Equal(testInput.ToString(), realInput);
}
[Fact]
public void UInt16Test()
{
// UInt16 = 0 to 65535
UInt16 testInput = 1;
var realInput = ConsoleCommands.UInt16Test(testInput);
Assert.Equal(testInput.ToString(), realInput);
}
[Fact]
public void UInt32Test()
{
// UInt32 = 0 to 4,294,967,295
UInt32 testInput = 100000;
var realInput = ConsoleCommands.UInt32Test(testInput);
}
[Fact]
public void UInt64Test()
{
// UInt64 = 0 to 18,446,744,073,709,551,615
UInt64 testInput = 10000000000;
var realInput = ConsoleCommands.UInt64Test(testInput);
}
}
}

23
Console.Waterworks/CW_Tests/CW_Tests.csproj

@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CW_Tests</RootNamespace>
<AssemblyName>CW_Tests</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>
@ -19,6 +19,7 @@
<TestProjectType>UnitTest</TestProjectType>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -46,14 +47,32 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll</HintPath>
</Reference>
<Reference Include="xunit.assert, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll</HintPath>
</Reference>
<Reference Include="xunit.core, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll</HintPath>
</Reference>
<Reference Include="xunit.execution.desktop, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="UnitTest1.cs" />
<Compile Include="CW_ConsoleTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CW_Console\CW_Console.csproj">
<Project>{e26d7001-2a4e-4618-8c27-8bf504993ee9}</Project>
<Name>CW_Console</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">

14
Console.Waterworks/CW_Tests/UnitTest1.cs

@ -1,14 +0,0 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace CW_Tests
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
}
}
}

7
Console.Waterworks/CW_Tests/packages.config

@ -2,4 +2,11 @@
<packages>
<package id="MSTest.TestAdapter" version="1.1.18" targetFramework="net461" />
<package id="MSTest.TestFramework" version="1.1.18" targetFramework="net461" />
<package id="xunit" version="2.2.0" targetFramework="net461" />
<package id="xunit.abstractions" version="2.0.1" targetFramework="net461" />
<package id="xunit.assert" version="2.2.0" targetFramework="net461" />
<package id="xunit.core" version="2.2.0" targetFramework="net461" />
<package id="xunit.extensibility.core" version="2.2.0" targetFramework="net461" />
<package id="xunit.extensibility.execution" version="2.2.0" targetFramework="net461" />
<package id="xunit.runner.console" version="2.2.0" targetFramework="net461" developmentDependency="true" />
</packages>

6
Console.Waterworks/Console.Waterworks.sln

@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Console.Waterworks", "Conso
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CW_Console", "CW_Console\CW_Console.csproj", "{E26D7001-2A4E-4618-8C27-8BF504993EE9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CW_Tests", "CW_Tests\CW_Tests.csproj", "{F42AB60B-B1AF-41BD-8FFC-85D500D806A7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -21,6 +23,10 @@ Global
{E26D7001-2A4E-4618-8C27-8BF504993EE9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E26D7001-2A4E-4618-8C27-8BF504993EE9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E26D7001-2A4E-4618-8C27-8BF504993EE9}.Release|Any CPU.Build.0 = Release|Any CPU
{F42AB60B-B1AF-41BD-8FFC-85D500D806A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F42AB60B-B1AF-41BD-8FFC-85D500D806A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F42AB60B-B1AF-41BD-8FFC-85D500D806A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F42AB60B-B1AF-41BD-8FFC-85D500D806A7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

Loading…
Cancel
Save