Skip to content

Commit afc7965

Browse files
authored
Release v2.1.0
Release v2.1.0
2 parents fce4780 + de91cfb commit afc7965

File tree

11 files changed

+84
-89
lines changed

11 files changed

+84
-89
lines changed

.github/workflows/deploy.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ jobs:
1111
uses: actions/checkout@v2
1212
with:
1313
fetch-depth: 0
14-
- name: Setup .NET 6
15-
uses: actions/setup-dotnet@v1
14+
- name: Setup .NET 8
15+
uses: actions/setup-dotnet@v4
1616
with:
17-
dotnet-version: 6.0.x
17+
dotnet-version: 8.0.x
1818
- name: "Build and Test"
1919
run: |
2020
dotnet build
@@ -86,10 +86,10 @@ jobs:
8686
needs: [test, version, prepublish]
8787
runs-on: windows-latest
8888
steps:
89-
- name: Setup .NET 6
90-
uses: actions/setup-dotnet@v1
89+
- name: Setup .NET 8
90+
uses: actions/setup-dotnet@v4
9191
with:
92-
dotnet-version: 6.0.x
92+
dotnet-version: 8.0.x
9393
- name: Checkout Sources
9494
uses: actions/checkout@v2
9595
with:

.github/workflows/pr.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ jobs:
1111
uses: actions/checkout@v2
1212
with:
1313
fetch-depth: 0
14-
- name: Setup .NET 6
14+
- name: Setup .NET 8
1515
uses: actions/setup-dotnet@v1
1616
with:
17-
dotnet-version: 6.0.x
17+
dotnet-version: 8.0.x
1818
- name: "Build and Test"
1919
run: |
2020
dotnet build

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# Change Log
2+
## 2.1.0
3+
Upgraded to latest Restsharp and .net 8.
24
## 2.0.0
35
Fixes:
46
* Fixed a bug where certain null values at GameModel result in breaking the code.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ For API-Docs look here: https://api.thegamesdb.net/#/
1212
This Library uses the following lib(s) fro archive its functionality:
1313
* [RestSharp](https://github.com/restsharp/RestSharp)
1414
* [NewtonSoft.Json/JSON.NET](https://github.com/JamesNK/Newtonsoft.Json)
15+
* [Shouldly](https://github.com/shouldly)
1516

1617
## Requirements
1718
* .NET 6 or higher

nugetdocs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ For API-Docs look here: https://api.thegamesdb.net/#/
1313
This Library uses the following lib(s) fro archive its functionality:
1414
* [RestSharp](https://github.com/restsharp/RestSharp)
1515
* [NewtonSoft.Json/JSON.NET](https://github.com/JamesNK/Newtonsoft.Json)
16-
16+
* [Shouldly](https://github.com/shouldly)
1717
## Requirements
1818
* .NET 6 or higher
1919
* Older Versions for NET5 and below are still available - however **starting with v2.0.0** these versions are no longer supported and marked as depricated. Please update your package to latest version when possible.

src/Data/ApiClasses/Base/BaseApiClass.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ protected async Task<T> CallGet<T>(string endpoint = null, object payload = null
172172
RestRequest r = new RestRequest(endpoint, Method.Get);
173173

174174
// Support for long requests
175-
r.Timeout = 3600;
175+
r.Timeout = TimeSpan.FromSeconds(3600);
176176

177177

178178
if (version != null)

src/Models/Entities/GameImageModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class GameImageModel
2828
/// The type.
2929
/// </value>
3030
[JsonProperty("type")]
31-
public GameImageType Type { get; set; }
31+
public GameImageType? Type { get; set; }
3232
/// <summary>
3333
/// Gets or sets the side (i.e. front or back) for boxart images.
3434
/// </summary>

src/Models/Entities/UpdateModel.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class UpdateModel
2121
/// The edit identifier.
2222
/// </value>
2323
[JsonProperty("edit_id")]
24-
public int EditID { get; set; }
24+
public int? EditID { get; set; }
2525

2626
/// <summary>
2727
/// Gets or sets the game identifier.
@@ -30,7 +30,7 @@ public class UpdateModel
3030
/// The game identifier.
3131
/// </value>
3232
[JsonProperty("game_id")]
33-
public int GameID { get; set; }
33+
public int? GameID { get; set; }
3434

3535
/// <summary>
3636
/// Gets or sets the timestamp.
@@ -39,7 +39,7 @@ public class UpdateModel
3939
/// The timestamp.
4040
/// </value>
4141
[JsonProperty("timestamp")]
42-
public DateTime Timestamp { get; set; }
42+
public DateTime? Timestamp { get; set; }
4343

4444
/// <summary>
4545
/// Gets or sets the type.
@@ -48,7 +48,7 @@ public class UpdateModel
4848
/// The type.
4949
/// </value>
5050
[JsonProperty("type")]
51-
public string Type { get; set; }
51+
public string? Type { get; set; }
5252

5353
/// <summary>
5454
/// Gets or sets the value if value is string.
@@ -67,7 +67,7 @@ public class UpdateModel
6767
/// The value.
6868
/// </value>
6969
[JsonIgnore]
70-
public string Value { get { return this.Values?.Value; } }
70+
public string? Value { get { return this.Values?.Value; } }
7171

7272
}
7373
}

src/TheGamesDBApiWrapper.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<PackageLicenseFile>LICENSE</PackageLicenseFile>
66
<Copyright>2021 Malte Peters</Copyright>
77
<Description>Wrapper Class in Fluent Style for TheGamesDBAPI</Description>
@@ -27,12 +27,12 @@ Starting with this release older versions of th is package are no longer support
2727
</PropertyGroup>
2828

2929
<ItemGroup>
30-
<PackageReference Include="Microsoft.Extensions.Configuration" Version="5.0.0" />
31-
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="5.0.0" />
32-
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.2" />
30+
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
31+
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.2" />
32+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
3333
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
34-
<PackageReference Include="RestSharp" Version="110.2.0" />
35-
<PackageReference Include="RestSharp.Serializers.NewtonsoftJson" Version="110.2.0" />
34+
<PackageReference Include="RestSharp" Version="112.1.0" />
35+
<PackageReference Include="RestSharp.Serializers.NewtonsoftJson" Version="112.1.0" />
3636
<None Include="..\nugetdocs\README.md" Pack="true" PackagePath="\" />
3737
</ItemGroup>
3838

tests/TheGamesDBApiWrapperTests/ApiTests.cs

Lines changed: 47 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using RestSharp;
66
using RestSharp.Serializers.NewtonsoftJson;
77
using RichardSzalay.MockHttp;
8+
using Shouldly;
89
using System;
910
using System.Collections.Generic;
1011
using System.IO;
@@ -41,7 +42,7 @@ private string loadJson(string filename)
4142
throw new Exception($"Json Mock {filename}.mock.json not found. Path: {p}");
4243
}
4344

44-
private RestClient mockRestClient<TResponse>(string jsonfile) where TResponse:class
45+
private RestClient mockRestClient<TResponse>(string jsonfile) where TResponse : class
4546
{
4647
string content = this.loadJson(jsonfile);
4748
var mockHttp = new MockHttpMessageHandler();
@@ -53,11 +54,8 @@ private RestClient mockRestClient<TResponse>(string jsonfile) where TResponse:cl
5354
{
5455
ConfigureMessageHandler = _ => mockHttp,
5556
BaseUrl = new Uri("https://localhost/testapi/"),
56-
57-
5857
},
5958
configureSerialization: s => s.UseNewtonsoftJson(this.getJsonSettings()));
60-
6159
}
6260

6361
private IServiceProvider ServiceProvider;
@@ -72,10 +70,8 @@ private JsonSerializerSettings getJsonSettings()
7270
return settings;
7371
}
7472

75-
76-
private void mockServices<TResponse>(string jsonfile) where TResponse:class
73+
private void mockServices<TResponse>(string jsonfile) where TResponse : class
7774
{
78-
7975
Mock<ITheGamesDBApiWrapperRestClientFactory> mock = new Mock<ITheGamesDBApiWrapperRestClientFactory>();
8076
mock.Setup(x => x.Create(It.IsAny<string>())).Returns(() => this.mockRestClient<TResponse>(jsonfile));
8177

@@ -99,10 +95,10 @@ public async Task DeveloperResponseShouldBeParsed()
9995
ITheGamesDBAPI api = this.ServiceProvider.GetService<ITheGamesDBAPI>();
10096
var response = await api.Developers.All();
10197

102-
Assert.NotNull(response.Code);
103-
Assert.NotNull(response.Data);
104-
Assert.NotNull(response.Data.Developers);
105-
Assert.NotNull(response.Data.Developers.First().Value.Name);
98+
response.Code.ShouldBeGreaterThan(0);
99+
response.Data.ShouldNotBeNull();
100+
response.Data.Developers.ShouldNotBeNull();
101+
response.Data.Developers.First().Value.Name.ShouldNotBeNull();
106102
}
107103

108104
[TestCaseSource(nameof(GameByIdMocks))]
@@ -111,35 +107,34 @@ public async Task GameByIdResponseShouldBeParsed(string mockfile)
111107
this.mockServices<GamesByGameIDResponse>(mockfile);
112108

113109
ITheGamesDBAPI api = this.ServiceProvider.GetService<ITheGamesDBAPI>();
114-
var response = await api.Games.ByGameID(new int[] { 1,2,3,4,5});
110+
var response = await api.Games.ByGameID(new int[] { 1, 2, 3, 4, 5 });
115111

116-
Assert.NotNull(response.Code);
117-
Assert.NotNull(response.Data);
118-
Assert.NotNull(response.Data.Games);
119-
Assert.NotNull(response.Data.Games.First().GameTitle);
112+
response.Code.ShouldBeGreaterThan(0);
113+
response.Data.ShouldNotBeNull();
114+
response.Data.Games.ShouldNotBeNull();
115+
response.Data.Games.First().GameTitle.ShouldNotBeNull();
120116
}
121117

122118
public static object[] GameByIdMocks = {
123-
new object[] { "game-by-id" },
124-
new object[] { "game-by-id-2" }
125-
};
119+
new object[] { "game-by-id" },
120+
new object[] { "game-by-id-2" }
121+
};
126122

