Skip to content

Commit 2160a86

Browse files
committed
Update MONO solution to SWAN
1 parent dcfd10e commit 2160a86

File tree

9 files changed

+33
-24
lines changed

9 files changed

+33
-24
lines changed

src/Unosquare.Labs.EmbedIO/Unosquare.Labs.EmbedIO.csproj

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,15 @@
4444
</PropertyGroup>
4545
<ItemGroup>
4646
<Reference Include="Microsoft.CSharp" />
47-
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
48-
<HintPath>..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
47+
<Reference Include="System" />
48+
<Reference Include="System.ComponentModel.DataAnnotations" />
49+
<Reference Include="System.Drawing" />
50+
<Reference Include="System.Net.Http" />
51+
<Reference Include="System.ServiceProcess" />
52+
<Reference Include="Unosquare.Swan, Version=0.9.13.0, Culture=neutral, processorArchitecture=MSIL">
53+
<HintPath>..\..\packages\Unosquare.Swan.0.9.13\lib\net452\Unosquare.Swan.dll</HintPath>
4954
<Private>True</Private>
5055
</Reference>
51-
<Reference Include="System" />
5256
</ItemGroup>
5357
<ItemGroup>
5458
<Compile Include="Constants.cs" />
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="9.0.1" targetFramework="net452" />
3+
<package id="Unosquare.Swan" version="0.9.13" targetFramework="net452" />
44
</packages>

