Skip to content

Commit b26b11e

Browse files
committed
Add a few more assertions to unit tests of ChainHashTable
1 parent b1dfcb9 commit b26b11e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

UnitTest/DataStructuresTests/HashTableSeparateChainingTest.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public static void Adding_TwoDuplicateElements_ReturnsException()
4040

4141
var exception = Assert.Throws<ArgumentException>(act);
4242
Assert.Equal("Key already exists in the hash table.", exception.Message);
43+
Assert.True(studentsMarks.Count == 2);
4344
}
4445

4546
[Fact]
@@ -52,6 +53,7 @@ public static void GetElement_ExistingElement_ReturnsElement()
5253
var value = studentsMarks["Name2"];
5354

5455
Assert.Equal(5, value);
56+
Assert.True(studentsMarks.Count == 2);
5557
}
5658

5759
[Fact]
@@ -65,6 +67,7 @@ public static void GetElement_NonExistingElement_ReturnsException()
6567
Action act = () => value = studentsMarks["Name3"];
6668

6769
Assert.Throws<KeyNotFoundException>(act);
70+
Assert.True(studentsMarks.Count == 2);
6871
}
6972

7073
[Fact]
@@ -120,6 +123,11 @@ public static void CopyTo_FilledHashTable_ReturnsSuccessful()
120123
Assert.Equal("Name1", arrayKeys[0]);
121124
Assert.Equal("Name2", arrayKeys[1]);
122125
Assert.Equal("Name3", arrayKeys[2]);
126+
var arrayValues = array.Select(x => x.Value).OrderBy(x => x).ToArray();
127+
Assert.Equal(1, arrayValues[0]);
128+
Assert.Equal(3, arrayValues[1]);
129+
Assert.Equal(5, arrayValues[2]);
130+
123131
}
124132

125133
[Fact]

0 commit comments

Comments
 (0)