Skip to content

Commit 98aedaa

Browse files
committed
Merge branch 'master' of github.com:restsharp/RestSharp
2 parents b3e1a3d + 287c9f0 commit 98aedaa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+5940
-1544
lines changed
File renamed without changes.

RestSharp.MonoDroid/RestSharp.MonoDroid.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
</PropertyGroup>
3434
<ItemGroup>
3535
<Reference Include="mscorlib" />
36-
<Reference Include="Newtonsoft.Json.Android">
37-
<HintPath>..\References\Newtonsoft.Json.Android.dll</HintPath>
36+
<Reference Include="Newtonsoft.Json.MonoDroid">
37+
<HintPath>..\References\Newtonsoft.Json.MonoDroid.dll</HintPath>
3838
</Reference>
3939
<Reference Include="System" />
4040
<Reference Include="System.Core" />

RestSharp.Silverlight/RestSharp.Silverlight.csproj

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@
4949
</PropertyGroup>
5050
<ItemGroup>
5151
<Reference Include="mscorlib" />
52-
<Reference Include="Newtonsoft.Json, Version=4.0.5.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
52+
<Reference Include="Newtonsoft.Json, Version=4.0.8.0, Culture=neutral, processorArchitecture=MSIL">
5353
<SpecificVersion>False</SpecificVersion>
54-
<HintPath>..\packages\Newtonsoft.Json.4.0.5\lib\sl4\Newtonsoft.Json.dll</HintPath>
54+
<HintPath>..\packages\Newtonsoft.Json.4.0.8\lib\sl4\Newtonsoft.Json.dll</HintPath>
5555
</Reference>
5656
<Reference Include="System.ServiceModel" />
5757
<Reference Include="System.ServiceModel.Web" />
@@ -164,6 +164,9 @@
164164
<Compile Include="..\RestSharp\RestClient.cs">
165165
<Link>RestClient.cs</Link>
166166
</Compile>
167+
<Compile Include="..\RestSharp\RestClientExtensions.cs">
168+
<Link>RestClientExtensions.cs</Link>
169+
</Compile>
167170
<Compile Include="..\RestSharp\RestRequest.cs">
168171
<Link>RestRequest.cs</Link>
169172
</Compile>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="Newtonsoft.Json" version="4.0.5" />
3+
<package id="Newtonsoft.Json" version="4.0.8" />
44
</packages>

RestSharp.Tests/JsonTests.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ public void Can_Deserialize_4sq_Json_With_Root_Element_Specified()
4949
public void Can_Deserialize_Lists_of_Simple_Types()
5050
{
5151
var doc = File.ReadAllText(Path.Combine("SampleData", "jsonlists.txt"));
52+
var json = new JsonDeserializer ();
53+
54+
var output = json.Deserialize<JsonLists> (new RestResponse { Content = doc });
55+
56+
Assert.NotEmpty (output.Names);
57+
Assert.NotEmpty (output.Numbers);
5258
}
5359

5460
[Fact]
@@ -149,6 +155,23 @@ public void Can_Deserialize_Root_Json_Array_To_List()
149155
Assert.Equal(4, output.Count);
150156
}
151157

158+
[Fact]
159+
public void Can_Deserialize_Various_Enum_Values ()
160+
{
161+
var data = File.ReadAllText (Path.Combine ("SampleData", "jsonenums.txt"));
162+
var response = new RestResponse { Content = data };
163+
var json = new JsonDeserializer ();
164+
var output = json.Deserialize<JsonEnumsTestStructure>(response);
165+
166+
Assert.Equal (output.Upper, Disposition.Friendly);
167+
Assert.Equal (output.Lower, Disposition.Friendly);
168+
Assert.Equal (output.CamelCased, Disposition.SoSo);
169+
Assert.Equal (output.Underscores, Disposition.SoSo);
170+
Assert.Equal (output.LowerUnderscores, Disposition.SoSo);
171+
Assert.Equal (output.Dashes, Disposition.SoSo);
172+
Assert.Equal (output.LowerDashes, Disposition.SoSo);
173+
}
174+
152175
[Fact]
153176
public void Can_Deserialize_Guid_String_Fields()
154177
{

RestSharp.Tests/RestSharp.Tests.csproj

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@
5353
<DocumentationFile>bin\Release\RestSharp.Tests.xml</DocumentationFile>
5454
</PropertyGroup>
5555
<ItemGroup>
56-
<Reference Include="Newtonsoft.Json, Version=4.0.5.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
56+
<Reference Include="Newtonsoft.Json, Version=4.0.8.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
5757
<SpecificVersion>False</SpecificVersion>
58-
<HintPath>..\packages\Newtonsoft.Json.4.0.5\lib\net40\Newtonsoft.Json.dll</HintPath>
58+
<HintPath>..\packages\Newtonsoft.Json.4.0.8\lib\net40\Newtonsoft.Json.dll</HintPath>
5959
</Reference>
6060
<Reference Include="System" />
6161
<Reference Include="System.Core">
@@ -111,6 +111,9 @@
111111
<Content Include="SampleData\datetimes.txt">
112112
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
113113
</Content>
114+
<Content Include="SampleData\jsonenums.txt">
115+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
116+
</Content>
114117
<Content Include="SampleData\person.json.txt">
115118
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
116119
</Content>

RestSharp.Tests/SampleClasses/misc.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,15 @@ public class DateTimeTestStructure
153153
public DateTimeOffset? NullableDateTimeOffsetWithNull { get; set; }
154154
public DateTimeOffset? NullableDateTimeOffsetWithValue { get; set; }
155155
}
156+
157+
public class JsonEnumsTestStructure
158+
{
159+
public Disposition Upper { get; set; }
160+
public Disposition Lower { get; set; }
161+
public Disposition CamelCased { get; set; }
162+
public Disposition Underscores { get; set; }
163+
public Disposition LowerUnderscores { get; set; }
164+
public Disposition Dashes { get; set; }
165+
public Disposition LowerDashes { get; set; }
166+
}
156167
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"upper": "FRIENDLY",
3+
"lower": "friendly",
4+
"camel_cased": "SoSo",
5+
"underscores": "So_So",
6+
"lower_underscores": "so_so",
7+
"dashes": "So-So",
8+
"lower_dashes": "so_so",
9+
}

RestSharp.Tests/UrlBuilderTests.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,5 +110,29 @@ public void POST_with_resource_containing_tokens()
110110
Assert.Equal(expected, output);
111111
}
112112

113+
[Fact]
114+
public void GET_with_empty_request()
115+
{
116+
var request = new RestRequest();
117+
var client = new RestClient("http://example.com/resource");
118+
119+
var expected = new Uri("http://example.com/resource");
120+
var output = client.BuildUri(request);
121+
122+
Assert.Equal(expected, output);
123+
}
124+
125+
[Fact]
126+
public void GET_with_empty_request_and_bare_hostname()
127+
{
128+
var request = new RestRequest();
129+
var client = new RestClient("http://example.com");
130+
131+
var expected = new Uri("http://example.com/");
132+
var output = client.BuildUri(request);
133+
134+
Assert.Equal(expected, output);
135+
}
136+
113137
}
114138
}

RestSharp.Tests/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="Newtonsoft.Json" version="4.0.5" />
3+
<package id="Newtonsoft.Json" version="4.0.8" />
44
<package id="xunit" version="1.9.0.1566" />
55
<package id="xunit.extensions" version="1.9.0.1566" />
66
</packages>

0 commit comments

Comments
 (0)