Skip to content
This repository was archived by the owner on Sep 29, 2023. It is now read-only.

Commit c47847a

Browse files
Downsized unit tests a little
1 parent 1a07b91 commit c47847a

File tree

5 files changed

+16
-87
lines changed

5 files changed

+16
-87
lines changed

net-solution/PalindromePartitions.Tests/FullAlgorithmTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System;
21
using System.Collections.Generic;
32
using NUnit.Framework;
43
using PalindromePartitions.Classes;

net-solution/PalindromePartitions.Tests/InputTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ namespace PalindromePartitions.Tests
1111
public class InputTests
1212
{
1313
// Error message strings.
14-
private static string emptyErrorText = "Input string is missing.";
15-
private static string maxLengthText = "Input string can only have up to 100 characters.";
16-
private static string wrongCharsText = "Input string must only contain alphanumeric characters.";
14+
private static readonly string EmptyErrorText = "Input string is missing.";
15+
private static readonly string MaxLengthText = "Input string can only have up to 100 characters.";
16+
private static readonly string WrongCharsText = "Input string must only contain alphanumeric characters.";
1717

1818
[Test]
1919
public void ValidString()
@@ -29,36 +29,36 @@ public void ValidString()
2929
public void EmptyArguments()
3030
{
3131
TryCatchResult testOutcome = InvalidCalls.ArgumentValidationEmpty();
32-
InvalidCalls.CheckErrorResult(testOutcome, emptyErrorText);
32+
InvalidCalls.CheckErrorResult(testOutcome, EmptyErrorText);
3333
}
3434

3535
[Test]
3636
public void EmptyString()
3737
{
3838
TryCatchResult testOutcome = InvalidCalls.ArgumentValidationPopulated("");
39-
InvalidCalls.CheckErrorResult(testOutcome, emptyErrorText);
39+
InvalidCalls.CheckErrorResult(testOutcome, EmptyErrorText);
4040
}
4141

4242
[Test]
4343
public void StringTooLong()
4444
{
4545
string reallyLongEntry = LongString.Write();
4646
TryCatchResult testOutcome = InvalidCalls.ArgumentValidationPopulated(reallyLongEntry);
47-
InvalidCalls.CheckErrorResult(testOutcome, maxLengthText);
47+
InvalidCalls.CheckErrorResult(testOutcome, MaxLengthText);
4848
}
4949

5050
[Test]
5151
public void InvalidCharacters()
5252
{
5353
TryCatchResult testOutcome = InvalidCalls.ArgumentValidationPopulated("qu!ck-#rwn-f()%");
54-
InvalidCalls.CheckErrorResult(testOutcome, wrongCharsText);
54+
InvalidCalls.CheckErrorResult(testOutcome, WrongCharsText);
5555
}
5656

5757
[Test]
5858
public void InvalidSpaces()
5959
{
6060
TryCatchResult testOutcome = InvalidCalls.ArgumentValidationPopulated("This string has spaces in it");
61-
InvalidCalls.CheckErrorResult(testOutcome, wrongCharsText);
61+
InvalidCalls.CheckErrorResult(testOutcome, WrongCharsText);
6262
}
6363
}
6464
}

