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] | |
using System; | |
namespace TddStore.Core.Exceptions | |
{ | |
public class InvalidOrderException : Exception | |
{ | |
} | |
} |
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 WhenUserPlacesACorrectOrderThenAnOrderNumberShouldBeReturned() | |
{ | |
//Arrange | |
var shoppingCart = new ShoppingCart(); | |
shoppingCart.Items.Add(new ShoppingCartItem { ItemId = Guid.NewGuid(), Quantity = 1 }); | |
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
[TestFixture] | |
class OrderServiceTests | |
{ | |
private OrderService _orderService; | |
private IOrderDataService _orderDataService; | |
[TestFixtureSetUp] | |
public void SetupTestFixture() | |
{ | |
_orderDataService = Mock.Create<IOrderDataService>(); |
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; | |
[TestFixtureSetUp] | |
public void SetupTestFixture() | |
{ | |
_orderService = new OrderService(); | |
} |
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 | |
//Act | |
orderService.PlaceOrder(customerId, shoppingCart); | |
//Assert |
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 | |
//Act | |
//Assert | |
Mock.Assert(orderDataService); |
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 | |
//Act | |
//Assert | |
} |
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 WhenUserPlacesACorrectOrderThenAnOrderNumberShouldBeReturned() | |
{ | |
//Arrange | |
var shoppingCart = new ShoppingCart(); | |
shoppingCart.Items.Add(new ShoppingCartItem { ItemId = Guid.NewGuid(), Quantity = 1 }); | |
var customerId = Guid.NewGuid(); | |
var expectedOrderId = Guid.NewGuid(); | |
var orderDataService = Mock.Create(); |
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 WhenUserPlacesACorrectOrderThenAnOrderNumberShouldBeReturned() | |
{ | |
//Arrange | |
var shoppingCart = new ShoppingCart(); | |
shoppingCart.Items.Add(new ShoppingCartItem { ItemId = Guid.NewGuid(), Quantity = 1 }); | |
var customerId = Guid.NewGuid(); | |
var expectedOrderId = Guid.NewGuid(); | |
var orderDataService = Mock.Create(); |
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) | |
{ | |
var order = new Order(); | |
return _orderDataService.Save(order); | |
} |