exercism/csharp

Incorrect unit test for "Word Search" exercise

Closed this issue · 0 comments

During the exercise Word Search I noticed that some of the unit tests a little bit wrong:

[Fact]
public void Should_accept_an_initial_game_grid_and_a_target_search_word()
{
    var wordsToSearchFor = new[] { "clojure" };
    var grid = "jefblpepre";
    var sut = new WordSearch(grid);
    var actual = sut.Search(wordsToSearchFor);
    var expected = new Dictionary<string, ((int, int), (int, int))?>
    {
        ["clojure"] = null
    };
    Assert.Null(expected["clojure"]);
}

[Fact]
public void Should_fail_to_locate_a_word_that_is_not_in_the_puzzle()
{
    var wordsToSearchFor = new[] { "clojure", "elixir", "ecmascript", "rust", "java", "lua", "lisp", "ruby", "haskell" };
    var grid = 
        "jefblpepre\n" +
        "camdcimgtc\n" +
        "oivokprjsm\n" +
        "pbwasqroua\n" +
        "rixilelhrs\n" +
        "wolcqlirpc\n" +
        "screeaumgr\n" +
        "alxhpburyi\n" +
        "jalaycalmp\n" +
        "clojurermt";
    var sut = new WordSearch(grid);
    var actual = sut.Search(wordsToSearchFor);
    var expected = new Dictionary<string, ((int, int), (int, int))?>
    {
        ["clojure"] = ((1, 10), (7, 10)),
        ["elixir"] = ((6, 5), (1, 5)),
        ["ecmascript"] = ((10, 1), (10, 10)),
        ["rust"] = ((9, 5), (9, 2)),
        ["java"] = ((1, 1), (4, 4)),
        ["lua"] = ((8, 9), (6, 7)),
        ["lisp"] = ((3, 6), (6, 3)),
        ["ruby"] = ((8, 6), (5, 9)),
        ["haskell"] = null
    };
    Assert.Equal(expected["clojure"], actual["clojure"]);
    Assert.Equal(expected["elixir"], actual["elixir"]);
    Assert.Equal(expected["ecmascript"], actual["ecmascript"]);
    Assert.Equal(expected["rust"], actual["rust"]);
    Assert.Equal(expected["java"], actual["java"]);
    Assert.Equal(expected["lua"], actual["lua"]);
    Assert.Equal(expected["lisp"], actual["lisp"]);
    Assert.Equal(expected["ruby"], actual["ruby"]);
    Assert.Null(expected["haskell"]);
}

I think it should be actual instead of expected on the lines with Assert.Null(...).