public void Does_not_parse_events_with_unknown_types() { string message = "Event: UNKNOWN;"; Action action = () => StockEvent.From(message); action.ShouldThrow <ArgumentException>(); }
public void Does_not_parse_events_with_incorrect_format() { string message = "incorrect message"; Action action = () => StockEvent.From(message); action.ShouldThrow <ArgumentException>(); }
public void Parses_close_event() { string message = "Event: CLOSE;"; StockEvent stockEvent = StockEvent.From(message); string serialized = stockEvent.ToString(); stockEvent.Type.ShouldEqual(StockEventType.Close); serialized.ShouldEqual(message); }
public void Parses_purchase_event() { string message = "Event: PURCHASE; BuyerName: Buyer; NumberSold: 1;"; StockEvent stockEvent = StockEvent.From(message); string serialized = stockEvent.ToString(); stockEvent.Type.ShouldEqual(StockEventType.Purchase); stockEvent.BuyerName.ShouldEqual("Buyer"); stockEvent.NumberSold.ShouldEqual(1); serialized.ShouldEqual(message); }
public void Parses_price_event() { string message = "Event: PRICE; NumberInStock: 12; CurrentPrice: 34;"; StockEvent stockEvent = StockEvent.From(message); string serialized = stockEvent.ToString(); stockEvent.Type.ShouldEqual(StockEventType.Price); stockEvent.NumberInStock.ShouldEqual(12); stockEvent.CurrentPrice.ShouldEqual(34); serialized.ShouldEqual(message); }
private void StockMessageRecieved(string message) { StockEvent stockEvent = StockEvent.From(message); StockCommand stockCommand = _buyer.Process(stockEvent); if (stockCommand != StockCommand.None()) { _connection.SendMessage(stockCommand.ToString()); } _repository.Save(ItemId, _buyer); Notify(nameof(CurrentPrice)); Notify(nameof(NumberInStock)); Notify(nameof(BoughtSoFar)); Notify(nameof(State)); }