Skip to content

Commit

Permalink
Add a few more assertions to unit tests of ChainHashTable
Browse files Browse the repository at this point in the history
  • Loading branch information
Gutsonok committed Nov 24, 2019
1 parent b1dfcb9 commit b26b11e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions UnitTest/DataStructuresTests/HashTableSeparateChainingTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public static void Adding_TwoDuplicateElements_ReturnsException()

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

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

Assert.Equal(5, value);
Assert.True(studentsMarks.Count == 2);
}

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

Assert.Throws<KeyNotFoundException>(act);
Assert.True(studentsMarks.Count == 2);
}

[Fact]
Expand Down Expand Up @@ -120,6 +123,11 @@ public static void CopyTo_FilledHashTable_ReturnsSuccessful()
Assert.Equal("Name1", arrayKeys[0]);
Assert.Equal("Name2", arrayKeys[1]);
Assert.Equal("Name3", arrayKeys[2]);
var arrayValues = array.Select(x => x.Value).OrderBy(x => x).ToArray();
Assert.Equal(1, arrayValues[0]);
Assert.Equal(3, arrayValues[1]);
Assert.Equal(5, arrayValues[2]);

}

[Fact]
Expand Down

0 comments on commit b26b11e

Please sign in to comment.