Permalink
Browse files

Fix typo and NewLine issue

- Use `Environment.NewLine` instead of `"\n"` (Unix new line) to have the same new line than in verbatim string literals (used in unit test)
- Simplify decimal removing ending `.0`
  • Loading branch information...
rdeneau committed Aug 26, 2018
1 parent fa2f5a8 commit 284db34b9c2e71cf873103b52dadff24673a6b9b
@@ -8,7 +8,7 @@ public class VideoStoreTests
private readonly Movie _newRelease1 = new Movie("NEW_RELEASE_1", Movie.NEW_RELEASE); private readonly Movie _newRelease1 = new Movie("NEW_RELEASE_1", Movie.NEW_RELEASE);
private readonly Movie _newRelease2 = new Movie("NEW_RELEASE_2", Movie.NEW_RELEASE); private readonly Movie _newRelease2 = new Movie("NEW_RELEASE_2", Movie.NEW_RELEASE);
private readonly Movie _childrens = new Movie("CHILDREN", Movie.CHILDREN); private readonly Movie _children = new Movie("CHILDREN", Movie.CHILDREN);
private readonly Movie _regular1 = new Movie("REGULAR_1", Movie.REGULAR); private readonly Movie _regular1 = new Movie("REGULAR_1", Movie.REGULAR);
private readonly Movie _regular2 = new Movie("REGULAR_2", Movie.REGULAR); private readonly Movie _regular2 = new Movie("REGULAR_2", Movie.REGULAR);
private readonly Movie _regular3 = new Movie("REGULAR_3", Movie.REGULAR); private readonly Movie _regular3 = new Movie("REGULAR_3", Movie.REGULAR);
@@ -18,8 +18,8 @@ public void TestSingleNewReleaseStatementTotals()
{ {
_statement.AddRental(new Rental(_newRelease1, 3)); _statement.AddRental(new Rental(_newRelease1, 3));
_statement.Generate(); _statement.Generate();
Assert.Equal(9.0m, _statement.TotalAmount); Assert.Equal(9m, _statement.TotalAmount);
Assert.Equal(2, _statement.FrequentRenterPoints); Assert.Equal(2, _statement.FrequentRenterPoints);
} }
[Fact] [Fact]
@@ -28,14 +28,14 @@ public void TestDualNewReleaseStatementTotals()
_statement.AddRental(new Rental(_newRelease1, 3)); _statement.AddRental(new Rental(_newRelease1, 3));
_statement.AddRental(new Rental(_newRelease2, 3)); _statement.AddRental(new Rental(_newRelease2, 3));
_statement.Generate(); _statement.Generate();
Assert.Equal(18.0m, _statement.TotalAmount); Assert.Equal(18m, _statement.TotalAmount);
Assert.Equal(4, _statement.FrequentRenterPoints); Assert.Equal(4, _statement.FrequentRenterPoints);
} }
[Fact] [Fact]
public void TestSingleChildrensStatementTotals() public void TestSingleChildrenStatementTotals()
{ {
_statement.AddRental(new Rental(_childrens, 3)); _statement.AddRental(new Rental(_children, 3));
_statement.Generate(); _statement.Generate();
Assert.Equal(1.5m, _statement.TotalAmount); Assert.Equal(1.5m, _statement.TotalAmount);
Assert.Equal(1, _statement.FrequentRenterPoints); Assert.Equal(1, _statement.FrequentRenterPoints);
@@ -1,4 +1,5 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
using System.Globalization; using System.Globalization;
namespace Soat.CleanCode.VideoStore.UncleBobFull namespace Soat.CleanCode.VideoStore.UncleBobFull
@@ -38,7 +39,7 @@ private void ClearTotals()
private string Header() private string Header()
{ {
return $"Rental Record for {CustomerName}\n"; return $"Rental Record for {CustomerName}{Environment.NewLine}";
} }
private string RentalLines() private string RentalLines()
@@ -80,7 +81,7 @@ private string RentalLines()
FrequentRenterPoints++; FrequentRenterPoints++;
} }
rentalLines += "\t" + rental.Movie.Title + "\t" + thisAmount.ToString("0.0", CultureInfo.InvariantCulture) + "\n"; rentalLines += "\t" + rental.Movie.Title + "\t" + thisAmount.ToString("0.0", CultureInfo.InvariantCulture) + Environment.NewLine;
TotalAmount += thisAmount; TotalAmount += thisAmount;
} }
@@ -90,8 +91,8 @@ private string RentalLines()
private string Footer() private string Footer()
{ {
var totalAmount = TotalAmount.ToString("0.0", CultureInfo.InvariantCulture); var totalAmount = TotalAmount.ToString("0.0", CultureInfo.InvariantCulture);
return $"You owed {totalAmount}\n" + return $"You owed {totalAmount}{Environment.NewLine}" +
$"You earned {FrequentRenterPoints} frequent renter points\n"; $"You earned {FrequentRenterPoints} frequent renter points{Environment.NewLine}";
} }
} }
} }

0 comments on commit 284db34

Please sign in to comment.