Skip to content

Commit

Permalink
Update MONO solution to SWAN
Browse files Browse the repository at this point in the history
  • Loading branch information
geoperez committed Jan 4, 2017
1 parent dcfd10e commit 2160a86
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 24 deletions.
10 changes: 7 additions & 3 deletions src/Unosquare.Labs.EmbedIO/Unosquare.Labs.EmbedIO.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,15 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<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>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.ServiceProcess" />
<Reference Include="Unosquare.Swan, Version=0.9.13.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Unosquare.Swan.0.9.13\lib\net452\Unosquare.Swan.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="Constants.cs" />
Expand Down
2 changes: 1 addition & 1 deletion src/Unosquare.Labs.EmbedIO/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" />
<package id="Unosquare.Swan" version="0.9.13" targetFramework="net452" />
</packages>
4 changes: 2 additions & 2 deletions test/Unosquare.Labs.EmbedIO.Tests/RegexRoutingTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Unosquare.Labs.EmbedIO.Tests
{
using Newtonsoft.Json;
using Swan.Formatters;
using NUnit.Framework;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -57,7 +57,7 @@ public async Task GetJsonDataWithOptRegexId()
Assert.IsNotNull(jsonBody, "Json Body is not null");
Assert.IsNotEmpty(jsonBody, "Json Body is not empty");

var remoteList = JsonConvert.DeserializeObject<List<Person>>(jsonBody);
var remoteList = Json.Deserialize<List<Person>>(jsonBody);

Assert.IsNotNull(remoteList, "Json Object is not null");
Assert.AreEqual(remoteList.Count, PeopleRepository.Database.Count, "Remote list count equals local list");
Expand Down
4 changes: 2 additions & 2 deletions test/Unosquare.Labs.EmbedIO.Tests/TestObjects/TestHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
using System.Net.Http;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Swan.Formatters;
using NUnit.Framework;
using System;
using System.IO;
Expand Down Expand Up @@ -134,7 +134,7 @@ public static async Task ValidatePerson(string url, Person person = null)
Assert.IsNotNull(jsonBody, "Json Body is not null");
Assert.IsNotEmpty(jsonBody, "Json Body is not empty");

var item = JsonConvert.DeserializeObject<Person>(jsonBody);
var item = Json.Deserialize<Person>(jsonBody);

Assert.IsNotNull(item, "Json Object is not null");
Assert.AreEqual(item.Name, person.Name, "Remote objects equality");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Unosquare.Labs.EmbedIO.Tests.TestObjects
{
using Newtonsoft.Json;
using Swan.Formatters;
using NUnit.Framework;
using System.Threading.Tasks;

Expand All @@ -14,7 +14,7 @@ public override async Task Invoke(MiddlewareContext context)

await Task.Delay(10);

context.HttpContext.JsonResponse(JsonConvert.SerializeObject(new {Status = "OK"}));
context.HttpContext.JsonResponse(Json.Serialize(new {Status = "OK"}));

context.Handled = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,25 @@
<WarningLevel>4</WarningLevel>
</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="nunit.framework, Version=3.5.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\..\packages\NUnit.3.5.0\lib\net45\nunit.framework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="Unosquare.Swan, Version=0.9.13.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Unosquare.Swan.0.9.13\lib\net452\Unosquare.Swan.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="CorsModuleTest.cs" />
Expand All @@ -59,7 +62,6 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TestObjects\PeopleRepository.cs" />
<Compile Include="TestObjects\Resources.cs" />
<Compile Include="TestObjects\TestConsoleLog.cs" />
<Compile Include="TestObjects\TestController.cs" />
<Compile Include="TestObjects\TestHelper.cs" />
<Compile Include="TestObjects\TestMiddleware.cs" />
Expand All @@ -72,7 +74,9 @@
<Compile Include="WebSocketsModuleTest.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Unosquare.Labs.EmbedIO\Unosquare.Labs.EmbedIO.csproj">
Expand Down
12 changes: 6 additions & 6 deletions test/Unosquare.Labs.EmbedIO.Tests/WebApiModuleTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Unosquare.Labs.EmbedIO.Tests
{
using Newtonsoft.Json;
using Swan.Formatters;
using NUnit.Framework;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -53,7 +53,7 @@ public async Task GetJsonData()
Assert.IsNotNull(jsonBody, "Json Body is not null");
Assert.IsNotEmpty(jsonBody, "Json Body is empty");

remoteList = JsonConvert.DeserializeObject<List<Person>>(jsonBody);
remoteList = Json.Deserialize<List<Person>>(jsonBody);

Assert.IsNotNull(remoteList, "Json Object is not null");
Assert.AreEqual(remoteList.Count, PeopleRepository.Database.Count, "Remote list count equals local list");
Expand Down Expand Up @@ -85,7 +85,7 @@ public async Task PostJsonData()

using (var dataStream = await request.GetRequestStreamAsync())
{
var byteArray = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(model));
var byteArray = Encoding.UTF8.GetBytes(Json.Serialize(model));
dataStream.Write(byteArray, 0, byteArray.Length);
}

Expand All @@ -97,7 +97,7 @@ public async Task PostJsonData()
Assert.IsNotNull(jsonString);
Assert.IsNotEmpty(jsonString);

var json = JsonConvert.DeserializeObject<Person>(jsonString);
var json = Json.Deserialize<Person>(jsonString);
Assert.IsNotNull(json);
Assert.AreEqual(json.Name, model.Name);
}
Expand Down Expand Up @@ -138,7 +138,7 @@ public async Task TestDictionaryFormData()
var result = await webClient.PostAsync(WebServerUrl + TestController.EchoPath, formContent);
Assert.IsNotNull(result);
var data = await result.Content.ReadAsStringAsync();
var obj = JsonConvert.DeserializeObject<Dictionary<string, string>>(data);
var obj = Json.Deserialize<Dictionary<string, string>>(data);
Assert.AreEqual(2, obj.Keys.Count);

Assert.AreEqual(content.First().Key, obj.First().Key);
Expand Down Expand Up @@ -169,7 +169,7 @@ public async Task TestMultipleIndexedValuesFormData(string label1, string label2
var result = await webClient.PostAsync(WebServerUrl + TestController.EchoPath, formContent);
Assert.IsNotNull(result);
var data = await result.Content.ReadAsStringAsync();
var obj = JsonConvert.DeserializeObject<FormDataSample>(data);
var obj = Json.Deserialize<FormDataSample>(data);
Assert.IsNotNull(obj);
Assert.AreEqual(content.First().Value, obj.test);
Assert.AreEqual(2, obj.id.Count);
Expand Down
4 changes: 2 additions & 2 deletions test/Unosquare.Labs.EmbedIO.Tests/WebServerCultureTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Unosquare.Swan.Formatters;
using NUnit.Framework;
using Unosquare.Labs.EmbedIO.Tests.TestObjects;
using System.Globalization;
Expand Down Expand Up @@ -48,7 +48,7 @@ public async Task GetIndex()
Assert.IsNotNull(jsonBody, "Json Body is not null");
Assert.IsNotEmpty(jsonBody, "Json Body is not empty");

var remoteList = JsonConvert.DeserializeObject<List<Person>>(jsonBody);
var remoteList = Json.Deserialize<List<Person>>(jsonBody);

Assert.IsNotNull(remoteList, "Json Object is not null");
Assert.AreEqual(remoteList.Count, PeopleRepository.Database.Count, "Remote list count equals local list");
Expand Down
1 change: 1 addition & 0 deletions test/Unosquare.Labs.EmbedIO.Tests/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit" version="3.5.0" targetFramework="net452" />
<package id="Unosquare.Swan" version="0.9.13" targetFramework="net452" />
</packages>

0 comments on commit 2160a86

Please sign in to comment.