127123
[Test]
128124
public async Task GameImagesResponseShouldBeParsed()
129125
{
130126
this.mockServices<GamesImagesResponse>("game-images");
131127

132128
ITheGamesDBAPI api = this.ServiceProvider.GetService<ITheGamesDBAPI>();
133-
var response = await api.Games.Images(new int[] { 1});
134-
135-
Assert.NotNull(response.Code);
136-
Assert.NotNull(response.Data);
137-
Assert.NotNull(response.Data.BaseUrl);
138-
Assert.NotNull(response.Pages);
139-
Assert.NotNull(response.Data.Images);
140-
Assert.NotNull(response.Data.Images.First().Value.First().Type);
141-
Assert.AreEqual(response.Data.Images.First().Value.First().Type, GameImageType.Fanart);
142-
129+
var response = await api.Games.Images(new int[] { 1 });
130+
131+
response.Code.ShouldBeGreaterThan(0);
132+
response.Data.ShouldNotBeNull();
133+
response.Data.BaseUrl.ShouldNotBeNull();
134+
response.Pages.ShouldNotBeNull();
135+
response.Data.Images.ShouldNotBeNull();
136+
response.Data.Images.First().Value.First().Type.ShouldNotBeNull();
137+
response.Data.Images.First().Value.First().Type.ShouldBe(GameImageType.Fanart);
143138
}
144139