test/Unosquare.Labs.EmbedIO.Tests/RegexRoutingTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace Unosquare.Labs.EmbedIO.Tests
22
{
3-
using Newtonsoft.Json;
3+
using Swan.Formatters;
44
using NUnit.Framework;
55
using System;
66
using System.Collections.Generic;
@@ -57,7 +57,7 @@ public async Task GetJsonDataWithOptRegexId()
5757
Assert.IsNotNull(jsonBody, "Json Body is not null");
5858
Assert.IsNotEmpty(jsonBody, "Json Body is not empty");
5959

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

6262
Assert.IsNotNull(remoteList, "Json Object is not null");
6363
Assert.AreEqual(remoteList.Count, PeopleRepository.Database.Count, "Remote list count equals local list");

test/Unosquare.Labs.EmbedIO.Tests/TestObjects/TestHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{
33
using System.Net.Http;
44
using System.Threading.Tasks;
5-
using Newtonsoft.Json;
5+
using Swan.Formatters;
66
using NUnit.Framework;
77
using System;
88
using System.IO;
@@ -134,7 +134,7 @@ public static async Task ValidatePerson(string url, Person person = null)
134134
Assert.IsNotNull(jsonBody, "Json Body is not null");
135135
Assert.IsNotEmpty(jsonBody, "Json Body is not empty");
136136

137-
var item = JsonConvert.DeserializeObject<Person>(jsonBody);
137+
var item = Json.Deserialize<Person>(jsonBody);
138138

139139
Assert.IsNotNull(item, "Json Object is not null");
140140
Assert.AreEqual(item.Name, person.Name, "Remote objects equality");

test/Unosquare.Labs.EmbedIO.Tests/TestObjects/TestMiddleware.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace Unosquare.Labs.EmbedIO.Tests.TestObjects
22
{
3-
using Newtonsoft.Json;
3+
using Swan.Formatters;
44
using NUnit.Framework;
55
using System.Threading.Tasks;
66

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

1515
await Task.Delay(10);
1616

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

1919
context.Handled = true;
2020
}

test/Unosquare.Labs.EmbedIO.Tests/Unosquare.Labs.EmbedIO.Tests.csproj

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,25 @@
3131
<WarningLevel>4</WarningLevel>
3232
</PropertyGroup>
3333
<ItemGroup>
34-
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
35-
<HintPath>..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
36-
<Private>True</Private>
37-
</Reference>
3834
<Reference Include="nunit.framework, Version=3.5.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
3935
<HintPath>..\..\packages\NUnit.3.5.0\lib\net45\nunit.framework.dll</HintPath>
4036
<Private>True</Private>
4137
</Reference>
4238
<Reference Include="System" />
39+
<Reference Include="System.ComponentModel.DataAnnotations" />
4340
<Reference Include="System.Core" />
41+
<Reference Include="System.Drawing" />
4442
<Reference Include="System.Net.Http" />
43+
<Reference Include="System.ServiceProcess" />
4544
<Reference Include="System.Xml.Linq" />
4645
<Reference Include="System.Data.DataSetExtensions" />
4746
<Reference Include="Microsoft.CSharp" />
4847
<Reference Include="System.Data" />
4948
<Reference Include="System.Xml" />
49+
<Reference Include="Unosquare.Swan, Version=0.9.13.0, Culture=neutral, processorArchitecture=MSIL">
50+
<HintPath>..\..\packages\Unosquare.Swan.0.9.13\lib\net452\Unosquare.Swan.dll</HintPath>
51+
<Private>True</Private>
52+
</Reference>
5053
</ItemGroup>
5154
<ItemGroup>
5255
<Compile Include="CorsModuleTest.cs" />
@@ -59,7 +62,6 @@
5962
<Compile Include="Properties\AssemblyInfo.cs" />
6063
<Compile Include="TestObjects\PeopleRepository.cs" />
6164
<Compile Include="TestObjects\Resources.cs" />
62-
<Compile Include="TestObjects\TestConsoleLog.cs" />
6365
<Compile Include="TestObjects\TestController.cs" />
6466
<Compile Include="TestObjects\TestHelper.cs" />
6567
<Compile Include="TestObjects\TestMiddleware.cs" />
@@ -72,7 +74,9 @@
7274
<Compile Include="WebSocketsModuleTest.cs" />
7375
</ItemGroup>
7476
<ItemGroup>
75-
<None Include="packages.config" />
77+
<None Include="packages.config">
78+
<SubType>Designer</SubType>
79+
</None>
7680
</ItemGroup>
7781
<ItemGroup>
7882
<ProjectReference Include="..\..\src\Unosquare.Labs.EmbedIO\Unosquare.Labs.EmbedIO.csproj">

test/Unosquare.Labs.EmbedIO.Tests/WebApiModuleTest.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace Unosquare.Labs.EmbedIO.Tests
22
{
3-
using Newtonsoft.Json;
3+
using Swan.Formatters;
44
using NUnit.Framework;
55
using System;
66
using System.Collections.Generic;
@@ -53,7 +53,7 @@ public async Task GetJsonData()
5353
Assert.IsNotNull(jsonBody, "Json Body is not null");
5454
Assert.IsNotEmpty(jsonBody, "Json Body is empty");
5555

56-
remoteList = JsonConvert.DeserializeObject<List<Person>>(jsonBody);
56+
remoteList = Json.Deserialize<List<Person>>(jsonBody);
5757

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

8686
using (var dataStream = await request.GetRequestStreamAsync())
8787
{
88-
var byteArray = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(model));
88+
var byteArray = Encoding.UTF8.GetBytes(Json.Serialize(model));
8989
dataStream.Write(byteArray, 0, byteArray.Length);
9090
}
9191

@@ -97,7 +97,7 @@ public async Task PostJsonData()
9797
Assert.IsNotNull(jsonString);
9898
Assert.IsNotEmpty(jsonString);
9999

100-
var json = JsonConvert.DeserializeObject<Person>(jsonString);
100+
var json = Json.Deserialize<Person>(jsonString);
101101
Assert.IsNotNull(json);
102102
Assert.AreEqual(json.Name, model.Name);
103103
}
@@ -138,7 +138,7 @@ public async Task TestDictionaryFormData()
138138
var result = await webClient.PostAsync(WebServerUrl + TestController.EchoPath, formContent);
139139
Assert.IsNotNull(result);
140140
var data = await result.Content.ReadAsStringAsync();
141-
var obj = JsonConvert.DeserializeObject<Dictionary<string, string>>(data);
141+
var obj = Json.Deserialize<Dictionary<string, string>>(data);
142142
Assert.AreEqual(2, obj.Keys.Count);
143143

144144
Assert.AreEqual(content.First().Key, obj.First().Key);
@@ -169,7 +169,7 @@ public async Task TestMultipleIndexedValuesFormData(string label1, string label2
169169
var result = await webClient.PostAsync(WebServerUrl + TestController.EchoPath, formContent);
170170
Assert.IsNotNull(result);
171171
var data = await result.Content.ReadAsStringAsync();
172-
var obj = JsonConvert.DeserializeObject<FormDataSample>(data);
172+
var obj = Json.Deserialize<FormDataSample>(data);
173173
Assert.IsNotNull(obj);
174174
Assert.AreEqual(content.First().Value, obj.test);
175175
Assert.AreEqual(2, obj.id.Count);

test/Unosquare.Labs.EmbedIO.Tests/WebServerCultureTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using System.Net;
66
using System.Threading;
77
using System.Threading.Tasks;
8-
using Newtonsoft.Json;
8+
using Unosquare.Swan.Formatters;
99
using NUnit.Framework;
1010
using Unosquare.Labs.EmbedIO.Tests.TestObjects;
1111
using System.Globalization;
@@ -48,7 +48,7 @@ public async Task GetIndex()
4848
Assert.IsNotNull(jsonBody, "Json Body is not null");
4949
Assert.IsNotEmpty(jsonBody, "Json Body is not empty");
5050

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

5353
Assert.IsNotNull(remoteList, "Json Object is not null");
5454
Assert.AreEqual(remoteList.Count, PeopleRepository.Database.Count, "Remote list count equals local list");
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
33
<package id="NUnit" version="3.5.0" targetFramework="net452" />
4+
<package id="Unosquare.Swan" version="0.9.13" targetFramework="net452" />
45
</packages>

0 commit comments

Comments
 (0)