diff --git a/src/Fluxera.ValueObject/PrimitiveValueObject.cs b/src/Fluxera.ValueObject/PrimitiveValueObject.cs
index a4b135d..cf5f95c 100644
--- a/src/Fluxera.ValueObject/PrimitiveValueObject.cs
+++ b/src/Fluxera.ValueObject/PrimitiveValueObject.cs
@@ -19,7 +19,9 @@
/// The type of the value.
[PublicAPI]
[TypeConverter(typeof(PrimitiveValueObjectConverter))]
- public abstract class PrimitiveValueObject : IComparable, IEquatable
+ public abstract class PrimitiveValueObject :
+ IComparable>,
+ IEquatable>
where TValueObject : PrimitiveValueObject
where TValue : IComparable, IEquatable
{
@@ -65,7 +67,7 @@ public static TValueObject Create(TValue value)
}
///
- public bool Equals(TValueObject other)
+ public bool Equals(PrimitiveValueObject other)
{
return this.Equals(other as object);
}
@@ -78,7 +80,7 @@ public sealed override bool Equals(object obj)
return false;
}
- if(object.ReferenceEquals(this, obj))
+ if(ReferenceEquals(this, obj))
{
return true;
}
@@ -90,7 +92,7 @@ public sealed override bool Equals(object obj)
}
///
- public int CompareTo(TValueObject other)
+ public int CompareTo(PrimitiveValueObject other)
{
return (this.Value, other.Value) switch
{
@@ -122,6 +124,50 @@ public int CompareTo(TValueObject other)
return !(left == right);
}
+ ///
+ /// Compares the given primitive value object instances with the lower-than operator.
+ ///
+ ///
+ ///
+ ///
+ public static bool operator <(PrimitiveValueObject left, PrimitiveValueObject right)
+ {
+ return left.CompareTo(right) < 0;
+ }
+
+ ///
+ /// Compares the given primitive value object instances with the lower-than-equal operator.
+ ///
+ ///
+ ///
+ ///
+ public static bool operator <=(PrimitiveValueObject left, PrimitiveValueObject right)
+ {
+ return left.CompareTo(right) <= 0;
+ }
+
+ ///
+ /// Compares the given primitive value object instances with the greater-than operator.
+ ///
+ ///
+ ///
+ ///
+ public static bool operator >(PrimitiveValueObject left, PrimitiveValueObject right)
+ {
+ return left.CompareTo(right) > 0;
+ }
+
+ ///
+ /// Compares the given primitive value object instances with the greater-than-equal operator.
+ ///
+ ///
+ ///
+ ///
+ public static bool operator >=(PrimitiveValueObject left, PrimitiveValueObject right)
+ {
+ return left.CompareTo(right) >= 0;
+ }
+
///
/// Converts the value object implicitly to its primitive value.
///
@@ -132,10 +178,10 @@ public static implicit operator TValue(PrimitiveValueObject
- /// Converts the primitive value explicitly to its value object.
+ /// Converts the primitive value implicitly to its value object.
///
///
- public static explicit operator PrimitiveValueObject(TValue value)
+ public static implicit operator PrimitiveValueObject(TValue value)
{
return Create(value);
}
diff --git a/tests/Fluxera.ValueObject.EntityFrameworkCore.UnitTests/Model/Age.cs b/tests/Fluxera.ValueObject.EntityFrameworkCore.UnitTests/Model/Age.cs
index 9d5bc4b..1149a2c 100644
--- a/tests/Fluxera.ValueObject.EntityFrameworkCore.UnitTests/Model/Age.cs
+++ b/tests/Fluxera.ValueObject.EntityFrameworkCore.UnitTests/Model/Age.cs
@@ -1,4 +1,4 @@
-namespace Fluxera.ValueObject.LiteDB.UnitTests.Model
+namespace Fluxera.ValueObject.EntityFrameworkCore.UnitTests.Model
{
public sealed class Age : PrimitiveValueObject
{
diff --git a/tests/Fluxera.ValueObject.EntityFrameworkCore.UnitTests/Model/Person.cs b/tests/Fluxera.ValueObject.EntityFrameworkCore.UnitTests/Model/Person.cs
index f8f98bd..04a42e2 100644
--- a/tests/Fluxera.ValueObject.EntityFrameworkCore.UnitTests/Model/Person.cs
+++ b/tests/Fluxera.ValueObject.EntityFrameworkCore.UnitTests/Model/Person.cs
@@ -1,7 +1,6 @@
namespace Fluxera.ValueObject.EntityFrameworkCore.UnitTests.Model
{
using System.ComponentModel.DataAnnotations;
- using Fluxera.ValueObject.LiteDB.UnitTests.Model;
public class Person
{
diff --git a/tests/Fluxera.ValueObject.EntityFrameworkCore.UnitTests/Model/PersonFactory.cs b/tests/Fluxera.ValueObject.EntityFrameworkCore.UnitTests/Model/PersonFactory.cs
index c9eda10..06d63e7 100644
--- a/tests/Fluxera.ValueObject.EntityFrameworkCore.UnitTests/Model/PersonFactory.cs
+++ b/tests/Fluxera.ValueObject.EntityFrameworkCore.UnitTests/Model/PersonFactory.cs
@@ -3,7 +3,6 @@
using System;
using System.Collections.Generic;
using Bogus;
- using Fluxera.ValueObject.LiteDB.UnitTests.Model;
public static class PersonFactory
{
diff --git a/tests/Fluxera.ValueObject.EntityFrameworkCore.UnitTests/QueryTests.cs b/tests/Fluxera.ValueObject.EntityFrameworkCore.UnitTests/QueryTests.cs
index 7f6f147..b78350e 100644
--- a/tests/Fluxera.ValueObject.EntityFrameworkCore.UnitTests/QueryTests.cs
+++ b/tests/Fluxera.ValueObject.EntityFrameworkCore.UnitTests/QueryTests.cs
@@ -4,7 +4,6 @@
using System.Threading.Tasks;
using FluentAssertions;
using Fluxera.ValueObject.EntityFrameworkCore.UnitTests.Model;
- using Fluxera.ValueObject.LiteDB.UnitTests.Model;
using Microsoft.EntityFrameworkCore;
using NUnit.Framework;
@@ -37,7 +36,7 @@ public async Task ShouldFindByPrimitiveValueObjectEquals()
linqFilterResult.Should().NotBeNull();
}
- [Ignore("Fix this later")]
+ [Ignore("Fix this later. Drop .NET 7 in November?")]
[Test]
public async Task ShouldFindByValueEquals()
{
@@ -48,7 +47,6 @@ public async Task ShouldFindByValueEquals()
linqFilterResult.Should().NotBeNull();
}
- [Ignore("Fix this later")]
[Test]
public async Task ShouldFindByPrimitiveValueObjectComparison()
{
@@ -59,7 +57,6 @@ public async Task ShouldFindByPrimitiveValueObjectComparison()
linqFilterResult.Should().NotBeNull();
}
- [Ignore("Fix this later")]
[Test]
public async Task ShouldFindByValueComparison()
{