Permalink
Browse files

Suite du refacto des tests pour vérifier les totaux et une fois le fo…

…rmat

- Passage en verbose string → suppression du dernier espace dans le rapport
  • Loading branch information...
rdeneau committed Aug 21, 2018
1 parent 1cae33e commit 65c2179518de4bf23dbdf3b58fc12c2f62bb0760
@@ -12,57 +12,58 @@ public VideoStoreTests()
} }
[Fact] [Fact]
public void TestSingleNewReleaseStatement() public void TestSingleNewReleaseStatementTotals()
{ {
_statement.AddRental(new Rental(new Movie("The cell", Movie.NEW_RELEASE), 3)); _statement.AddRental(new Rental(new Movie("The cell", Movie.NEW_RELEASE), 3));
_statement.Generate(); _statement.Generate();
Assert.Equal(9.0m, _statement.TotalAmount); Assert.Equal(9.0m, _statement.TotalAmount);
Assert.Equal(2, _statement.FrequentRenterPoints); Assert.Equal(2, _statement.FrequentRenterPoints);
} }
[Fact] [Fact]
public void TestDualNewReleaseStatement() public void TestDualNewReleaseStatementTotals()
{ {
_statement.AddRental(new Rental(new Movie("The cell", Movie.NEW_RELEASE), 3)); _statement.AddRental(new Rental(new Movie("The cell", Movie.NEW_RELEASE), 3));
_statement.AddRental(new Rental(new Movie("The Tigger Movie", Movie.NEW_RELEASE), 3)); _statement.AddRental(new Rental(new Movie("The Tigger Movie", Movie.NEW_RELEASE), 3));
_statement.Generate();
Assert.Equal( Assert.Equal(18.0m, _statement.TotalAmount);
"Rental Record for Fred\n" + Assert.Equal(4, _statement.FrequentRenterPoints);
"\tThe cell\t9.0\n" +
"\tThe Tigger Movie\t9.0\n" +
"You owed 18.0\n" +
"You earned 4 frequent renter points \n",
_statement.Generate());
} }
[Fact] [Fact]
public void TestSingleChildrensStatement() public void TestSingleChildrensStatementTotals()
{ {
_statement.AddRental(new Rental(new Movie("The Tigger Movie", Movie.CHILDREN), 3)); _statement.AddRental(new Rental(new Movie("The Tigger Movie", Movie.CHILDREN), 3));
_statement.Generate();
Assert.Equal(1.5m, _statement.TotalAmount);
Assert.Equal(1, _statement.FrequentRenterPoints);
}
Assert.Equal( [Fact]
"Rental Record for Fred\n" + public void TestMultipleRegularStatementTotals()
"\tThe Tigger Movie\t1.5\n" + {
"You owed 1.5\n" + _statement.AddRental(new Rental(new Movie("Plan 9 from Outer Space", Movie.REGULAR), 1));
"You earned 1 frequent renter points \n", _statement.AddRental(new Rental(new Movie("8 1/2", Movie.REGULAR), 2));
_statement.Generate()); _statement.AddRental(new Rental(new Movie("Eraserhead", Movie.REGULAR), 3));
_statement.Generate();
Assert.Equal(7.5m, _statement.TotalAmount);
Assert.Equal(3, _statement.FrequentRenterPoints);
} }
[Fact] [Fact]
public void TestMultipleRegularStatement() public void TestMultipleRegularStatementFormat()
{ {
_statement.AddRental(new Rental(new Movie("Plan 9 from Outer Space", Movie.REGULAR), 1)); _statement.AddRental(new Rental(new Movie("Plan 9 from Outer Space", Movie.REGULAR), 1));
_statement.AddRental(new Rental(new Movie("8 1/2", Movie.REGULAR), 2)); _statement.AddRental(new Rental(new Movie("8 1/2", Movie.REGULAR), 2));
_statement.AddRental(new Rental(new Movie("Eraserhead", Movie.REGULAR), 3)); _statement.AddRental(new Rental(new Movie("Eraserhead", Movie.REGULAR), 3));
Assert.Equal( Assert.Equal(@"Rental Record for Fred
"Rental Record for Fred\n" + Plan 9 from Outer Space 2.0
"\tPlan 9 from Outer Space\t2.0\n" + 8 1/2 2.0
"\t8 1/2\t2.0\n" + Eraserhead 3.5
"\tEraserhead\t3.5\n" + You owed 7.5
"You owed 7.5\n" + You earned 3 frequent renter points
"You earned 3 frequent renter points \n", ", _statement.Generate());
_statement.Generate());
} }
} }
} }
@@ -63,7 +63,7 @@ public string Generate()
} }
result += "You owed " + TotalAmount.ToString("0.0", CultureInfo.InvariantCulture) + "\n"; result += "You owed " + TotalAmount.ToString("0.0", CultureInfo.InvariantCulture) + "\n";
result += "You earned " + FrequentRenterPoints.ToString() + " frequent renter points \n"; result += "You earned " + FrequentRenterPoints.ToString() + " frequent renter points\n";
return result; return result;
} }

0 comments on commit 65c2179

Please sign in to comment.