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(); | |
//Act | |
_orderService.PlaceOrder(customerId, shoppingCart); |
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; | |
namespace TddStore.Core | |
{ | |
public interface ICustomerService | |
{ | |
Customer GetCustomer(Guid 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
using System; | |
namespace TddStore.Core | |
{ | |
public class Customer | |
{ | |
public Guid Id { get; set; } | |
public string FirstName { get; set; } | |
public string LastName { get; set; } | |
public Address ShippingAddress { get; private set; } | |
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>())) |
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>())) |
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] | |
[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(); |
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] | |
[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(); |
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 order = new Order(); |
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] | |
[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(); |
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] | |
[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(); |