Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you change the compatibility?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok! The breaking change makes sense now with the IsAssignableTo on GetType.

<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
Expand Down
4 changes: 2 additions & 2 deletions src/TheNoobs.ValueObjects.Abstractions/ValueObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public virtual bool Equals(ValueObject? other)
}

return ReferenceEquals(this, other) ||
other.GetType() == GetType() &&
GetAtomicValues().SequenceEqual(other.GetAtomicValues());
(GetType().IsInstanceOfType(other) || GetType().IsAssignableTo(other.GetType())) &&
GetAtomicValues().SequenceEqual(other.GetAtomicValues());
}

/// <inheritdoc cref="object"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ο»Ώusing System.Diagnostics.CodeAnalysis;

namespace TheNoobs.ValueObjects.Abstractions.UnitTests.Stubs;

[ExcludeFromCodeCoverage]
public class AgeStubProxy : AgeStub
{
public AgeStubProxy(int age)
: base(age)
{
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net6.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;net6.0;net7.0;net8.0</TargetFrameworks>

<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<IsPackable>false</IsPackable>
Expand All @@ -15,20 +15,20 @@
<RootNamespace>TheNoobs.ValueObjects.Abstractions.UnitTests</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AutoFixture.Xunit2" Version="4.17.0" />
<PackageReference Include="coverlet.msbuild" Version="3.1.2">
<PackageReference Include="AutoFixture.Xunit2" Version="4.18.1" />
<PackageReference Include="coverlet.msbuild" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="FluentAssertions" Version="6.7.0" />
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="JetBrains.DotMemoryUnit" Version="3.2.20220510" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="xunit" Version="2.8.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<PackageReference Include="coverlet.collector" Version="6.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,14 @@ public void Given_TwoNullValueObject_WhenCompares_Then_TheResultShouldBeTrue()
ZipCodeStub? zipCode2 = null;
(zipCode1! == zipCode2!).Should().BeTrue();
}

[Fact]
public void Given_AValueObject_WhenComparesToAProxiedItself_Then_TheResultShouldBeTrue()
{
AgeStub age1 = new AgeStub(1);
AgeStubProxy age2 = new AgeStubProxy(1);

(age1 == age2).Should().BeTrue();
(age2 == age1).Should().BeTrue();
}
}