Moving forward 

Once the legacy system has been sufficiently refactored and a comprehensive suite of tests has been added, you may begin to think of the application as non-legacy, current, or a present-day system. It should now be trivial to add new features and squash any newly discovered defects. From this point forward, any new feature requested should be easily added with the confidence that other parts of the system will not be negatively affected.

The legacy application is no longer legacy. With a comprehensive suite of tests, you are now safe to proceed in Test-Driven Development fashion and write tests as every new feature is added. Remember to keep your tests as clean and well-refactored as any part of the production system.

Taking the GetPercent example above, how might you modify this in order to return two decimal places? Why, by writing new tests, of course! Start by creating a test to return two decimal places based on the input value.

Your test might look something like this:

[Fact]
public void ItReturnsTwoDecimalPlaces()
{
// Arrange
// Act
var result = GetPercent(1, 3);
// Assert
Assert.Equal(33.33, result);
}

Now, modify the existing method to return only two decimal places. We'll leave this as an exercise for the reader.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.245.219