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 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);
        }