Skip to content
Merged
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
37 changes: 37 additions & 0 deletions tests/AggregateKit.Tests/ValueObjectNullTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System.Collections.Generic;
using Xunit;

namespace AggregateKit.Tests
{
public class ValueObjectNullTests
{
private class NullableVO : ValueObject
{
public string? Value { get; }

public NullableVO(string? value)
{
Value = value;
}

protected override IEnumerable<object?> GetEqualityComponents()
{
yield return Value;
}
}

[Fact]
public void ValueObjects_With_Null_Value_Are_Equal_And_GetHashCode_Does_Not_Throw()
{
// Arrange
var vo1 = new NullableVO(null);
var vo2 = new NullableVO(null);

// Act & Assert
Assert.Equal(vo1, vo2);
var hash1 = vo1.GetHashCode();
var hash2 = vo2.GetHashCode();
Assert.Equal(hash1, hash2);
}
}
}