Пример #1
0
    public void Errors_if_source_does_not_exist()
    {
        var from = "nonexistent";
        var to   = "x";
        var tree = new Tree("parent", new Tree("x", new Tree("kid-0"), new Tree("kid-1")), new Tree("sibling-0"), new Tree("sibling-1"));

        Assert.Throws <ArgumentException>(() => Pov.PathTo(from, to, tree));
    }
Пример #2
0
    public void Can_find_path_to_sibling()
    {
        var from     = "x";
        var to       = "b";
        var tree     = new Tree("parent", new Tree("a"), new Tree("x"), new Tree("b"), new Tree("c"));
        var expected = new[] { "x", "parent", "b" };

        Assert.Equal(expected, Pov.PathTo(from, to, tree));
    }
Пример #3
0
    public void Can_find_path_to_cousin()
    {
        var from     = "x";
        var to       = "cousin-1";
        var tree     = new Tree("grandparent", new Tree("parent", new Tree("x", new Tree("kid-0"), new Tree("kid-1")), new Tree("sibling-0"), new Tree("sibling-1")), new Tree("uncle", new Tree("cousin-0"), new Tree("cousin-1")));
        var expected = new[] { "x", "parent", "grandparent", "uncle", "cousin-1" };

        Assert.Equal(expected, Pov.PathTo(from, to, tree));
    }
Пример #4
0
    public void Can_find_path_from_nodes_other_than_x()
    {
        var from     = "a";
        var to       = "c";
        var tree     = new Tree("parent", new Tree("a"), new Tree("x"), new Tree("b"), new Tree("c"));
        var expected = new[] { "a", "parent", "c" };

        Assert.Equal(expected, Pov.PathTo(from, to, tree));
    }
Пример #5
0
    public void Can_find_path_not_involving_root()
    {
        var from     = "x";
        var to       = "sibling-1";
        var tree     = new Tree("grandparent", new Tree("parent", new Tree("x"), new Tree("sibling-0"), new Tree("sibling-1")));
        var expected = new[] { "x", "parent", "sibling-1" };

        Assert.Equal(expected, Pov.PathTo(from, to, tree));
    }