public void NotifiesBidDetailsWhenCurrentPriceMessageReceivedFromOtherBidder() { amt.ProcessMessage(new Message(new XmlDocument()) { Body = string.Format(SOLProtocol.PRICE_EVENT_FORMAT, 0, 0, "other bidder") }); A.CallTo(() => auctionEventListener.CurrentPrice(0, 0, PriceSource.FromOtherBidder)).MustHaveHappened(Repeated.Exactly.Once); }
public void InvokeProcessMessage(MessageListenerEventArgs mle) { if (MessageHasPairedValues(mle)) { var auctionEvent = AuctionEvent.From(mle.Message.Body); switch (auctionEvent.Type) { case "CLOSE": _auctionEventListener.AuctionClosed(); break; case "PRICE": _auctionEventListener.CurrentPrice(auctionEvent.CurrentPrice, auctionEvent.Increment, auctionEvent.IsFrom(_sniperId)); break; default: string messageDetail = $"Message type: {auctionEvent.Type} not handled, from message {mle.Message.Body}"; throw new Exception(messageDetail); } } else { if (mle.Message.Body.Contains(SharedConstants.STATUS_JOINING)) { _auctionEventListener.JoiningAuction(); } } }
public void NotifiesBidDetailsWhenCurrentPriceMessageReceivedFromSniper() { _mockListener.CurrentPrice(234, 5, Enums.PriceSource.FromSniper); _mocks.ReplayAll(); var message = new Message(UNUSED_CHAT) { Body = string.Format( "SOLVersion: 1.1; Event: PRICE; CurrentPrice: 234; Increment: 5; Bidder: {0};", SNIPER_ID) }; var mlea = new MessageListenerEventArgs(message); _translator.InvokeProcessMessage(mlea); }
public AuctionMessageTranslator(JID inSniperJId, IAuctionEventListener inListener) { mSniperId = inSniperJId; mParser.RegisterAction("CLOSE", (ev) => { inListener.AuctionClosed(); }); mParser.RegisterAction("PRICE", (ev) => { inListener.CurrentPrice( ev.IntegerValueOf("CurrentPrice"), ev.IntegerValueOf("Increment"), ev.PriceSourceFrom(mSniperId) ); }); }
public void ProcessMessage(jabber.protocol.client.Message message) { AuctionEvent ev = AuctionEvent.From(message.Body); switch (ev.Type) { case "CLOSE": _listener.AuctionClosed(); break; case "PRICE": _listener.CurrentPrice(ev.CurrentPrice, ev.Increment, ev.IsFrom(_sniperId)); break; default: throw new Exception("Invalid message"); } }