Skip to content

Instantly share code, notes, and snippets.

View Hameds's full-sized avatar
🎯
Focusing

Hamed Hameds

🎯
Focusing
View GitHub Profile
[Test]
using System;
namespace TddStore.Core.Exceptions
{
public class InvalidOrderException : Exception
{
}
}
[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>()))
[TestFixture]
class OrderServiceTests
{
private OrderService _orderService;
private IOrderDataService _orderDataService;
[TestFixtureSetUp]
public void SetupTestFixture()
{
_orderDataService = Mock.Create<IOrderDataService>();
[TestFixture]
class OrderServiceTests
{
private OrderService _orderService;
[TestFixtureSetUp]
public void SetupTestFixture()
{
_orderService = new OrderService();
}
[Test]
[ExpectedException(typeof(InvalidOrderException))]
public void WhenAUserAttemptsToOrderAnItemWithAQuantityOfZeroThrowInvalidOrderException()
{
//Arrange
//Act
orderService.PlaceOrder(customerId, shoppingCart);
//Assert
[Test]
[ExpectedException(typeof(InvalidOrderException))]
public void WhenAUserAttemptsToOrderAnItemWithAQuantityOfZeroThrowInvalidOrderException()
{
//Arrange
//Act
//Assert
Mock.Assert(orderDataService);
[Test]
[ExpectedException(typeof(InvalidOrderException))]
public void WhenAUserAttemptsToOrderAnItemWithAQuantityOfZeroThrowInvalidOrderException()
{
//Arrange
//Act
//Assert
}
[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();
[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();
public Guid PlaceOrder(Guid customerId, ShoppingCart shoppingCart)
{
var order = new Order();
return _orderDataService.Save(order);
}