-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get rid of Json.NET in favor of System.Text.Json
- Loading branch information
Showing
28 changed files
with
355 additions
and
410 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// ---------------------------------------------------------------------- | ||
// <copyright file="DeserializationTests.cs"> | ||
// Copyright (c) The Loxone.NET Authors. All rights reserved. | ||
// </copyright> | ||
// <license> | ||
// Use of this source code is governed by the MIT license that can be | ||
// found in the LICENSE.txt file. | ||
// </license> | ||
// ---------------------------------------------------------------------- | ||
|
||
namespace Loxone.Client.Tests | ||
{ | ||
using System; | ||
using Loxone.Client.Transport; | ||
using Loxone.Client.Transport.Serialization.Responses; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
[TestClass] | ||
public class DeserializationTests | ||
{ | ||
[TestMethod] | ||
public void DeserializeResponseNumberCodeLowercase() | ||
{ | ||
string s = @"{""LL"":{""control"":""jdev/sys/getkey2/user"",""code"":200,""value"":{""key"":""0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"",""salt"":""0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF012345""}}}"; | ||
var r = LXResponse<GetKey2>.Deserialize(s); | ||
Assert.AreEqual(200, r.Code); | ||
Assert.AreEqual("jdev/sys/getkey2/user", r.Control); | ||
Assert.IsNotNull(r.Value); | ||
} | ||
|
||
[TestMethod] | ||
public void DeserializeResponseStringCodeUppercase() | ||
{ | ||
string s = @"{""LL"": { ""control"": ""dev/cfg/api"", ""value"": ""{'snr': 'AA:BB:CC:DD:EE:FF', 'version':'10.3.4.10'}"", ""Code"": ""200""}}"; | ||
var r = LXResponse<Api>.Deserialize(s); | ||
Assert.AreEqual(200, r.Code); | ||
Assert.AreEqual("dev/cfg/api", r.Control); | ||
Assert.IsNotNull(r.Value); | ||
Assert.AreEqual(SerialNumber.Parse("AA:BB:CC:DD:EE:FF"), r.Value.SerialNumber); | ||
Assert.AreEqual(new Version(10, 3, 4, 10), r.Value.Version); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" /> | ||
<PackageReference Include="MSTest.TestFramework" Version="2.0.0" /> | ||
<PackageReference Include="MSTest.TestAdapter" Version="2.0.0" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\Loxone.Client\Loxone.Client.csproj" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// ---------------------------------------------------------------------- | ||
// <copyright file="AsemblyInfo.cs"> | ||
// Copyright (c) The Loxone.NET Authors. All rights reserved. | ||
// </copyright> | ||
// <license> | ||
// Use of this source code is governed by the MIT license that can be | ||
// found in the LICENSE.txt file. | ||
// </license> | ||
// ---------------------------------------------------------------------- | ||
|
||
using System.Runtime.CompilerServices; | ||
|
||
[assembly: InternalsVisibleTo("Loxone.Client.Tests")] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.