public async Task Should_retrieve_a_boardgame_by_id() { ThingResponse response = await bgg.GetThingAsync(new ThingRequest(new int[] { 172818 }, versions : true)); Assert.True(response.Succeeded); ThingResponse.Item game = response.Result.FirstOrDefault(); Assert.NotNull(game); Assert.Equal(172818, game.Id); Assert.Equal("boardgame", game.Type); Assert.NotNull(game.Thumbnail); Assert.NotNull(game.Image); Assert.Equal("Above and Below", game.Name); Assert.Equal(6, game.AlternateNames.Count); Assert.StartsWith("Your last village was ransacked by barbarians.", game.Description); Assert.Equal(2015, game.YearPublished); Assert.Equal(2, game.MinPlayers); Assert.Equal(4, game.MaxPlayers); Assert.Equal(90, game.PlayingTime); Assert.Equal(90, game.MinPlayingTime); Assert.Equal(90, game.MaxPlayingTime); Assert.Equal(13, game.MinAge); Assert.Equal(3, game.Polls.Count); Assert.Equal(43, game.Links.Count); Assert.Equal(9, game.Versions.Count); }
// GET: /Games/TestAPIAsync public async Task <IActionResult> TestAPIAsync() { ThingRequest request = new ThingRequest(new[] { 161936 }); ThingResponse response = await _bgg.GetThingAsync(request); // not sure that this will work ThingResponse.Item pandemicLegacySeason1 = response.Result[0]; return(View(pandemicLegacySeason1)); }
public async Task Should_retrieve_boardgame_statistics() { ThingResponse response = await bgg.GetThingAsync(new ThingRequest(new int[] { 172818 }, stats : true)); Assert.True(response.Succeeded); ThingResponse.Item game = response.Result.First(); Assert.NotNull(game.Statistics); // values are subject to change - manually test this }
public async Task Should_retrieve_videos() { ThingResponse response = await bgg.GetThingAsync(new ThingRequest(new int[] { 172818 }, videos : true)); Assert.True(response.Succeeded); ThingResponse.Item game = response.Result.First(); Assert.Equal(15, game.Videos.Count); Assert.Equal(103, game.Videos.Total); ThingResponse.Video video = game.Videos[5]; //Assert.Equal("How to Play Above and Below", video.Title); }
public async Task Should_retrieve_an_rpg_by_id() { ThingResponse response = await bgg.GetThingAsync(new ThingRequest(new int[] { 234669 }, versions : true)); Assert.True(response.Succeeded); ThingResponse.Item game = response.Result.FirstOrDefault(); Assert.NotNull(game); Assert.Equal(234669, game.Id); Assert.Equal("Legacy of Dragonholt", game.Name); Assert.Equal(2, game.Versions.Count); // could do more asserts, but i'm not all the interested in the rpg items. }
public async Task <Game> FetchGame(int id) { ThingRequest request = new ThingRequest(new[] { id }, stats: true, videos: true); ThingResponse response = await _bggApiClient.GetThingAsync(request); ThingResponse.Item item = response.Result.FirstOrDefault(); if (item == null) { return(null); } Game game = Mapper.Map <Game>(item); if (item.Statistics != null) { List <Ranking> rankings = new List <Ranking>(); foreach (var r in item.Statistics?.Ratings?.Ranks) { if (r.Value != null) { var rank = new Ranking() { GameId = game.Id, Position = (int)r.Value, }; rank.Category = r.Name.ToCategory(); rankings.Add(rank); } } game.Ranks = rankings; } if (item.Videos != null) { var vids = Mapper.Map <List <Video> >(item.Videos); foreach (var v in vids) { v.GameId = game.Id; } await VideosDb.AddOrUpdateRange(vids); } return(game); }
public async Task Should_retrieve_boardgame_marketplace_listings() { ThingResponse response = await bgg.GetThingAsync(new ThingRequest(new int[] { 172818 }, marketplace : true)); Assert.True(response.Succeeded); ThingResponse.Item game = response.Result.First(); Assert.NotNull(game.Marketplace); ThingResponse.MarketplaceListing listing = game.Marketplace[0]; Assert.Equal(new DateTimeOffset(2016, 1, 16, 20, 08, 34, 0, TimeSpan.FromHours(0)), listing.ListDate); Assert.Equal("EUR", listing.Currency); Assert.Equal(51.95, listing.Price); Assert.Equal("new", listing.Condition); Assert.Equal("weight: 1760 grams + packaging", listing.Notes); Assert.Equal("https://boardgamegeek.com/geekmarket/product/869188", listing.Link); }
public async Task Should_retrieve_boardgame_rating_comments() { ThingResponse response = await bgg.GetThingAsync(new ThingRequest(new int[] { 172818 }, ratingComments : true)); Assert.True(response.Succeeded); ThingResponse.Item game = response.Result.First(); Assert.NotNull(game.RatingComments); Assert.Equal(1, game.RatingComments.Page); Assert.Equal(100, game.RatingComments.Count); // Not 100% sure of the sort order on comments. // They seem to be oldest to newest, and if so the following assertions shouldn't change over time. ThingResponse.RatingComment comment = game.RatingComments[0]; Assert.Equal("artfuldodgr42", comment.Username); Assert.Equal(10, comment.Rating); Assert.Equal("", comment.Value); }
public async Task Should_retrieve_a_videogame_by_id() { ThingResponse response = await bgg.GetThingAsync(new ThingRequest(new int[] { 69327 }, versions : true)); Assert.True(response.Succeeded); ThingResponse.Item game = response.Result.FirstOrDefault(); Assert.NotNull(game); Assert.Equal(69327, game.Id); Assert.Equal("videogame", game.Type); Assert.NotNull(game.Thumbnail); Assert.NotNull(game.Image); Assert.Equal("The Legend of Zelda", game.Name); Assert.Equal(2, game.AlternateNames.Count); Assert.StartsWith("From the back of the \"Classic NES Series\"", game.Description); Assert.Equal(1, game.MinPlayers); Assert.Equal(1, game.MaxPlayers); Assert.Equal(15, game.Links.Count); Assert.Equal(16, game.Versions.Count); // could be interesting. }