Skip to content

Instantly share code, notes, and snippets.

@Hameds
Last active November 2, 2017 10:19
Show Gist options
  • Save Hameds/2e79e89447b7133a48118a644738b753 to your computer and use it in GitHub Desktop.
Save Hameds/2e79e89447b7133a48118a644738b753 to your computer and use it in GitHub Desktop.
[Test]
[ExpectedException(typeof(InvalidOrderException))]
public void WhenAUserAttemptsToOrderAnItemWithAQuantityOfZeroThrowInvalidOrderException()
{
//Arrange
var shoppingCart = new ShoppingCart();
shoppingCart.Items.Add(new ShoppingCartItem { ItemId = Guid.NewGuid(), Quantity = 0 });
var customerId = Guid.NewGuid();
var expectedOrderId = Guid.NewGuid();
Mock.Arrange(() => _orderDataService.Save(Arg.IsAny<order>()))
.Returns(expectedOrderId)
.OccursOnce();
//Act
_orderService.PlaceOrder(customerId, shoppingCart);
//Assert
Mock.Assert(_orderDataService);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment