Permalink
Browse files

Four4Sample - support custom numeral count for Results

  • Loading branch information...
bobbymcr committed Mar 17, 2018
1 parent 3a11cc3 commit 45d07d6e154dee7857b6383f96c6c0e2ecbd7a94
Showing with 21 additions and 1 deletion.
  1. +17 −0 projects/Four4Sample/Four4.Test/ResultsTest.cs
  2. +4 −1 projects/Four4Sample/Four4/Results.cs
@@ -79,6 +79,23 @@ public void SortOrder()
.And.HaveCount(2);
}
[Fact]
public void CustomNumeralCount()
{
Results results = new Results { NumeralCount = 2 };
Expression exprTooFew = default(Expression).Append("4").Append("R");
Expression exprTooMany = default(Expression).Append("44").Append("4").Append("+");
Expression exprJustRight = default(Expression).Append("4").Append("4").Append("/");
results.Add(exprTooFew);
results.Add(exprTooMany);
results.Add(exprJustRight);
Expression[] all = results.ToArray();
all.Select(e => e.ToString()).Should().ContainInOrder(
"4 4 /").And.HaveCount(1);
}
private static void TestAdd(string x, string y, string op, int count)
{
Results results = new Results();
@@ -14,13 +14,16 @@ public sealed class Results : IEnumerable<Expression>
public Results()
{
this.results = new SortedDictionary<int, Expression>();
this.NumeralCount = 4;
}
public int Count => this.results.Count;
public int NumeralCount { get; set; }
public void Add(Expression expr)
{
if (expr.NumeralCount != 4)
if (expr.NumeralCount != this.NumeralCount)
{
return;
}

0 comments on commit 45d07d6

Please sign in to comment.