Permalink
Browse files

Sum is an integer

The Sum class represents an integer. We'll refactor this to extend from Integer instead of implementing ISum. This refactor aligns it with the concept of what it is representing.

This also means that we no longer can, or need to, invoke the Value method in our Act section. We have the implicit conversion that will make it an int.
  • Loading branch information...
Fyzxs committed Jun 15, 2018
1 parent 6d38bf3 commit 1cdcc9a7662b70d70d69a46235d78be27ebdd44a
Showing with 4 additions and 12 deletions.
  1. +4 −12 AddTwoInts/AddTwoIntsTests.cs
@@ -12,10 +12,10 @@ public void ShouldReturnSumOfTwoInts()
Integer expected = new IntegerOf(9);
Integer augend = new IntegerOf(4);
Integer addend = new IntegerOf(5);
ISum subject = new Sum(augend, addend);
Integer subject = new Sum(augend, addend);

//Act
int actual = subject.Value();
int actual = subject;

//Assert
Assert.AreEqual(expected, actual);
@@ -37,7 +37,7 @@ public sealed class IntegerOf : Integer
protected override int Value() => _origin;
}

public sealed class Sum : ISum
public sealed class Sum : Integer
{
private readonly int _augend;
private readonly int _addend;
@@ -48,14 +48,6 @@ public Sum(int augend, int addend)
_addend = addend;
}

public int Value()
{
return _augend + _addend;
}
}

public interface ISum
{
int Value();
protected override int Value() => _augend + _addend;
}
}

0 comments on commit 1cdcc9a

Please sign in to comment.