-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* snapshot testing with verify * formatting * add back old serialization tests * pass verify * use json correctly * formatting * Don't use Quibble and order ourselves because ordering doesn't matter * whitespace on snapshot * Better json diffing? Quibble is back * add common project * add object unit tests to see how verify would work * format * move random exes to new solution folder * update lock files
- Loading branch information
1 parent
f79ae7e
commit bafd130
Showing
55 changed files
with
1,776 additions
and
451 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
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 |
---|---|---|
|
@@ -18,4 +18,6 @@ tools | |
|
||
.DS_Store | ||
*.snupkg | ||
coverage.xml | ||
coverage.xml | ||
|
||
*.received.* |
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
4 changes: 2 additions & 2 deletions
4
...zation.Tests/DummySqLiteReceiveManager.cs → ...ng/Framework/DummySqLiteReceiveManager.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
4 changes: 2 additions & 2 deletions
4
...alization.Tests/DummySqLiteSendManager.cs → ...sting/Framework/DummySqLiteSendManager.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
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,24 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
using Argon; | ||
using Speckle.Sdk.Common; | ||
using Speckle.Sdk.Serialisation; | ||
|
||
namespace Speckle.Sdk.Testing.Framework; | ||
|
||
[SuppressMessage("Design", "CA1062:Validate arguments of public methods")] | ||
public class IdStringSerializer : JsonConverter | ||
{ | ||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) | ||
{ | ||
var id = (Id)value; | ||
writer.WriteValue(id.Value); | ||
} | ||
|
||
public override object? ReadJson(JsonReader reader, Type type, object? existingValue, JsonSerializer serializer) | ||
{ | ||
var json = reader.ReadAsString(); | ||
return new Id(json.NotNull()); | ||
} | ||
|
||
public override bool CanConvert(Type type) => typeof(Id) == type; | ||
} |
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,24 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
using Argon; | ||
using Speckle.Sdk.Common; | ||
using Speckle.Sdk.Serialisation; | ||
|
||
namespace Speckle.Sdk.Testing.Framework; | ||
|
||
[SuppressMessage("Design", "CA1062:Validate arguments of public methods")] | ||
public class JsonStringSerializer : JsonConverter | ||
{ | ||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) | ||
{ | ||
var json = (Json)value; | ||
writer.WriteRawValue(JObject.Parse(json.Value).ToString(Formatting.Indented)); | ||
} | ||
|
||
public override object? ReadJson(JsonReader reader, Type type, object? existingValue, JsonSerializer serializer) | ||
{ | ||
var json = reader.ReadAsString(); | ||
return new Json(json.NotNull()); | ||
} | ||
|
||
public override bool CanConvert(Type type) => typeof(Json) == type; | ||
} |
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 @@ | ||
[assembly: CollectionBehavior(DisableTestParallelization = true)] |
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,19 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" /> | ||
<PackageReference Include="Verify.Quibble" /> | ||
<PackageReference Include="Verify.Xunit" /> | ||
<PackageReference Include="xunit.runner.visualstudio"/> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\src\Speckle.Sdk\Speckle.Sdk.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System.Runtime.CompilerServices; | ||
using Argon; | ||
using Speckle.Sdk.Serialisation; | ||
using Speckle.Sdk.Testing.Framework; | ||
|
||
namespace Speckle.Sdk.Testing; | ||
|
||
public static class SpeckleVerify | ||
{ | ||
[ModuleInitializer] | ||
public static void Initialize() | ||
{ | ||
VerifierSettings.DontScrubGuids(); | ||
VerifierSettings.DontScrubDateTimes(); | ||
|
||
VerifierSettings.UseStrictJson(); | ||
VerifierSettings.DontIgnoreEmptyCollections(); | ||
VerifierSettings.SortPropertiesAlphabetically(); | ||
VerifierSettings.SortJsonObjects(); | ||
if (!VerifyQuibble.Initialized) | ||
{ | ||
VerifyQuibble.Initialize(); | ||
} | ||
} | ||
|
||
private static readonly JsonSerializer _jsonSerializer = new() | ||
{ | ||
NullValueHandling = NullValueHandling.Include, | ||
Formatting = Formatting.Indented, | ||
Converters = { new JsonStringSerializer() }, | ||
}; | ||
|
||
private static async Task VerifyJsonObjects(IDictionary<string, Json> objects, string sourceFile) => | ||
await VerifyJson(JObject.FromObject(objects, _jsonSerializer).ToString(), sourceFile: sourceFile); | ||
|
||
public static async Task VerifyJsonDictionary( | ||
IDictionary<string, string> objects, | ||
[CallerFilePath] string sourceFile = "" | ||
) => await VerifyJsonObjects(objects.ToDictionary(x => x.Key, x => new Json(x.Value)), sourceFile); | ||
|
||
public static async Task VerifyJsonDictionary( | ||
IDictionary<Id, Json> objects, | ||
[CallerFilePath] string sourceFile = "" | ||
) => await VerifyJsonObjects(objects.ToDictionary(x => x.Key.Value, x => x.Value), sourceFile); | ||
} |
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,7 @@ | ||
namespace Speckle.Sdk.Testing; | ||
|
||
public class VerifyTests | ||
{ | ||
[Fact] | ||
public Task TestVerify() => VerifyChecks.Run(); | ||
} |
Oops, something went wrong.