Skip to content

Instantly share code, notes, and snippets.

View Hameds's full-sized avatar
🎯
Focusing

Hamed Hameds

🎯
Focusing
View GitHub Profile
SetCapsLockState, AlwaysOff
+CapsLock::CapsLock
CapsLock::Send, {Ctrl down}{Shift down}{Shift up}{Ctrl up}{Ctrl up}
return
private void PlaceOrderWithFulfillmentService(ShoppingCart shoppingCart, Customer customer)
{
//Open Session
var orderFulfillmentSessionId = OpenOrderFulfillmentSession();
var firstItemId = shoppingCart.Items[0].ItemId;
var firstItemQuantity = shoppingCart.Items[0].Quantity;
//Check Inventory Level
var itemIsInInventory = _orderFulfillmentService.IsInInventory(orderFulfillmentSessionId, firstItemId, firstItemQuantity);
private void PlaceOrderWithFulfillmentService(ShoppingCart shoppingCart, Customer customer)
{
//Open Session
var orderFulfillmentSessionId = OpenOrderFulfillmentSession();
var firstItemId = shoppingCart.Items[0].ItemId;
var firstItemQuantity = shoppingCart.Items[0].Quantity;
//Check Inventory Level
var itemIsInInventory = _orderFulfillmentService.IsInInventory(orderFulfillmentSessionId, firstItemId, firstItemQuantity);
public Guid PlaceOrder(Guid customerId, ShoppingCart shoppingCart)
{
foreach (var item in shoppingCart.Items)
{
if (item.Quantity == 0)
{
throw new InvalidOrderException();
}
}
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);
[TestFixtureSetUp]
public void SetupTestFixture()
{
_orderDataService = Mock.Create();
_customerService = Mock.Create();
_orderFulfillmentService = Mock.Create();
_orderService = new OrderService(_orderDataService, _customerService, _orderFulfillmentService);
}
namespace TddStore.Core
{
public class OrderService
{
private IOrderDataService _orderDataService;
private ICustomerService _customerService;
private IOrderFulfillmentService _orderFulfillmentService;
private const string USERNAME = "Bob";
private const string PASSWORD = "Foo";
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);
namespace TddStore.UnitTests
{
[TestFixture]
class OrderServiceTests
{
private OrderService _orderService;
private IOrderDataService _orderDataService;
private ICustomerService _customerService;
private IOrderFulfillmentService _orderFulfillmentService;
[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();