Browse Source
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
8 changed files with 178 additions and 29 deletions
@ -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> |
@ -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); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -1,14 +0,0 @@ |
|||||||
using System; |
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting; |
|
||||||
|
|
||||||
namespace CW_Tests |
|
||||||
{ |
|
||||||
[TestClass] |
|
||||||
public class UnitTest1 |
|
||||||
{ |
|
||||||
[TestMethod] |
|
||||||
public void TestMethod1() |
|
||||||
{ |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
Loading…
Reference in new issue