Created
November 2, 2017 10:20
-
-
Save Hameds/727a829face992f2cc33ad2b845f2ce8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Test] | |
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 | |
try | |
{ | |
_orderService.PlaceOrder(customerId, shoppingCart); | |
} | |
catch(InvalidOrderException ex) | |
{ | |
//Assert | |
Mock.Assert(_orderDataService); | |
Assert.Pass(); | |
} | |
//Assert | |
Assert.Fail(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment