diff --git a/src/StructId.FunctionalTests/UlidTests.cs b/src/StructId.FunctionalTests/UlidTests.cs index 787189e..ba84c0c 100644 --- a/src/StructId.FunctionalTests/UlidTests.cs +++ b/src/StructId.FunctionalTests/UlidTests.cs @@ -43,13 +43,18 @@ public override void SetValue(IDbDataParameter parameter, Ulid value) // showcases a custom EF value converter trumps the built-in templatized // support for types that provide IParsable and IFormattable -//public partial class UlidToStringConverter : ValueConverter -//{ -// public UlidToStringConverter() : this(null) { } +public partial class UlidToStringConverter : ValueConverter +{ + public UlidToStringConverter() : this(null) { } -// public UlidToStringConverter(ConverterMappingHints? mappingHints = null) -// : base(id => id.ToString(), value => Ulid.Parse(value), mappingHints) { } -//} + public UlidToStringConverter(ConverterMappingHints? mappingHints = null) + : base(id => id.ToString(), value => Ulid.Parse(value), mappingHints) + { + Instantiated = true; + } + + public static bool Instantiated { get; private set; } +} // showcases alternative serialization //public class BinaryUlidHandler : TypeHandler @@ -147,6 +152,8 @@ public void EntityFramework() var product3 = context.Products.FirstOrDefault(x => guid == x.Id); Assert.Equal(product, product3); + + Assert.True(UlidToStringConverter.Instantiated, "Custom EF converter for Ulid was not used."); } public class UlidContext : DbContext