Skip to content

Commit

Permalink
Fix naming
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-dudarev committed Dec 10, 2024
1 parent 4d7108a commit 0f195fe
Showing 1 changed file with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ public class OrderTotalsCalculationTest
{
public static IEnumerable<object[]> Data =>
[
// Expected Expected Expected
// MidpointRounding, ListPrice, DiscountAmount, Quantity, CartSubTotal, DiscountTotal, CartTotal
[MidpointRounding.AwayFromZero, 49.95m, 4.9950m, 1, 49.95m, 5.00m, 44.95m],
[MidpointRounding.ToZero, 49.95m, 4.9950m, 1, 49.95m, 4.99m, 44.96m],
[MidpointRounding.AwayFromZero, 26.25m, 1.3125m, 1, 26.25m, 1.31m, 24.94m],
[MidpointRounding.ToZero, 26.25m, 1.3125m, 1, 26.25m, 1.31m, 24.94m],
[MidpointRounding.AwayFromZero, 26.25m, 1.3125m, 3, 78.75m, 3.94m, 74.81m],
[MidpointRounding.ToZero, 26.25m, 1.3125m, 3, 78.75m, 3.93m, 74.82m],
[MidpointRounding.AwayFromZero, 422.50m, 190.1250m, 1, 422.50m, 190.13m, 232.37m],
[MidpointRounding.ToZero, 422.50m, 190.1250m, 1, 422.50m, 190.12m, 232.38m],
[MidpointRounding.AwayFromZero, 422.50m, 190.1250m, 10, 4225.00m, 1901.25m, 2323.75m],
[MidpointRounding.ToZero, 422.50m, 190.1250m, 10, 4225.00m, 1901.25m, 2323.75m],
// Expected Expected Expected
// MidpointRounding, ListPrice, DiscountAmount, Quantity, SubTotal, DiscountTotal, Total
[MidpointRounding.AwayFromZero, 49.95m, 4.9950m, 1, 49.95m, 5.00m, 44.95m],
[MidpointRounding.ToZero, 49.95m, 4.9950m, 1, 49.95m, 4.99m, 44.96m],
[MidpointRounding.AwayFromZero, 26.25m, 1.3125m, 1, 26.25m, 1.31m, 24.94m],
[MidpointRounding.ToZero, 26.25m, 1.3125m, 1, 26.25m, 1.31m, 24.94m],
[MidpointRounding.AwayFromZero, 26.25m, 1.3125m, 3, 78.75m, 3.94m, 74.81m],
[MidpointRounding.ToZero, 26.25m, 1.3125m, 3, 78.75m, 3.93m, 74.82m],
[MidpointRounding.AwayFromZero, 422.50m, 190.1250m, 1, 422.50m, 190.13m, 232.37m],
[MidpointRounding.ToZero, 422.50m, 190.1250m, 1, 422.50m, 190.12m, 232.38m],
[MidpointRounding.AwayFromZero, 422.50m, 190.1250m, 10, 4225.00m, 1901.25m, 2323.75m],
[MidpointRounding.ToZero, 422.50m, 190.1250m, 10, 4225.00m, 1901.25m, 2323.75m],
];

[Theory]
Expand All @@ -37,9 +37,9 @@ public void CalculateTotals_LineItemDiscountTotal_MustBeRounded(
decimal listPrice,
decimal discountAmount,
int quantity,
decimal expectedCartSubTotal,
decimal expectedSubTotal,
decimal expectedDiscountTotal,
decimal expectedCartTotal)
decimal expectedTotal)
{
// Arrange
var lineItem = new LineItem
Expand All @@ -49,7 +49,7 @@ public void CalculateTotals_LineItemDiscountTotal_MustBeRounded(
Quantity = quantity,
};

var cart = new CustomerOrder
var order = new CustomerOrder
{
Items = [lineItem],
};
Expand All @@ -63,16 +63,16 @@ public void CalculateTotals_LineItemDiscountTotal_MustBeRounded(
var totalsCalculator = GetTotalsCalculator(currency);

// Act
totalsCalculator.CalculateTotals(cart);
totalsCalculator.CalculateTotals(order);

// Assert
Assert.Equal(expectedCartSubTotal, cart.SubTotal);
Assert.Equal(expectedDiscountTotal, cart.DiscountTotal);
Assert.Equal(expectedCartTotal, cart.Total);
Assert.Equal(expectedSubTotal, order.SubTotal);
Assert.Equal(expectedDiscountTotal, order.DiscountTotal);
Assert.Equal(expectedTotal, order.Total);

Assert.Equal(expectedCartSubTotal, lineItem.ListTotal);
Assert.Equal(expectedSubTotal, lineItem.ListTotal);
Assert.Equal(expectedDiscountTotal, lineItem.DiscountTotal);
Assert.Equal(expectedCartTotal, lineItem.ExtendedPrice);
Assert.Equal(expectedTotal, lineItem.ExtendedPrice);
}

private DefaultCustomerOrderTotalsCalculator GetTotalsCalculator(Currency currency)
Expand Down

0 comments on commit 0f195fe

Please sign in to comment.