public void JoinAuction(string sniperId, Item item) { List <IAuctionEventListener> eventListeners = new List <IAuctionEventListener>(); IAuction auction = auctionHouse.AuctionFor(item); AuctionSniper sniper = new AuctionSniper(item, auction); auction.AddAuctionEventListener(sniper); eventListeners.Add(sniper); collector.AddSniper(sniper); auction.Join(); }
public void AddsNewSniperToCollectorAndThenJoinsAuction() { Item item = new Item("item 123", Int32.MaxValue); IAuctionHouse auctionHouse = Substitute.For <IAuctionHouse>(); IAuction auction = Substitute.For <IAuction>(); ISniperCollector collector = Substitute.For <ISniperCollector>(); auctionHouse.AuctionFor(item).Returns(auction); auction.When(a => a.Join()).Do(a => { auction.Received(1).AddAuctionEventListener(Arg.Is <AuctionSniper>(s => s.Item.Equals(item))); collector.Received(1).AddSniper(Arg.Is <AuctionSniper>(s => s.Item.Equals(item))); }); SniperLauncher launcher = new SniperLauncher(auctionHouse, collector); launcher.JoinAuction(ApplicationRunner.SNIPER_ID, item); auction.Received(1).Join(); }