145140
[Test]
@@ -151,16 +146,14 @@ public async Task GameUpdateResponseShouldBeParsed()
151146

152147
var response = await api.Games.Updates(0);
153148

154-
Assert.NotNull(response.Code);
155-
Assert.NotNull(response.Data);
156-
Assert.NotNull(response.Data.Updates);
157-
Assert.NotNull(response.Data.Updates.First().EditID);
158-
Assert.NotNull(response.Data.Updates.First().GameID);
159-
Assert.NotNull(response.Data.Updates.First().Timestamp);
160-
Assert.NotNull(response.Data.Updates.First().Type);
161-
Assert.NotNull(response.Data.Updates.First().Value);
162-
163-
149+
response.Code.ShouldBeGreaterThan(0);
150+
response.Data.ShouldNotBeNull();
151+
response.Data.Updates.ShouldNotBeNull();
152+
response.Data.Updates.First().EditID.ShouldNotBeNull();
153+
response.Data.Updates.First().GameID.ShouldNotBeNull();
154+
response.Data.Updates.First().Timestamp.ShouldNotBeNull();
155+
response.Data.Updates.First().Type.ShouldNotBeNull();
156+
response.Data.Updates.First().Value.ShouldNotBeNull();
164157
}
165158

166159
[Test]
@@ -172,11 +165,10 @@ public async Task PlatformsResponseShouldBeParsed()
172165

