-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* convert Audis.Primitives to records * make typeconverter only available for strings, add unit tests * Update azure-pipelines.yml for Azure Pipelines Use .NET 5 * Update azure-pipelines.yml for Azure Pipelines Use .NET 5 * add test-task for Audis.Primitives to pipelines * publish test results as TRX * use TRX logger for dotnet test
- Loading branch information
1 parent
4ff4dd2
commit d4e6f39
Showing
13 changed files
with
361 additions
and
316 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
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
43 changes: 43 additions & 0 deletions
43
src/Audis.Primitives/Audis.Primitives.Tests/PrimitiveTypeConverterTests.cs
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 @@ | ||
using System; | ||
using Newtonsoft.Json; | ||
using NUnit.Framework; | ||
|
||
namespace Audis.Primitives.Tests | ||
{ | ||
[TestFixture] | ||
public class PrimitiveTypeConverterTests | ||
{ | ||
[Test] | ||
public void StringSerialization() | ||
{ | ||
var knowledgeValue = new KnowledgeValue("asdf"); | ||
var dto = new StringDto { Primitive = knowledgeValue }; | ||
|
||
var json = JsonConvert.SerializeObject(dto); | ||
var newDto = JsonConvert.DeserializeObject<StringDto>(json); | ||
|
||
Assert.That(json, Is.EqualTo("{\"Primitive\":\"asdf\"}")); | ||
Assert.That(newDto.Primitive, Is.EqualTo(dto.Primitive)); | ||
Assert.That(newDto.Primitive!.Value, Is.EqualTo(knowledgeValue.Value)); | ||
} | ||
|
||
[Test] | ||
public void KnowledgeValueWithDateTimeCanBeSerializedAndDeserialized() | ||
{ | ||
var date = new DateTime(2020, 11, 11, 11, 11, 11); | ||
var knowledgeValue = new KnowledgeValue(date.ToString("o")); | ||
var json = JsonConvert.SerializeObject(knowledgeValue); | ||
|
||
var deserializedKnowledegeValue = JsonConvert.DeserializeObject<KnowledgeValue>(json); | ||
|
||
Assert.That(json, Is.EqualTo("\"2020-11-11T11:11:11.0000000\"")); | ||
Assert.That(deserializedKnowledegeValue, Is.EqualTo(knowledgeValue)); | ||
Assert.That(deserializedKnowledegeValue.Value, Is.EqualTo(date.ToString("o"))); | ||
} | ||
|
||
public class StringDto | ||
{ | ||
public KnowledgeValue? Primitive { get; set; } | ||
} | ||
} | ||
} |
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.