net-solution/PalindromePartitions.Tests/PartitionObjectTests.cs

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System;
21
using System.Collections.Generic;
32
using NUnit.Framework;
43
using PalindromePartitions.Classes;
@@ -10,41 +9,18 @@ namespace PalindromePartitions.Tests
109
[TestFixture]
1110
public class PartitionObjectTests
1211
{
13-
// Object type shortcut.
14-
private static readonly Type ObjectType = typeof(Partition);
15-
16-
// Error message strings.
12+
// Error message strings.
1713
private static readonly string NegativeText = "Non-negative number required. (Parameter 'index')";
1814
private static readonly string BoundText = WriteBoundErrorText();
1915

2016

21-
// 'Join' function.
22-
[Test]
23-
public void JoinFunction()
24-
{
25-
Partition emptyObj = Partition.Empty();
26-
string emptyJoin = emptyObj.Join();
27-
Assert.AreEqual(emptyJoin, "");
28-
}
29-
30-
31-
// 'Empty' constructor.
32-
[Test]
33-
public void EmptyObjectConstructor()
34-
{
35-
Partition emptyObj = Partition.Empty();
36-
Assert.AreEqual(emptyObj.Count, 0);
37-
}
38-
39-
40-
// 'Initialize' constructor - Valid.
17+
// 'Initialize' constructor - Valid.
4118
[Test]
4219
public void InitializeObjectConstructorValid()
4320
{
4421
string entryString = "quickbrownfox";
4522
Partition intlObj = Partition.Initialize(ref entryString);
46-
Assert.IsInstanceOf(ObjectType, intlObj);
47-
Assert.AreEqual(intlObj.Count, entryString.Length);
23+
Assert.AreEqual(intlObj.Count, entryString.Length);
4824
PartitionContents.CompareInitializedConstructor(ref entryString, intlObj);
4925
}
5026

@@ -86,7 +62,6 @@ public void ParseObjectConstructorValid()
8662
string entryString = "meow,tacocat,hiss";
8763
Partition parsedObj = Partition.Parse(entryString);
8864

89-
Assert.IsInstanceOf(ObjectType, parsedObj);
9065
Assert.AreEqual(parsedObj.Count, 3);
9166
string actualJoin = PartitionContents.Check(parsedObj);
9267
Assert.AreEqual(entryString, actualJoin);
@@ -242,7 +217,6 @@ public void DeriveObjectConstructorBegin()
242217
Partition originalObject = Partition.Parse("ta,co,cat,abc,def");
243218
Partition derivedObject = Partition.Derive(originalObject, "tacocat", 0, 2);
244219

245-
Assert.IsInstanceOf(ObjectType, derivedObject);
246220
string deriveJoin = derivedObject.Join();
247221

248222
Assert.AreEqual(deriveJoin, "tacocat,abc,def");
Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
using System;
21
using NUnit.Framework;
32
using PalindromePartitions.Tasks;
4-
using PalindromePartitions.Tests.Common;
53

64
namespace PalindromePartitions.Tests
75
{
@@ -10,26 +8,9 @@ namespace PalindromePartitions.Tests
108
public class ResultOutputTests
119
{
1210
[Test]
13-
public void Complete()
11+
public void Placeholder()
1412
{
15-
int testFlag = AlgorithmResults.GetOutputType(20);
16-
Assert.Positive(testFlag);
13+
Assert.True(true);
1714
}
18-
19-
[Test]
20-
public void Truncated()
21-
{
22-
int testFlag = AlgorithmResults.GetOutputType(500);
23-
Assert.Zero(testFlag);
24-
}
25-
26-
27-
[Test]
28-
public void Empty()
29-
{
30-
int testFlag = AlgorithmResults.GetOutputType(-1);
31-
Assert.Negative(testFlag);
32-
}
33-
3415
}
3516
}

net-solution/PalindromePartitions/Tasks/AlgorithmResults.cs

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -36,34 +36,9 @@ public static void OutputPartitions(List<Partition> resList)
3636
Console.WriteLine("No partitions found");
3737
}
3838
}
39-
40-
41-
// Debug function indicates output mode based on given number. Used for unit testing.
42-
public static int GetOutputType(int resultCount)
43-
{
44-
int resultFlag;
45-
46-
if (resultCount > 0 && resultCount <= MaxResultsDisplay)
47-
{
48-
// Complete.
49-
resultFlag = 1;
50-
}
51-
else if (resultCount > MaxResultsDisplay)
52-
{
53-
// Truncated.
54-
resultFlag = 0;
55-
}
56-
else
57-
{
58-
// Empty.
59-
resultFlag = -1;
60-
}
61-
62-
return resultFlag;
63-
}
64-
65-
66-
// Output display loop.
39+
40+
41+
// Output display loop.
6742
private static void PrintOutput(List<Partition> rList)
6843
{
6944
int loopCutoff = Math.Min(rList.Count, MaxResultsDisplay);

0 commit comments

Comments
 (0)