diff --git a/src/.nuget/NuGet.Config b/src/.nuget/NuGet.Config new file mode 100644 index 0000000..67f8ea0 --- /dev/null +++ b/src/.nuget/NuGet.Config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/.nuget/NuGet.targets b/src/.nuget/NuGet.targets new file mode 100644 index 0000000..3f8c37b --- /dev/null +++ b/src/.nuget/NuGet.targets @@ -0,0 +1,144 @@ + + + + $(MSBuildProjectDirectory)\..\ + + + false + + + false + + + true + + + false + + + + + + + + + + + $([System.IO.Path]::Combine($(SolutionDir), ".nuget")) + + + + + $(SolutionDir).nuget + + + + $(MSBuildProjectDirectory)\packages.$(MSBuildProjectName.Replace(' ', '_')).config + $(MSBuildProjectDirectory)\packages.$(MSBuildProjectName).config + + + + $(MSBuildProjectDirectory)\packages.config + $(PackagesProjectConfig) + + + + + $(NuGetToolsPath)\NuGet.exe + @(PackageSource) + + "$(NuGetExePath)" + mono --runtime=v4.0.30319 "$(NuGetExePath)" + + $(TargetDir.Trim('\\')) + + -RequireConsent + -NonInteractive + + "$(SolutionDir) " + "$(SolutionDir)" + + + $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir) + $(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols + + + + RestorePackages; + $(BuildDependsOn); + + + + + $(BuildDependsOn); + BuildPackage; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/PortableRest.Tests/Mocks/JsonConverterMock.cs b/src/PortableRest.Tests/Mocks/JsonConverterMock.cs new file mode 100644 index 0000000..8f6e616 --- /dev/null +++ b/src/PortableRest.Tests/Mocks/JsonConverterMock.cs @@ -0,0 +1,32 @@ +// JsonConverterMock.cs +// - PortableRest +// -- PortableRest.Tests +// +// Author: Jeff Hansen + +using System; +using Newtonsoft.Json; + +namespace PortableRest.Tests.Mocks +{ + public class JsonConverterMock : JsonConverter + { + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + throw new NotImplementedException(); + } + + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + throw new NotImplementedException(); + } + + public override bool CanConvert(Type objectType) + { + Calls++; + return false; + } + + public int Calls { get; private set; } + } +} \ No newline at end of file diff --git a/src/PortableRest.Tests/PortableRest.Tests.csproj b/src/PortableRest.Tests/PortableRest.Tests.csproj index d7ff358..0d837e6 100644 --- a/src/PortableRest.Tests/PortableRest.Tests.csproj +++ b/src/PortableRest.Tests/PortableRest.Tests.csproj @@ -50,12 +50,10 @@ true ..\PortableRest.snk - + ..\packages\AsyncOAuth.0.8.4\lib\AsyncOAuth.dll - - False ..\packages\FluentAssertions.3.0.107\lib\net45\FluentAssertions.dll @@ -77,15 +75,12 @@ ..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll - True ..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll - True ..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll - True False @@ -97,17 +92,15 @@ - - False - ..\packages\Microsoft.Net.Http.2.2.22\lib\net45\System.Net.Http.Extensions.dll + + ..\packages\Microsoft.Net.Http.2.2.28\lib\net45\System.Net.Http.Extensions.dll False ..\packages\Microsoft.AspNet.WebApi.Client.5.2.0-rc\lib\net45\System.Net.Http.Formatting.dll - - False - ..\packages\Microsoft.Net.Http.2.2.22\lib\net45\System.Net.Http.Primitives.dll + + ..\packages\Microsoft.Net.Http.2.2.28\lib\net45\System.Net.Http.Primitives.dll @@ -144,6 +137,7 @@ + @@ -194,6 +188,13 @@ + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + diff --git a/src/PortableRest.Tests/SendAsyncTests.cs b/src/PortableRest.Tests/SendAsyncTests.cs index 9766977..4ac0939 100644 --- a/src/PortableRest.Tests/SendAsyncTests.cs +++ b/src/PortableRest.Tests/SendAsyncTests.cs @@ -6,7 +6,9 @@ using FluentAssertions; using Microsoft.Owin.Hosting; using Microsoft.VisualStudio.TestTools.UnitTesting; +using Newtonsoft.Json; using PortableRest.Tests.AsyncTestUtilities; +using PortableRest.Tests.Mocks; using PortableRest.Tests.OwinSelfHostServer; namespace PortableRest.Tests @@ -146,6 +148,34 @@ public void AsyncLibrariesLikePortableRestShouldNotDeadlockOnTaskResult() } + [TestMethod] + public void JsonDeserializerSettingsAreUsedWhenDeserializingJson() + { + // Setup + var settings = new JsonSerializerSettings(); + var converterMock = new JsonConverterMock(); + settings.Converters.Add(converterMock); + var client = new RestClient { BaseUrl = BaseAddress, JsonDeserializerSettings = settings}; + var request = new RestRequest("api/books"); + RestResponse> response = null; + + // Execute + using (WebApp.Start(BaseAddress)) + { + // Simulate ASP.NET and Windows Forms thread affinity + WindowsFormsContext.Run(() => + { + // Should not deadlock on this call + response = client.SendAsync>(request).Result; + }); + } + + // Validate + converterMock.Calls.Should().NotBe(0); + response.Content.Should().NotBeNull(); + response.Content.Count().Should().Be(5); + + } } } \ No newline at end of file diff --git a/src/PortableRest.Tests/app.config b/src/PortableRest.Tests/app.config index b74c831..c736c48 100644 --- a/src/PortableRest.Tests/app.config +++ b/src/PortableRest.Tests/app.config @@ -4,7 +4,7 @@ - + diff --git a/src/PortableRest.Tests/packages.config b/src/PortableRest.Tests/packages.config index 4d58944..bb0fba2 100644 --- a/src/PortableRest.Tests/packages.config +++ b/src/PortableRest.Tests/packages.config @@ -9,7 +9,7 @@ - + diff --git a/src/PortableRest.sln b/src/PortableRest.sln index 4e3c82f..e274f86 100644 --- a/src/PortableRest.sln +++ b/src/PortableRest.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 -VisualStudioVersion = 12.0.30501.0 +VisualStudioVersion = 12.0.30723.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PortableRest", "PortableRest\PortableRest.csproj", "{A3546D1A-CE87-49BB-800A-98018C1FCA00}" EndProject @@ -16,7 +16,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{155D3255-6321-4241-8357-162D6A883535}" ProjectSection(SolutionItems) = preProject + .nuget\NuGet.Config = .nuget\NuGet.Config .nuget\NuGet.exe = .nuget\NuGet.exe + .nuget\NuGet.targets = .nuget\NuGet.targets EndProjectSection EndProject Global diff --git a/src/PortableRest/ContentTypes.cs b/src/PortableRest/ContentTypes.cs index d122763..cd7b04f 100644 --- a/src/PortableRest/ContentTypes.cs +++ b/src/PortableRest/ContentTypes.cs @@ -30,5 +30,9 @@ public enum ContentTypes /// /// Xml, + /// + /// + /// + MultipartFormData } } diff --git a/src/PortableRest/FileParameter.cs b/src/PortableRest/FileParameter.cs new file mode 100644 index 0000000..4a5fb5a --- /dev/null +++ b/src/PortableRest/FileParameter.cs @@ -0,0 +1,34 @@ +namespace PortableRest +{ + /// + /// + /// + public class FileParameter + { + /// + /// + /// + public string FileName { get; set; } + /// + /// + /// + public byte[] Data { get; set; } + /// + /// + /// + public string Name { get; set; } + + /// + /// + /// + /// + /// + /// + public FileParameter(string name, byte[] bytes, string fileName) + { + FileName = fileName; + Data = bytes; + Name = name; + } + } +} diff --git a/src/PortableRest/PortableRest.csproj b/src/PortableRest/PortableRest.csproj index 7db4f66..dec34af 100644 --- a/src/PortableRest/PortableRest.csproj +++ b/src/PortableRest/PortableRest.csproj @@ -82,6 +82,7 @@ + @@ -93,11 +94,9 @@ ..\packages\Microsoft.Bcl.Async.1.0.168\lib\portable-net40+sl4+win8+wp71+wpa81\Microsoft.Threading.Tasks.dll - True ..\packages\Microsoft.Bcl.Async.1.0.168\lib\portable-net40+sl4+win8+wp71+wpa81\Microsoft.Threading.Tasks.Extensions.dll - True ..\packages\Newtonsoft.Json.6.0.4\lib\portable-net40+sl5+wp80+win8+wpa81\Newtonsoft.Json.dll @@ -106,13 +105,13 @@ ..\packages\Microsoft.Bcl.1.1.9\lib\portable-net40+sl5+win8+wp8+wpa81\System.IO.dll - ..\packages\Microsoft.Net.Http.2.2.27-beta\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.dll + ..\packages\Microsoft.Net.Http.2.2.28\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.dll - ..\packages\Microsoft.Net.Http.2.2.27-beta\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.Extensions.dll + ..\packages\Microsoft.Net.Http.2.2.28\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.Extensions.dll - ..\packages\Microsoft.Net.Http.2.2.27-beta\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.Primitives.dll + ..\packages\Microsoft.Net.Http.2.2.28\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.Primitives.dll ..\packages\Microsoft.Bcl.1.1.9\lib\portable-net40+sl5+win8+wp8+wpa81\System.Runtime.dll @@ -122,10 +121,17 @@ - + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + - - + +