private AuctionSniper CreateLosingSniper() { var sniper = new AuctionSniper("bidder", 20); sniper.Process(AuctionEvent.Price(20, 5, "other bidder")); return(sniper); }
private AuctionSniper CreateWinningSniper() { var sniper = new AuctionSniper("bidder", 200); sniper.Process(AuctionEvent.Price(1, 2, "bidder")); return(sniper); }
private AuctionSniper CreateBiddingSniper(string bidder = "some bidder") { var sniper = new AuctionSniper(bidder, 200); sniper.Process(AuctionEvent.Price(1, 2, Guid.NewGuid().ToString())); return(sniper); }
public void Sniper_is_losing_when_it_cannot_beat_last_bid() { var sniper = new AuctionSniper("bidder", 20); AuctionCommand command = sniper.Process(AuctionEvent.Price(15, 10, "other bidder")); command.ShouldEqual(AuctionCommand.None()); sniper.StateShouldBe(SniperState.Losing, 15, 0); }
public void Bidding_sniper_is_winning_when_price_event_with_the_same_bidder_arrives() { AuctionSniper sniper = CreateBiddingSniper("bidder"); AuctionCommand command = sniper.Process(AuctionEvent.Price(3, 2, "bidder")); command.ShouldEqual(AuctionCommand.None()); sniper.StateShouldBe(SniperState.Winning, 3, 3); }
public void Sniper_bids_when_price_event_with_a_different_bidder_arrives() { var sniper = new AuctionSniper("", 200); AuctionCommand command = sniper.Process(AuctionEvent.Price(1, 2, "some bidder")); command.ShouldEqual(AuctionCommand.Bid(3)); sniper.StateShouldBe(SniperState.Bidding, 1, 3); }
public void Failed_sniper_does_not_react_on_further_messages() { AuctionSniper sniper = CreateFailedSniper(); AuctionCommand command = sniper.Process(AuctionEvent.Price(10, 5, "some bidder")); command.ShouldEqual(AuctionCommand.None()); sniper.StateShouldBe(SniperState.Failed, 0, 0); }
public void Price_method_returns_a_price_event() { AuctionEvent auctionEvent = AuctionEvent.Price(1, 2, "bidder"); auctionEvent.Type.ShouldEqual(AuctionEventType.Price); auctionEvent.CurrentPrice.ShouldEqual(1); auctionEvent.Increment.ShouldEqual(2); auctionEvent.Bidder.ShouldEqual("bidder"); auctionEvent.ToString().ShouldEqual("SOLVersion: 1.1; Event: PRICE; CurrentPrice: 1; Increment: 2; Bidder: bidder;"); }