173166
var response = await api.Platform.All();
174167

175-
Assert.NotNull(response.Code);
176-
Assert.NotNull(response.Data);
177-
Assert.NotNull(response.Data.Platforms);
178-
Assert.NotNull(response.Data.Platforms.First().Value.Name);
179-
168+
response.Code.ShouldBeGreaterThan(0);
169+
response.Data.ShouldNotBeNull();
170+
response.Data.Platforms.ShouldNotBeNull();
171+
response.Data.Platforms.First().Value.Name.ShouldNotBeNull();
180172
}
181173

182174
[Test]
@@ -188,11 +180,10 @@ public async Task GenresResponseShouldBeParsed()
188180

189181
var response = await api.Genres.All();
190182

191-
192-
Assert.NotNull(response.Code);
193-
Assert.NotNull(response.Data);
194-
Assert.NotNull(response.Data.Genres);
195-
Assert.NotNull(response.Data.Genres.First().Value.Name);
183+
response.Code.ShouldBeGreaterThan(0);
184+
response.Data.ShouldNotBeNull();
185+
response.Data.Genres.ShouldNotBeNull();
186+
response.Data.Genres.First().Value.Name.ShouldNotBeNull();
196187
}
197188

198189
[Test]
@@ -204,11 +195,10 @@ public async Task PublishersResponseShouldBeParsed()
204195

205196
var response = await api.Publishers.All();
206197

207-
208-
Assert.NotNull(response.Code);
209-
Assert.NotNull(response.Data);
210-
Assert.NotNull(response.Data.Publishers);
211-
Assert.NotNull(response.Data.Publishers.First().Value.Name);
198+
response.Code.ShouldBeGreaterThan(0);
199+
response.Data.ShouldNotBeNull();
200+
response.Data.Publishers.ShouldNotBeNull();
201+
response.Data.Publishers.First().Value.Name.ShouldNotBeNull();
212202
}
213203

214204
[Test]
@@ -221,12 +211,11 @@ public async Task AllowanceShouldBeTracked()
221211

222212
IAllowanceTracker tracker = this.ServiceProvider.GetService<IAllowanceTracker>();
223213

224-
Assert.NotNull(tracker.Current);
225-
Assert.AreEqual(2916, tracker.Current.Remaining);
226-
Assert.AreSame(api.AllowanceTrack, tracker.Current);
214+
tracker.Current.ShouldNotBeNull();
215+
tracker.Current.Remaining.ShouldBe(2916);
216+
api.AllowanceTrack.ShouldBeSameAs(tracker.Current);
227217
}
228218

229219
#endregion
230-
231220
}
232221
}

0 commit comments

Comments
 (0)