Files
speckle-sharp-sdk/Speckle.Sdk.Testing/Framework/IdStringSerializer.cs
T
Adam Hathcock bafd130ece Snapshot testing (#208)
* 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
2025-01-16 13:46:53 +00:00

25 lines
705 B
C#

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;
}