Skip to content

largest-series-product: Do not test digits/slices #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions exercises/largest-series-product/Example.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class LargestSeriesProduct
{
private readonly string digits;

public int[] Digits { get; private set; }
private int[] Digits;

public LargestSeriesProduct(string digits)
{
Expand All @@ -19,7 +19,7 @@ private int[] ParseValues(IEnumerable<char> values)
return values.Select(x => int.Parse(x.ToString())).ToArray();
}

public int[][] GetSlices(int limit)
private int[][] GetSlices(int limit)
{
if (limit > digits.Length) throw new ArgumentException("Slice size is too big");
var slices = new List<int[]>();
Expand Down
52 changes: 4 additions & 48 deletions exercises/largest-series-product/LargestSeriesProductTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,6 @@
[TestFixture]
public class LargestSeriesProductTest
{
[Test]
public void Splits_out_digits()
{
Assert.That(new LargestSeriesProduct("0123456789").Digits, Is.EqualTo(new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }));
}

[Ignore("Remove to run test")]
[Test]
public void Digits_maintain_order()
{
Assert.That(new LargestSeriesProduct("9876543210").Digits, Is.EqualTo(new[] { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }));
}

[Ignore("Remove to run test")]
[Test]
public void Digits_is_an_empty_array_for_empty_input()
{
Assert.That(new LargestSeriesProduct("").Digits, Is.Empty);
}

[Ignore("Remove to run test")]
[Test]
public void Slices_digits_by_limit_given()
{
Assert.That(new LargestSeriesProduct("01234").GetSlices(2),
Is.EqualTo(new[] { new[] { 0, 1 }, new[] { 1, 2 }, new[] { 2, 3 }, new[] { 3, 4 } }));
}

[Ignore("Remove to run test")]
[Test]
public void Slices_are_as_long_as_the_limit_given()
{
Assert.That(new LargestSeriesProduct("982347").GetSlices(3),
Is.EqualTo(new[] { new[] { 9, 8, 2 }, new[] { 8, 2, 3 }, new[] { 2, 3, 4 }, new[] { 3, 4, 7 } }));
}

[Ignore("Remove to run test")]
[Test]
public void Cannot_slice_bigger_than_input()
{
var ex = Assert.Throws<ArgumentException>(() => new LargestSeriesProduct("123").GetSlices(4));
Assert.That(ex.Message, Is.EqualTo("Slice size is too big"));
}

[Ignore("Remove to run test")]
[TestCase("01234567890", 2, ExpectedResult = 72)]
[TestCase("1027839564", 3, ExpectedResult = 270)]
public int Gets_the_largest_product(string digits, int seriesLength)
Expand Down Expand Up @@ -88,9 +43,10 @@ public int Largest_product_for_empty_span_is_1(string digits)
}

[Ignore("Remove to run test")]
[Test]
public void Cannot_slice_empty_string_with_nonzero_span()
[TestCase("123", 4)]
[TestCase("", 1)]
public void Cannot_take_largest_product_of_more_digits_than_input(string digits, int seriesLength)
{
Assert.Throws<ArgumentException>(() => new LargestSeriesProduct("").GetSlices(1));
Assert.Throws<ArgumentException>(() => new LargestSeriesProduct(digits).GetLargestProduct(seriesLength));
}
}