Permalink
Browse files

Extract into a class

The very brute force implementation is to use a method. MicroObjects is all about objects, we want our functionality extracted into an object.
This isn't the final form of our object, but it starts us down the path.
  • Loading branch information...
Fyzxs committed Jun 15, 2018
1 parent 67f288b commit 73f0a425749b525f2412c2668158fe083da4c0fd
Showing with 15 additions and 3 deletions.
  1. +15 −3 AddTwoInts/AddTwoIntsTests.cs
@@ -14,15 +14,27 @@ public void ShouldReturnSumOfTwoInts()
int addend = 5;

//Act
int actual = Sum(augend, addend);
int actual = new Sum(augend, addend).Value();

//Assert
Assert.AreEqual(expected, actual);
}
}

public class Sum
{
private readonly int _augend;
private readonly int _addend;

public Sum(int augend, int addend)
{
_augend = augend;
_addend = addend;
}

private int Sum(int augend, int addend)
public int Value()
{
return augend + addend;
return _augend + _addend;
}
}
}

0 comments on commit 73f0a42

Please sign in to comment.