Skip to content

Instantly share code, notes, and snippets.

@JamesBender
Last active December 26, 2015 10:59
Show Gist options
  • Save JamesBender/7140449 to your computer and use it in GitHub Desktop.
Save JamesBender/7140449 to your computer and use it in GitHub Desktop.
[Test]
public void WhenUserPlacesOrderWithItemThatIsInInventoryOrderFulfillmentWorkflowShouldComplete()
{
//Arrange
var shoppingCart = new ShoppingCart();
var itemId = Guid.NewGuid();
shoppingCart.Items.Add(new ShoppingCartItem { ItemId = itemId, Quantity = 1 });
var customerId = Guid.NewGuid();
var customer = new Customer { Id = customerId };
var orderFulfillmentSessionId = Guid.NewGuid();
Mock.Arrange(() => _customerService.GetCustomer(customerId)).Returns(customer).OccursOnce();
Mock.Arrange(() => _orderFulfillmentService.OpenSession(Arg.IsAny<string>(), Arg.IsAny<string>()))
.Returns(orderFulfillmentSessionId)
.InOrder();
Mock.Arrange(() => _orderFulfillmentService.IsInInventory(orderFulfillmentSessionId, itemId, 1))
.Returns(true)
.InOrder();
Mock.Arrange(() =>
_orderFulfillmentService.
PlaceOrder(orderFulfillmentSessionId, Arg.IsAny<IDictionary<Guid, int>>(), Arg.IsAny<string>()))
.Returns(true)
.InOrder();
Mock.Arrange(() => _orderFulfillmentService.CloseSession(orderFulfillmentSessionId))
.InOrder();
//Act
_orderService.PlaceOrder(customerId, shoppingCart);
//Assert
Mock.Assert(_orderFulfillmentService);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment