public void ListingsShouldBeUpdated()
        {
            _tpWrapper.ExceptionToThrow = TradingPostApiWrapperMock.TestException.None;
            NotifyServiceMock notifyService = new NotifyServiceMock();
            ICommerceService commerceService = new CommerceService(_tpWrapper, notifyService);

            GameItemModel itemToUpdate = _testDataFactory.GetTestGameItems().First();
            commerceService.UpdateListings(itemToUpdate);

            Assert.Equal(_updatedListing.Buys, itemToUpdate.Listing.Buys);
            Assert.Equal(_updatedListing.Sells, itemToUpdate.Listing.Sells);
        }
        public void PricesShouldBeUpdated()
        {
            _tpWrapper.ExceptionToThrow = TradingPostApiWrapperMock.TestException.None;
            NotifyServiceMock notifyService = new NotifyServiceMock();
            ICommerceService commerceService = new CommerceService(_tpWrapper, notifyService);

            List<GameItemModel> itemsToUpdate = _testDataFactory.GetTestGameItems().ToList();

            commerceService.UpdatePrices(itemsToUpdate);
            foreach (GameItemModel item in itemsToUpdate)
            {
                Assert.Equal(_updatedPrice.Sells.UnitPrice, item.SellPrice);
                Assert.Equal(_updatedPrice.Sells.Quantity, item.SellListingQuantity);
                Assert.Equal(_updatedPrice.Buys.UnitPrice, item.BuyPrice);
                Assert.Equal(_updatedPrice.Buys.Quantity, item.BuyOrderQuantity);
            }
        }
        public void UpdatingListingsShouldNotifyOnExceptions()
        {
            NotifyServiceMock notifyService = new NotifyServiceMock();
            ICommerceService commerceService = new CommerceService(_tpWrapper, notifyService);

            GameItemModel itemToUpdate = _testDataFactory.GetTestGameItems().First();

            // make sure notifyService was not notified before throwing an exception
            Assert.False(notifyService.IsNotified);

            // WebException
            _tpWrapper.ExceptionToThrow = TradingPostApiWrapperMock.TestException.Web;
            commerceService.UpdateListings(itemToUpdate);
            Assert.True(notifyService.IsNotified);

            // JsonException
            notifyService.IsNotified = false;
            _tpWrapper.ExceptionToThrow = TradingPostApiWrapperMock.TestException.Json;
            commerceService.UpdateListings(itemToUpdate);
            Assert.True(notifyService.IsNotified);
        }