Skip to content

Commit

Permalink
Fix TagStaticListConverter null deserialization (BenFradet#326)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pikeman authored and BenFradet committed Feb 27, 2017
1 parent 2d39e79 commit 25c1ab9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
, JsonSerializer serializer)
{
var token = JToken.Load(reader);
if (token.Type == JTokenType.Null) return null;
if (token.Values<string>() == null) return null;
var list = token.Values<string>();
var tags = new List<TagStatic>();
Expand Down
5 changes: 5 additions & 0 deletions RiotSharpTest/RiotSharpTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
</ItemGroup>
Expand Down Expand Up @@ -77,6 +81,7 @@
<None Include="App.config">
<SubType>Designer</SubType>
</None>
<None Include="packages.config" />
</ItemGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
Expand Down
12 changes: 12 additions & 0 deletions RiotSharpTest/StaticRiotApiTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;
using RiotSharp;
using RiotSharp.StaticDataEndpoint;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;

Expand Down Expand Up @@ -50,6 +52,16 @@ public void GetChampionsAsync_Test()
Assert.IsTrue(champs.Result.Champions.Count > 0);
}

[TestMethod]
[TestCategory("StaticRiotApi")]
public void SerializeChampions_Test()
{
var champs = api.GetChampions(Region.euw, ChampionData.basic);
ICollection<ChampionStatic> champ = champs.Champions.Values;
string json = JsonConvert.SerializeObject(champ);
champ = JsonConvert.DeserializeObject<List<ChampionStatic>>(json);
}

[TestMethod]
[TestCategory("StaticRiotApi")]
public void GetItems_Test()
Expand Down
4 changes: 4 additions & 0 deletions RiotSharpTest/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net45" />
</packages>

0 comments on commit 25c1ab9

Please sign in to comment.