public async void GetItemPriceInfo_CallGw2ApiWithInvalidIdShouldFail() { ApiHelper.InitializeClient(); int[] fakeMatsArray = { int.MaxValue }; await Assert.ThrowsAsync <Exception>(async() => await CommerceProcessor.getItemPriceInfo(fakeMatsArray)); }
public CommerceProcessor GetCommerceProcessor(int testMode = 0, bool forceMock = false) { if (forceMock) { return(getCommerceProcessorMock(testMode)); } switch (Application.platform) { case RuntimePlatform.Android: commerceProcessor = new CommerceProcessorGooglePlay(); break; case RuntimePlatform.IPhonePlayer: commerceProcessor = new CommerceProcessorApple(); break; case RuntimePlatform.OSXPlayer: case RuntimePlatform.WindowsPlayer: commerceProcessor = new CommerceProcessorCSG(); break; case RuntimePlatform.OSXEditor: case RuntimePlatform.WindowsEditor: commerceProcessor = new CommerceProcessorCSG(); break; } if (commerceProcessor == null) { commerceProcessor = getCommerceProcessorMock(testMode); } return(commerceProcessor); }
public async void GetItemPriceInfo_CallGw2ApiAndReturnListOfItemModels() { // Arrange ApiHelper.InitializeClient(); int[] fakeMatsArray = { 19700, 19722, 30689 }; // Act IList <ItemModel> itemModels = await CommerceProcessor.getItemPriceInfo(fakeMatsArray); // Assert Assert.True(itemModels.Count == 3); Assert.Equal(19700, itemModels[0].Id); }
static async Task Main(string[] args) { ApiHelper.InitializeClient(); // get project directory path string projectDirectory = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName; // parse file containing item id and name info into dictionary Dictionary <int, string> parsedItemList = TextFileReader.ParseText(File.OpenRead($"{ projectDirectory }/ItemIdList.txt")); // strip ids from dictionairy keys to an array int[] mats = parsedItemList.Keys.ToArray(); // get list of item models to parse through IList <ItemModel> itemModels = await CommerceProcessor.getItemPriceInfo(mats); ProfitHelperMethods.CalculateProfit(itemModels); ProfitHelperMethods.ItemProfitDisplay(itemModels, parsedItemList); }
private CommerceProcessor getCommerceProcessorMock(int testMode = 0) { commerceProcessor = new CommerceProcessorMock(); commerceProcessor.SetTestMode(testMode); return(commerceProcessor); }