diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index a8cd79d..3643377 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -25,7 +25,7 @@
$(MSBuildThisFileDirectory)..\artifacts
- 1.5.0-alpha.14
+ 1.5.0-alpha.15
diff --git a/src/Primitively/EmbeddedResources/Numeric/Base.cs b/src/Primitively/EmbeddedResources/Numeric/Base.cs
index fe7e976..d704f9e 100644
--- a/src/Primitively/EmbeddedResources/Numeric/Base.cs
+++ b/src/Primitively/EmbeddedResources/Numeric/Base.cs
@@ -1,27 +1,27 @@
readonly partial record struct PRIMITIVE_TYPE : global::PRIMITIVE_INTERFACE, global::System.IEquatable, global::System.IComparablePRIMITIVE_IVALIDATABLEOBJECT
{
- private readonly global::PRIMITIVE_VALUE_TYPE _value;
+ private readonly global::PRIMITIVE_VALUE_TYPE _value = default;
public const string Example = "PRIMITIVE_EXAMPLE";
public const global::PRIMITIVE_VALUE_TYPE Minimum = PRIMITIVE_MINIMUM;
public const global::PRIMITIVE_VALUE_TYPE Maximum = PRIMITIVE_MAXIMUM;
+ public PRIMITIVE_TYPE()
+ {
+ HasValue = IsMatch(_value);
+ _value = default;
+ }
+
public PRIMITIVE_TYPE(global::PRIMITIVE_VALUE_TYPE value)
{
- if (value >= Minimum && value <= Maximum)
- {
- _value = value;
- HasValue = true;
- }
+ HasValue = IsMatch(value);
+ _value = HasValue ? value : default;
}
private PRIMITIVE_TYPE(string value)
{
- if (global::PRIMITIVE_VALUE_TYPE.TryParse(value, out var result) && result >= Minimum && result <= Maximum)
- {
- _value = result;
- HasValue = true;
- }
+ HasValue = global::PRIMITIVE_VALUE_TYPE.TryParse(value, out var result) && IsMatch(result);
+ _value = HasValue ? result : default;
}
object global::Primitively.IPrimitive.Value => _value;
@@ -29,7 +29,7 @@ private PRIMITIVE_TYPE(string value)
global::PRIMITIVE_VALUE_TYPE global::Primitively.IPrimitive.Value => _value;
[global::System.Text.Json.Serialization.JsonIgnore]
- public bool HasValue { get; }
+ public bool HasValue { get; } = false;
[global::System.Text.Json.Serialization.JsonIgnore]
public global::System.Type ValueType => typeof(global::PRIMITIVE_VALUE_TYPE);
@@ -49,3 +49,5 @@ private PRIMITIVE_TYPE(string value)
public static PRIMITIVE_TYPE Parse(string value) => new(value);
public static bool TryParse(string value, out PRIMITIVE_TYPE result) => (result = new(value)).HasValue;
+
+ private static bool IsMatch(global::PRIMITIVE_VALUE_TYPE value) => value >= Minimum && value <= Maximum;
diff --git a/test/Primitively.IntegrationTests/NumericTests/Byte/FluentValidationTests.cs b/test/Primitively.IntegrationTests/NumericTests/Byte/FluentValidationTests.cs
index 06ebce3..71b1b5f 100644
--- a/test/Primitively.IntegrationTests/NumericTests/Byte/FluentValidationTests.cs
+++ b/test/Primitively.IntegrationTests/NumericTests/Byte/FluentValidationTests.cs
@@ -25,8 +25,9 @@ public FluentValidationTests()
[InlineData("")]
[InlineData(" ")]
[InlineData(" ")]
- [InlineData("0")]
- [InlineData("00")]
+ [InlineData("-1")]
+ [InlineData("0", true, true)]
+ [InlineData("00", true, true)]
[InlineData("001", true, true)]
[InlineData(ByteId.Example, true, true)]
public void ConvertFromThisToThatWithExpectedResults(string? value, bool nonNullableIsValid = false, bool nullableIsValid = false)
diff --git a/test/Primitively.IntegrationTests/NumericTests/Byte/InstantiationTests.cs b/test/Primitively.IntegrationTests/NumericTests/Byte/InstantiationTests.cs
index 363bab7..345fe82 100644
--- a/test/Primitively.IntegrationTests/NumericTests/Byte/InstantiationTests.cs
+++ b/test/Primitively.IntegrationTests/NumericTests/Byte/InstantiationTests.cs
@@ -10,31 +10,15 @@ public class InstantiationTests
[InlineData("")]
[InlineData(" ")]
[InlineData(" ")]
- [InlineData("0")]
- [InlineData("00")]
+ [InlineData("-1")]
+ [InlineData("0", true)]
+ [InlineData("00", true)]
[InlineData("001", true)]
[InlineData(ByteId.Example, true)]
- public void ConvertFromThisToThatWithExpectedResults(string? from, bool hasValue = default)
+ public void ConvertFromThisToThatWithExpectedResults(string? from, bool hasValue = false)
{
- var expectedInteger = hasValue ? ByteId.Parse(from) : default;
- var expectedString = expectedInteger.ToString();
-
- var @this = (ByteId)from;
- string to = @this;
- var that = ByteId.Parse(to);
- var and = new ByteId(that);
- string back = and;
+ var @this = ByteId.Parse(from);
@this.HasValue.Should().Be(hasValue);
- @this.Should().Be(expectedInteger);
- @this.ToString().Should().Be(expectedString);
- to.Should().Be(expectedString);
- that.HasValue.Should().Be(hasValue);
- that.Should().Be(expectedInteger);
- that.ToString().Should().Be(expectedString);
- and.HasValue.Should().Be(hasValue);
- and.Should().Be(expectedInteger);
- and.ToString().Should().Be(expectedString);
- back.Should().Be(expectedString);
}
}
diff --git a/test/Primitively.IntegrationTests/NumericTests/Int/FluentValidationTests.cs b/test/Primitively.IntegrationTests/NumericTests/Int/FluentValidationTests.cs
index 8faed6d..7fb98df 100644
--- a/test/Primitively.IntegrationTests/NumericTests/Int/FluentValidationTests.cs
+++ b/test/Primitively.IntegrationTests/NumericTests/Int/FluentValidationTests.cs
@@ -25,8 +25,9 @@ public FluentValidationTests()
[InlineData("")]
[InlineData(" ")]
[InlineData(" ")]
- [InlineData("0")]
- [InlineData("00")]
+ [InlineData("-1", true, true)]
+ [InlineData("0", true, true)]
+ [InlineData("00", true, true)]
[InlineData("001", true, true)]
[InlineData(IntId.Example, true, true)]
public void ConvertFromThisToThatWithExpectedResults(string? value, bool nonNullableIsValid = false, bool nullableIsValid = false)
diff --git a/test/Primitively.IntegrationTests/NumericTests/Int/InstantiationTests.cs b/test/Primitively.IntegrationTests/NumericTests/Int/InstantiationTests.cs
index fb75020..e2ee97a 100644
--- a/test/Primitively.IntegrationTests/NumericTests/Int/InstantiationTests.cs
+++ b/test/Primitively.IntegrationTests/NumericTests/Int/InstantiationTests.cs
@@ -10,31 +10,15 @@ public class InstantiationTests
[InlineData("")]
[InlineData(" ")]
[InlineData(" ")]
- [InlineData("0")]
- [InlineData("00")]
+ [InlineData("-1", true)]
+ [InlineData("0", true)]
+ [InlineData("00", true)]
[InlineData("001", true)]
[InlineData(IntId.Example, true)]
- public void ConvertFromThisToThatWithExpectedResults(string? from, bool hasValue = default)
+ public void ConvertFromThisToThatWithExpectedResults(string? from, bool hasValue = false)
{
- var expectedInteger = hasValue ? IntId.Parse(from) : default;
- var expectedString = expectedInteger.ToString();
-
- var @this = (IntId)from;
- string to = @this;
- var that = IntId.Parse(to);
- var and = new IntId(that);
- string back = and;
+ var @this = IntId.Parse(from);
@this.HasValue.Should().Be(hasValue);
- @this.Should().Be(expectedInteger);
- @this.ToString().Should().Be(expectedString);
- to.Should().Be(expectedString);
- that.HasValue.Should().Be(hasValue);
- that.Should().Be(expectedInteger);
- that.ToString().Should().Be(expectedString);
- and.HasValue.Should().Be(hasValue);
- and.Should().Be(expectedInteger);
- and.ToString().Should().Be(expectedString);
- back.Should().Be(expectedString);
}
}
diff --git a/test/Primitively.IntegrationTests/NumericTests/Int/ValidateMethodTests.cs b/test/Primitively.IntegrationTests/NumericTests/Int/ValidateMethodTests.cs
index 7d81c60..31dbd60 100644
--- a/test/Primitively.IntegrationTests/NumericTests/Int/ValidateMethodTests.cs
+++ b/test/Primitively.IntegrationTests/NumericTests/Int/ValidateMethodTests.cs
@@ -11,8 +11,9 @@ public class ValidateMethodTests
[InlineData("")]
[InlineData(" ")]
[InlineData(" ")]
- [InlineData("0")]
- [InlineData("00")]
+ [InlineData("-1", true)]
+ [InlineData("0", true)]
+ [InlineData("00", true)]
[InlineData("001", true)]
[InlineData(ValidatableInteger.Example, true)]
public void ConvertFromThisToThatWithExpectedResults(string? value, bool isValid = false)
diff --git a/test/Primitively.IntegrationTests/NumericTests/Long/FluentValidationTests.cs b/test/Primitively.IntegrationTests/NumericTests/Long/FluentValidationTests.cs
index 2b2de75..576570c 100644
--- a/test/Primitively.IntegrationTests/NumericTests/Long/FluentValidationTests.cs
+++ b/test/Primitively.IntegrationTests/NumericTests/Long/FluentValidationTests.cs
@@ -25,8 +25,9 @@ public FluentValidationTests()
[InlineData("")]
[InlineData(" ")]
[InlineData(" ")]
- [InlineData("0")]
- [InlineData("00")]
+ [InlineData("-1", true, true)]
+ [InlineData("0", true, true)]
+ [InlineData("00", true, true)]
[InlineData("001", true, true)]
[InlineData(LongId.Example, true, true)]
public void ConvertFromThisToThatWithExpectedResults(string? value, bool nonNullableIsValid = false, bool nullableIsValid = false)
diff --git a/test/Primitively.IntegrationTests/NumericTests/Long/InstantiationTests.cs b/test/Primitively.IntegrationTests/NumericTests/Long/InstantiationTests.cs
index ceb3189..38f3e27 100644
--- a/test/Primitively.IntegrationTests/NumericTests/Long/InstantiationTests.cs
+++ b/test/Primitively.IntegrationTests/NumericTests/Long/InstantiationTests.cs
@@ -10,31 +10,15 @@ public class InstantiationTests
[InlineData("")]
[InlineData(" ")]
[InlineData(" ")]
- [InlineData("0")]
- [InlineData("00")]
+ [InlineData("-1", true)]
+ [InlineData("0", true)]
+ [InlineData("00", true)]
[InlineData("001", true)]
[InlineData(LongId.Example, true)]
- public void ConvertFromThisToThatWithExpectedResults(string? from, bool hasValue = default)
+ public void ConvertFromThisToThatWithExpectedResults(string? from, bool hasValue = false)
{
- var expectedInteger = hasValue ? LongId.Parse(from) : default;
- var expectedString = expectedInteger.ToString();
-
- var @this = (LongId)from;
- string to = @this;
- var that = LongId.Parse(to);
- var and = new LongId(that);
- string back = and;
+ var @this = LongId.Parse(from);
@this.HasValue.Should().Be(hasValue);
- @this.Should().Be(expectedInteger);
- @this.ToString().Should().Be(expectedString);
- to.Should().Be(expectedString);
- that.HasValue.Should().Be(hasValue);
- that.Should().Be(expectedInteger);
- that.ToString().Should().Be(expectedString);
- and.HasValue.Should().Be(hasValue);
- and.Should().Be(expectedInteger);
- and.ToString().Should().Be(expectedString);
- back.Should().Be(expectedString);
}
}
diff --git a/test/Primitively.IntegrationTests/NumericTests/SByte/FluentValidationTests.cs b/test/Primitively.IntegrationTests/NumericTests/SByte/FluentValidationTests.cs
index 687e61e..0e7b170 100644
--- a/test/Primitively.IntegrationTests/NumericTests/SByte/FluentValidationTests.cs
+++ b/test/Primitively.IntegrationTests/NumericTests/SByte/FluentValidationTests.cs
@@ -25,8 +25,9 @@ public FluentValidationTests()
[InlineData("")]
[InlineData(" ")]
[InlineData(" ")]
- [InlineData("0")]
- [InlineData("00")]
+ [InlineData("-1", true, true)]
+ [InlineData("0", true, true)]
+ [InlineData("00", true, true)]
[InlineData("001", true, true)]
[InlineData(SByteId.Example, true, true)]
public void ConvertFromThisToThatWithExpectedResults(string? value, bool nonNullableIsValid = false, bool nullableIsValid = false)
diff --git a/test/Primitively.IntegrationTests/NumericTests/SByte/InstantiationTests.cs b/test/Primitively.IntegrationTests/NumericTests/SByte/InstantiationTests.cs
index 0890dae..2e6ebf5 100644
--- a/test/Primitively.IntegrationTests/NumericTests/SByte/InstantiationTests.cs
+++ b/test/Primitively.IntegrationTests/NumericTests/SByte/InstantiationTests.cs
@@ -10,31 +10,15 @@ public class InstantiationTests
[InlineData("")]
[InlineData(" ")]
[InlineData(" ")]
- [InlineData("0")]
- [InlineData("00")]
+ [InlineData("-1", true)]
+ [InlineData("0", true)]
+ [InlineData("00", true)]
[InlineData("001", true)]
[InlineData(SByteId.Example, true)]
- public void ConvertFromThisToThatWithExpectedResults(string? from, bool hasValue = default)
+ public void ConvertFromThisToThatWithExpectedResults(string? from, bool hasValue = false)
{
- var expectedInteger = hasValue ? SByteId.Parse(from) : default;
- var expectedString = expectedInteger.ToString();
-
- var @this = (SByteId)from;
- string to = @this;
- var that = SByteId.Parse(to);
- var and = new SByteId(that);
- string back = and;
+ var @this = SByteId.Parse(from);
@this.HasValue.Should().Be(hasValue);
- @this.Should().Be(expectedInteger);
- @this.ToString().Should().Be(expectedString);
- to.Should().Be(expectedString);
- that.HasValue.Should().Be(hasValue);
- that.Should().Be(expectedInteger);
- that.ToString().Should().Be(expectedString);
- and.HasValue.Should().Be(hasValue);
- and.Should().Be(expectedInteger);
- and.ToString().Should().Be(expectedString);
- back.Should().Be(expectedString);
}
}
diff --git a/test/Primitively.IntegrationTests/NumericTests/Short/FluentValidationTests.cs b/test/Primitively.IntegrationTests/NumericTests/Short/FluentValidationTests.cs
index 0d6acb9..286089d 100644
--- a/test/Primitively.IntegrationTests/NumericTests/Short/FluentValidationTests.cs
+++ b/test/Primitively.IntegrationTests/NumericTests/Short/FluentValidationTests.cs
@@ -25,8 +25,9 @@ public FluentValidationTests()
[InlineData("")]
[InlineData(" ")]
[InlineData(" ")]
- [InlineData("0")]
- [InlineData("00")]
+ [InlineData("-1", true, true)]
+ [InlineData("0", true, true)]
+ [InlineData("00", true, true)]
[InlineData("001", true, true)]
[InlineData(ShortId.Example, true, true)]
public void ConvertFromThisToThatWithExpectedResults(string? value, bool nonNullableIsValid = false, bool nullableIsValid = false)
diff --git a/test/Primitively.IntegrationTests/NumericTests/Short/InstantiationTests.cs b/test/Primitively.IntegrationTests/NumericTests/Short/InstantiationTests.cs
index 88c67ae..69d2f84 100644
--- a/test/Primitively.IntegrationTests/NumericTests/Short/InstantiationTests.cs
+++ b/test/Primitively.IntegrationTests/NumericTests/Short/InstantiationTests.cs
@@ -10,31 +10,15 @@ public class InstantiationTests
[InlineData("")]
[InlineData(" ")]
[InlineData(" ")]
- [InlineData("0")]
- [InlineData("00")]
+ [InlineData("-1", true)]
+ [InlineData("0", true)]
+ [InlineData("00", true)]
[InlineData("001", true)]
[InlineData(ShortId.Example, true)]
- public void ConvertFromThisToThatWithExpectedResults(string? from, bool hasValue = default)
+ public void ConvertFromThisToThatWithExpectedResults(string? from, bool hasValue = false)
{
- var expectedInteger = hasValue ? ShortId.Parse(from) : default;
- var expectedString = expectedInteger.ToString();
-
- var @this = (ShortId)from;
- string to = @this;
- var that = ShortId.Parse(to);
- var and = new ShortId(that);
- string back = and;
+ var @this = ShortId.Parse(from);
@this.HasValue.Should().Be(hasValue);
- @this.Should().Be(expectedInteger);
- @this.ToString().Should().Be(expectedString);
- to.Should().Be(expectedString);
- that.HasValue.Should().Be(hasValue);
- that.Should().Be(expectedInteger);
- that.ToString().Should().Be(expectedString);
- and.HasValue.Should().Be(hasValue);
- and.Should().Be(expectedInteger);
- and.ToString().Should().Be(expectedString);
- back.Should().Be(expectedString);
}
}
diff --git a/test/Primitively.IntegrationTests/NumericTests/UInt/FluentValidationTests.cs b/test/Primitively.IntegrationTests/NumericTests/UInt/FluentValidationTests.cs
index 1721585..61b7eea 100644
--- a/test/Primitively.IntegrationTests/NumericTests/UInt/FluentValidationTests.cs
+++ b/test/Primitively.IntegrationTests/NumericTests/UInt/FluentValidationTests.cs
@@ -25,8 +25,9 @@ public FluentValidationTests()
[InlineData("")]
[InlineData(" ")]
[InlineData(" ")]
- [InlineData("0")]
- [InlineData("00")]
+ [InlineData("-1")]
+ [InlineData("0", true, true)]
+ [InlineData("00", true, true)]
[InlineData("001", true, true)]
[InlineData(UIntId.Example, true, true)]
public void ConvertFromThisToThatWithExpectedResults(string? value, bool nonNullableIsValid = false, bool nullableIsValid = false)
diff --git a/test/Primitively.IntegrationTests/NumericTests/UInt/InstantiationTests.cs b/test/Primitively.IntegrationTests/NumericTests/UInt/InstantiationTests.cs
index 38a6433..caf2866 100644
--- a/test/Primitively.IntegrationTests/NumericTests/UInt/InstantiationTests.cs
+++ b/test/Primitively.IntegrationTests/NumericTests/UInt/InstantiationTests.cs
@@ -10,31 +10,15 @@ public class InstantiationTests
[InlineData("")]
[InlineData(" ")]
[InlineData(" ")]
- [InlineData("0")]
- [InlineData("00")]
+ [InlineData("-1")]
+ [InlineData("0", true)]
+ [InlineData("00", true)]
[InlineData("001", true)]
[InlineData(UIntId.Example, true)]
- public void ConvertFromThisToThatWithExpectedResults(string? from, bool hasValue = default)
+ public void ConvertFromThisToThatWithExpectedResults(string? from, bool hasValue = false)
{
- var expectedInteger = hasValue ? UIntId.Parse(from) : default;
- var expectedString = expectedInteger.ToString();
-
- var @this = (UIntId)from;
- string to = @this;
- var that = UIntId.Parse(to);
- var and = new UIntId(that);
- string back = and;
+ var @this = UIntId.Parse(from);
@this.HasValue.Should().Be(hasValue);
- @this.Should().Be(expectedInteger);
- @this.ToString().Should().Be(expectedString);
- to.Should().Be(expectedString);
- that.HasValue.Should().Be(hasValue);
- that.Should().Be(expectedInteger);
- that.ToString().Should().Be(expectedString);
- and.HasValue.Should().Be(hasValue);
- and.Should().Be(expectedInteger);
- and.ToString().Should().Be(expectedString);
- back.Should().Be(expectedString);
}
}
diff --git a/test/Primitively.IntegrationTests/NumericTests/ULong/FluentValidationTests.cs b/test/Primitively.IntegrationTests/NumericTests/ULong/FluentValidationTests.cs
index c94293f..4f67d53 100644
--- a/test/Primitively.IntegrationTests/NumericTests/ULong/FluentValidationTests.cs
+++ b/test/Primitively.IntegrationTests/NumericTests/ULong/FluentValidationTests.cs
@@ -25,8 +25,9 @@ public FluentValidationTests()
[InlineData("")]
[InlineData(" ")]
[InlineData(" ")]
- [InlineData("0")]
- [InlineData("00")]
+ [InlineData("-1")]
+ [InlineData("0", true, true)]
+ [InlineData("00", true, true)]
[InlineData("001", true, true)]
[InlineData(ULongId.Example, true, true)]
public void ConvertFromThisToThatWithExpectedResults(string? value, bool nonNullableIsValid = false, bool nullableIsValid = false)
diff --git a/test/Primitively.IntegrationTests/NumericTests/ULong/InstantiationTests.cs b/test/Primitively.IntegrationTests/NumericTests/ULong/InstantiationTests.cs
index b8c02bd..3a829c7 100644
--- a/test/Primitively.IntegrationTests/NumericTests/ULong/InstantiationTests.cs
+++ b/test/Primitively.IntegrationTests/NumericTests/ULong/InstantiationTests.cs
@@ -10,31 +10,15 @@ public class InstantiationTests
[InlineData("")]
[InlineData(" ")]
[InlineData(" ")]
- [InlineData("0")]
- [InlineData("00")]
+ [InlineData("-1")]
+ [InlineData("0", true)]
+ [InlineData("00", true)]
[InlineData("001", true)]
[InlineData(ULongId.Example, true)]
- public void ConvertFromThisToThatWithExpectedResults(string? from, bool hasValue = default)
+ public void ConvertFromThisToThatWithExpectedResults(string? from, bool hasValue = false)
{
- var expectedInteger = hasValue ? ULongId.Parse(from) : default;
- var expectedString = expectedInteger.ToString();
-
- var @this = (ULongId)from;
- string to = @this;
- var that = ULongId.Parse(to);
- var and = new ULongId(that);
- string back = and;
+ var @this = ULongId.Parse(from);
@this.HasValue.Should().Be(hasValue);
- @this.Should().Be(expectedInteger);
- @this.ToString().Should().Be(expectedString);
- to.Should().Be(expectedString);
- that.HasValue.Should().Be(hasValue);
- that.Should().Be(expectedInteger);
- that.ToString().Should().Be(expectedString);
- and.HasValue.Should().Be(hasValue);
- and.Should().Be(expectedInteger);
- and.ToString().Should().Be(expectedString);
- back.Should().Be(expectedString);
}
}
diff --git a/test/Primitively.IntegrationTests/NumericTests/UShort/FluentValidationTests.cs b/test/Primitively.IntegrationTests/NumericTests/UShort/FluentValidationTests.cs
index 8fb0c96..1c7c026 100644
--- a/test/Primitively.IntegrationTests/NumericTests/UShort/FluentValidationTests.cs
+++ b/test/Primitively.IntegrationTests/NumericTests/UShort/FluentValidationTests.cs
@@ -25,8 +25,9 @@ public FluentValidationTests()
[InlineData("")]
[InlineData(" ")]
[InlineData(" ")]
- [InlineData("0")]
- [InlineData("00")]
+ [InlineData("-1")]
+ [InlineData("0", true, true)]
+ [InlineData("00", true, true)]
[InlineData("001", true, true)]
[InlineData(UShortId.Example, true, true)]
public void ConvertFromThisToThatWithExpectedResults(string? value, bool nonNullableIsValid = false, bool nullableIsValid = false)
diff --git a/test/Primitively.IntegrationTests/NumericTests/UShort/InstantiationTests.cs b/test/Primitively.IntegrationTests/NumericTests/UShort/InstantiationTests.cs
index 407e96e..ec8a3de 100644
--- a/test/Primitively.IntegrationTests/NumericTests/UShort/InstantiationTests.cs
+++ b/test/Primitively.IntegrationTests/NumericTests/UShort/InstantiationTests.cs
@@ -10,31 +10,15 @@ public class InstantiationTests
[InlineData("")]
[InlineData(" ")]
[InlineData(" ")]
- [InlineData("0")]
- [InlineData("00")]
+ [InlineData("-1")]
+ [InlineData("0", true)]
+ [InlineData("00", true)]
[InlineData("001", true)]
[InlineData(UShortId.Example, true)]
- public void ConvertFromThisToThatWithExpectedResults(string? from, bool hasValue = default)
+ public void ConvertFromThisToThatWithExpectedResults(string? from, bool hasValue = false)
{
- var expectedInteger = hasValue ? UShortId.Parse(from) : default;
- var expectedString = expectedInteger.ToString();
-
- var @this = (UShortId)from;
- string to = @this;
- var that = UShortId.Parse(to);
- var and = new UShortId(that);
- string back = and;
+ var @this = UShortId.Parse(from);
@this.HasValue.Should().Be(hasValue);
- @this.Should().Be(expectedInteger);
- @this.ToString().Should().Be(expectedString);
- to.Should().Be(expectedString);
- that.HasValue.Should().Be(hasValue);
- that.Should().Be(expectedInteger);
- that.ToString().Should().Be(expectedString);
- and.HasValue.Should().Be(hasValue);
- and.Should().Be(expectedInteger);
- and.ToString().Should().Be(expectedString);
- back.Should().Be(expectedString);
}
}
diff --git a/test/Primitively.IntegrationTests/PrimitiveJsonConverterTests.cs b/test/Primitively.IntegrationTests/PrimitiveJsonConverterTests.cs
index 4a43bc8..1468b9d 100644
--- a/test/Primitively.IntegrationTests/PrimitiveJsonConverterTests.cs
+++ b/test/Primitively.IntegrationTests/PrimitiveJsonConverterTests.cs
@@ -48,7 +48,7 @@ public void JsonConverter_CanReadDefault()
var result = converter.Read(ref reader, typeof(TPrimitive), new JsonSerializerOptions());
result.Should().BeAssignableTo(typeof(TPrimitive));
- result.Should().BeEquivalentTo(default(TPrimitive));
+ result.Should().BeEquivalentTo(new TPrimitive());
}
[Fact]
@@ -67,7 +67,7 @@ public void JsonConverter_CanReadNull()
var result = converter.Read(ref reader, typeof(TPrimitive), new JsonSerializerOptions());
result.Should().BeAssignableTo(typeof(TPrimitive));
- result.Should().BeEquivalentTo(default(TPrimitive));
+ result.Should().BeEquivalentTo(new TPrimitive());
}
#if NET6_0_OR_GREATER