public void Buyer_closes_when_it_buys_enough_items() { Buyer buyer = CreateMonitoringBuyer("Buyer", numberToBuy: 5); StockCommand command = buyer.Process(StockEvent.Purchase("Buyer", 5)); command.ShouldEqual(StockCommand.None()); buyer.Snapshot.State.ShouldEqual(BuyerState.Closed); }
public void Purchase_method_returns_a_purchase_event() { StockEvent stockEvent = StockEvent.Purchase("some user", 1); stockEvent.Type.ShouldEqual(StockEventType.Purchase); stockEvent.BuyerName.ShouldEqual("some user"); stockEvent.NumberSold.ShouldEqual(1); stockEvent.ToString().ShouldEqual("Event: PURCHASE; BuyerName: some user; NumberSold: 1;"); }
public void Buyer_does_not_react_to_a_purchase_event_related_to_another_buyer() { Buyer buyer = CreateMonitoringBuyer("Buyer"); StockCommand command = buyer.Process(StockEvent.Purchase("Some other buyer", 1)); command.ShouldEqual(StockCommand.None()); buyer.Snapshot.State.ShouldEqual(BuyerState.Monitoring); buyer.Snapshot.BoughtSoFar.ShouldEqual(0); }
public void Buyer_updates_items_bought_so_far_when_purchase_event_with_the_same_user_name_arrives() { Buyer buyer = CreateMonitoringBuyer("name", numberInStock: 10); StockCommand command = buyer.Process(StockEvent.Purchase("name", 1)); command.ShouldEqual(StockCommand.None()); buyer.Snapshot.State.ShouldEqual(BuyerState.Monitoring); buyer.Snapshot.BoughtSoFar.ShouldEqual(1); buyer.Snapshot.NumberInStock.ShouldEqual(9); }