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 UpdatingPricesShouldNotifyOnExceptions() { NotifyServiceMock notifyService = new NotifyServiceMock(); ICommerceService commerceService = new CommerceService(_tpWrapper, notifyService); List<GameItemModel> itemsToUpdate = _testDataFactory.GetTestGameItems().ToList(); // make sure notifyService was not notified before throwing an exception Assert.False(notifyService.IsNotified); // WebException _tpWrapper.ExceptionToThrow = TradingPostApiWrapperMock.TestException.Web; commerceService.UpdatePrices(itemsToUpdate); Assert.True(notifyService.IsNotified); // JsonException notifyService.IsNotified = false; _tpWrapper.ExceptionToThrow = TradingPostApiWrapperMock.TestException.Json; commerceService.UpdatePrices(itemsToUpdate); Assert.True(notifyService.IsNotified); }