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 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(); |
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 WhenUserPlacesOrderWithItemThatIsInInventoryOrderFulfillmentWorkflowShouldComplete() | |
{ | |
//Arrange | |
var shoppingCart = new ShoppingCart(); | |
shoppingCart.Items.Add(new ShoppingCartItem { ItemId = Guid.NewGuid(), Quantity = 1 }); | |
var customerId = Guid.NewGuid(); | |
var customer = new Customer { Id = customerId }; | |
Mock.Arrange(() => _customerService.GetCustomer(customerId)).Returns(customer).OccursOnce(); | |
} |
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
using System; | |
using System.Collections.Generic; | |
namespace TddStore.Core | |
{ | |
public interface IOrderFulfillmentService | |
{ | |
Guid OpenSession(string user, string password); | |
bool IsInInventory(Guid sessionId, Guid ItemNumber, int quantity); | |
bool PlaceOrder(Guid sessionId, IDictionary items, string mailingAddress); | |
void CloseSession(Guid sessionId); |
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
using System; | |
using System.Linq; | |
using NUnit.Framework; | |
using TddStore.Core; | |
using TddStore.Core.Exceptions; | |
using Telerik.JustMock; | |
namespace TddStore.UnitTests | |
{ | |
[TestFixture] |
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
using System; | |
using TddStore.Core.Exceptions; | |
namespace TddStore.Core | |
{ | |
public class OrderService | |
{ | |
private IOrderDataService _orderDataService; | |
private ICustomerService _customerService; |
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
public Guid PlaceOrder(Guid customerId, ShoppingCart shoppingCart) | |
{ | |
foreach (var item in shoppingCart.Items) | |
{ | |
if (item.Quantity == 0) | |
{ | |
throw new InvalidOrderException(); | |
} | |
} | |
var customer = _customerService.GetCustomer(customerId); |
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 customerToReturn = new Customer { Id = customerId, FirstName = "Fred", LastName = "Flinstone" }; | |
Mock.Arrange(() => _customerService.GetCustomer(customerId)) |
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" }; |
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 customerToReturn = new Customer { Id = customerId, FirstName = "Fred", LastName = "Flinstone" }; | |
//Act |
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
[TestFixture] | |
class OrderServiceTests | |
{ | |
private OrderService _orderService; | |
private IOrderDataService _orderDataService; | |
private ICustomerService _customerService; | |
[TestFixtureSetUp] | |
public void SetupTestFixture() | |
{ |