public void SetUp() { unitTestContext = new UnitTestContext(); httpClient = new SimpleHttpClient(unitTestContext.LoggingServiceMock.Object); priceFetcher = new EbayPriceFetcher(httpClient, unitTestContext.LoggingServiceMock.Object); }
public override async Task <bool> OnCommand(Command command, IMessage message, IMessenger messenger) { if (command == null) { throw new ArgumentNullException("command"); } if (message == null) { throw new ArgumentNullException("message"); } if (messenger == null) { throw new ArgumentNullException("messenger"); } if (command.Arguments.Any()) { Card card = null; if (command.Arguments.Length == 1) { string name = command.Arguments[0]; if (string.IsNullOrEmpty(name)) { return(false); } // Get card using only name card = await this.mStore.GetCard(name); } else if (command.Arguments.Length == 2) { string name = command.Arguments[1]; string set = command.Arguments[0]; if (string.IsNullOrEmpty(name)) { return(false); } if (string.IsNullOrEmpty(set)) { return(false); } // Get card using only name card = await this.mStore.GetCard(name, set); } if (card != null) { var ebay = new EbayPriceFetcher(this.mHttpClient, this.mLoggingService); string[] ebayPrice = ebay.GetPrice(card.Name); if (ebayPrice != null) { string url = this.UrlShortener.ShortenUrl(ebayPrice[1]); string msg = ""; if (!string.IsNullOrEmpty(url)) { msg = string.Format("The eBay Buy It Now price for '{0}' is {1} - {2}", card.Name, ebayPrice[0], url); } else { msg = string.Format("The eBay Buy It Now price for '{0}' is {1}", card.Name, ebayPrice[0]); } // Get other sets card is in List <Set> otherSets = await base.Store.GetCardOtherSets(card.MultiverseId); if (otherSets.Any()) { msg += string.Format(". Also appears in sets: {0}", string.Join(", ", otherSets.Select(s => s.Name).Take(5).ToArray())); } messenger.SendMessage(msg); return(true); } else { messenger.SendMessage("Price unavailable"); } } } return(false); }
public void SetUp() { httpClient = new SimpleHttpClient(loggingServiceMock.Object); priceFetcher = new EbayPriceFetcher(httpClient, loggingServiceMock.Object); }