Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        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);
        }