Example #1
0
    public void One_row()
    {
        var actual   = PascalsTriangle.Calculate(1);
        var expected = new[] { new[] { 1 } };

        Assert.Equal(expected, actual, NestedEnumerableEqualityComparer <int> .Instance);
    }
Example #2
0
    public void Twenty_rows()
    {
        var actual   = PascalsTriangle.Calculate(20).Last();
        var expected = new[] { 1, 19, 171, 969, 3876, 11628, 27132, 50388, 75582, 92378, 92378, 75582, 50388, 27132, 11628, 3876, 969, 171, 19, 1 };

        Assert.Equal(expected, actual);
    }
Example #3
0
    public void Five_rows()
    {
        var actual   = PascalsTriangle.Calculate(5);
        var expected = new[] { new[] { 1 }, new[] { 1, 1 }, new[] { 1, 2, 1 }, new[] { 1, 3, 3, 1 }, new[] { 1, 4, 6, 4, 1 } };

        Assert.Equal(expected, actual, NestedEnumerableEqualityComparer <int> .Instance);
    }
Example #4
0
    public void Two_rows()
    {
        var actual   = PascalsTriangle.Calculate(2).ToArray();
        var expected = new[] { new[] { 1 }, new[] { 1, 1 } };

        Assert.Equal(expected, actual, NestedEnumerableEqualityComparer <int> .Instance);
    }
Example #5
0
    public void Single_row()
    {
        var expected = new[]
        {
            new[] { 1 }
        };

        Assert.Equal(expected, PascalsTriangle.Calculate(1));
    }
Example #6
0
    public void Two_rows()
    {
        var expected = new[]
        {
            new[] { 1 },
            new[] { 1, 1 }
        };

        Assert.Equal(expected, PascalsTriangle.Calculate(2));
    }
Example #7
0
    public void Four_rows()
    {
        var expected = new[]
        {
            new[] { 1 },
            new[] { 1, 1 },
            new[] { 1, 2, 1 },
            new[] { 1, 3, 3, 1 }
        };

        Assert.Equal(expected, PascalsTriangle.Calculate(4));
    }
Example #8
0
    public void Six_rows()
    {
        var expected = new[]
        {
            new[] { 1 },
            new[] { 1, 1 },
            new[] { 1, 2, 1 },
            new[] { 1, 3, 3, 1 },
            new[] { 1, 4, 6, 4, 1 },
            new[] { 1, 5, 10, 10, 5, 1 }
        };

        Assert.Equal(expected, PascalsTriangle.Calculate(6));
    }
Example #9
0
    public void Ten_rows()
    {
        var expected = new[]
        {
            new[] { 1 },
            new[] { 1, 1 },
            new[] { 1, 2, 1 },
            new[] { 1, 3, 3, 1 },
            new[] { 1, 4, 6, 4, 1 },
            new[] { 1, 5, 10, 10, 5, 1 },
            new[] { 1, 6, 15, 20, 15, 6, 1 },
            new[] { 1, 7, 21, 35, 35, 21, 7, 1 },
            new[] { 1, 8, 28, 56, 70, 56, 28, 8, 1 },
            new[] { 1, 9, 36, 84, 126, 126, 84, 36, 9, 1 }
        };

        Assert.Equal(expected, PascalsTriangle.Calculate(10));
    }
Example #10
0
 public void Zero_rows()
 {
     Assert.Empty(PascalsTriangle.Calculate(0));
 }
Example #11
0
    public void One_row()
    {
        var actual = PascalsTriangle.Calculate(1);

        Assert.That(actual, Is.EqualTo(new[] { new[] { 1 } }));
    }
Example #12
0
    public void Twenty_rows()
    {
        var actual = PascalsTriangle.Calculate(20).Last();

        Assert.That(actual, Is.EqualTo(new[] { 1, 19, 171, 969, 3876, 11628, 27132, 50388, 75582, 92378, 92378, 75582, 50388, 27132, 11628, 3876, 969, 171, 19, 1 }));
    }
Example #13
0
    public void Five_rows()
    {
        var actual = PascalsTriangle.Calculate(5);

        Assert.That(actual, Is.EqualTo(new[] { new[] { 1 }, new[] { 1, 1 }, new[] { 1, 2, 1 }, new[] { 1, 3, 3, 1 }, new [] { 1, 4, 6, 4, 1 } }));
    }
Example #14
0
    public void Three_rows()
    {
        var actual = PascalsTriangle.Calculate(3);

        Assert.That(actual, Is.EqualTo(new[] { new[] { 1 }, new[] { 1, 1 }, new[] { 1, 2, 1 } }));
    }
 public void Negative_rows()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => PascalsTriangle.Calculate(-1));
 }