public void One_row() { var actual = PascalsTriangle.Calculate(1); var expected = new[] { new[] { 1 } }; Assert.Equal(expected, actual, NestedEnumerableEqualityComparer <int> .Instance); }
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); }
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); }
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); }
public void Single_row() { var expected = new[] { new[] { 1 } }; Assert.Equal(expected, PascalsTriangle.Calculate(1)); }
public void Two_rows() { var expected = new[] { new[] { 1 }, new[] { 1, 1 } }; Assert.Equal(expected, PascalsTriangle.Calculate(2)); }
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)); }
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)); }
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)); }
public void Zero_rows() { Assert.Empty(PascalsTriangle.Calculate(0)); }
public void One_row() { var actual = PascalsTriangle.Calculate(1); Assert.That(actual, Is.EqualTo(new[] { new[] { 1 } })); }
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 })); }
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 } })); }
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)); }