Skip to content

Commit

Permalink
Moving Functionality to be on Fluent Type
Browse files Browse the repository at this point in the history
I call these base types FluentTypes as all of the behavior of the type moves into the base type class.
Instead of newing up an IntegerEquality, we can now call IsEqual on our subject and compare it to our expected. This allows us much smoother and simpler interaction with the types.
  • Loading branch information
Fyzxs committed Jun 20, 2018
1 parent 73f4736 commit ab816ac
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions AddTwoInts/AddTwoIntsTests.cs
Expand Up @@ -15,17 +15,16 @@ public void ShouldReturnSumOfTwoInts()
Integer subject = new Sum(augend, addend);

//Act
Bool integerEquality = new IntegerEquality(subject, expected);

//Assert
Assert.IsTrue(integerEquality);
Assert.IsTrue(subject.IsEqual(expected), $"Actual <{(int)subject}> was not the same as Expected <{(int)expected}>");
}
}

public abstract class Integer
{
public static implicit operator int(Integer origin) => origin.Value();
protected abstract int Value();
public Bool IsEqual(Integer other) => new IntegerEquality(this, other);
}

public sealed class IntegerOf : Integer
Expand Down

0 comments on commit ab816ac

Please sign in to comment.