Created
November 2, 2017 10:34
-
-
Save Hameds/37898dd20a015f5daf83c902b501d46d 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 WhenAValidCustomerPlacesAValidOrderAnOrderShouldBePlaced() | |
{ | |
//Arrange | |
var shoppingCart = new ShoppingCart(); | |
shoppingCart.Items.Add(new ShoppingCartItem { ItemId = Guid.NewGuid(), Quantity = 1 }); | |
var customerId = Guid.NewGuid(); | |
var expectedOrderId = Guid.NewGuid(); | |
var customerToReturn = new Customer { Id = customerId, FirstName = "Fred", LastName = "Flinstone" }; | |
Mock.Arrange(() => _orderDataService.Save(Arg.IsAny<Order>())) | |
.Returns(expectedOrderId) | |
.OccursOnce(); | |
Mock.Arrange(() => _customerService.GetCustomer(customerId)) | |
.Returns(customerToReturn) | |
.OccursOnce(); | |
//Act | |
var result = _orderService.PlaceOrder(customerId, shoppingCart); | |
//Assert | |
Assert.AreEqual(expectedOrderId, result); | |
Mock.Assert(_orderDataService); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment