public void GetGameEnginesWithBuilder() { IgdbClient client = new IgdbClient(ApiKey); var engines = client.GetGameEngines(b => b.Fields("name", "companies.*") .Where("id > 500") .Limit(3) ); Assert.IsTrue(engines != null && engines.All(e => e.Id > 500)); }
public void GetGameEnginesOnlyNames() { IgdbClient client = new IgdbClient(ApiKey); ApiQuery query = new ApiQuery(); query.Fields.Add("name"); var engines = client.GetGameEngines(query); Assert.IsNotNull(engines); }
public void GetGameEnginesWhereIdIn() { const int someId = 583; const int ueId = 203; IgdbClient client = new IgdbClient(ApiKey); ApiQuery query = ApiQuery.WildCard; query.Predicate = $"id = ({someId},{ueId})"; var engines = client.GetGameEngines(query); Assert.IsTrue(engines != null && engines.Count() == 2 && engines.Any(e => e.Id == someId || e.Id == ueId)); }
public void DownloadGameEngineLogo() { const int testGameEngineId = 532; IgdbClient client = new IgdbClient(ApiKey); var logo = client.GetGameEngines(q => q .Fields("logo.*") .Where("id = " + testGameEngineId) )?.FirstOrDefault()?.Logo; byte[] imgData = new ImageLoader().DownloadJpg(logo.ImageId, ImageSize.LogoMed); string filePath = DOWNLOAD_OUTPUT_DIRECTORY + "\\" + DateTime.Now.ToString("yyyyMMdd_hh-mm-ss") + ".jpg"; System.IO.File.WriteAllBytes(filePath, imgData); }
public void GetGameEnginesInvalidField() { IgdbClient client = new IgdbClient(ApiKey); ApiQuery query = new ApiQuery(); query.Fields.Add("something"); string errorTitle = string.Empty; try { var engines = client.GetGameEngines(query); } catch (IgdbClientBadStatusException ex) { errorTitle = ex?.ErrorInformation?.Title; } Assert.AreEqual("Invalid Field", errorTitle); }
public void GetGameEnginesInvalidPredicate() { IgdbClient client = new IgdbClient(ApiKey); string errorTitle = string.Empty; try { var engines = client.GetGameEngines(b => b.Fields("name", "companies.*") .Where("id === 500") .Limit(5) ); } catch (IgdbClientBadStatusException ex) { errorTitle = ex?.ErrorInformation?.Title; } Assert.AreEqual("Syntax Error", errorTitle); }
private string _userKey = ""; // specify your free user key from https://api.igdb.com/signup public GameController(IHttpClientFactory clientFactory, IgdbClient igdbClient) { _clientFactory = clientFactory; _igdbClient = igdbClient; }