public void ShouldAddMultipleTimesToItemQuantity(int first, int second, int expected) { // Arrange var orderItem = new OrderItem(DefaultProductId, DefaultProductName, DefaultPrice); // Act orderItem.AddQuantity(first); orderItem.AddQuantity(second); // Assert Equal(expected, orderItem.Quantity); }
public void ShouldIncreaseDefaultItemQuantityByTheFactorThatIsPassed(int quantity, int expected) { // Arrange var orderItem = new OrderItem(DefaultProductId, DefaultProductName, DefaultPrice); // Act orderItem.AddQuantity(quantity); // Assert Equal(expected, orderItem.Quantity); }
public void GivenOrderItem_WhenTheQuantityIsAdding_IsSuccessful(int initQuantity, int quantityToAdd) { // Arrange var orderItem = new OrderItem(Guid.NewGuid(), initQuantity); // Act orderItem.AddQuantity(quantityToAdd); // Assert Assert.Equal(initQuantity + quantityToAdd, orderItem.Quantity); }
public void ShouldThrowArgumentExceptionWhenQuantityIsLessThanOrEqualToZero(int quantity) { // Arrange var orderItem = new OrderItem(DefaultProductId, DefaultProductName, DefaultPrice); // Act var exception = Throws <ArgumentException>(() => orderItem.AddQuantity(quantity)); // Assert Equal("Invalid quantity", exception.Message); Equal(1, orderItem.Quantity); }
public void GivenOrderItem_WhenTheNegativeQuantityIsAdding_IsFailed(int quantityToAdd) { // Arrange var orderItem = new OrderItem(Guid.NewGuid()); var notification = new Notification(); // Act orderItem.AddQuantity(quantityToAdd); orderItem.Validate(notification); // Assert Assert.False(orderItem.IsValid); Assert.True(notification.HasErrors); }