Skip to content
Merged
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
@@ -0,0 +1,21 @@
namespace Monify.Console.Classes.Nested.InClass.OutterForImmutableArrayTests;

using System.Collections.Immutable;

public static class WhenConstructorIsCalled
{
private static readonly ImmutableArray<string> _sampleValue = ["Alpha", "Beta", "Gamma"];

[Fact]
public static void GivenValueThenValueIsStored()
{
// Arrange
OutterForImmutableArray<int>.Inner instance = new(_sampleValue);

// Act
ImmutableArray<string> actual = instance;

// Assert
actual.ShouldBe(_sampleValue);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
namespace Monify.Console.Classes.Nested.InClass.OutterForImmutableArrayTests;

using System.Collections.Immutable;

public static class WhenEqualityOperatorWithImmutableArrayIsCalled
{
private static readonly ImmutableArray<string> _differentValue = ["Delta", "Epsilon", "Zeta"];
private static readonly ImmutableArray<string> _sampleValue = ["Alpha", "Beta", "Gamma"];

[Fact]
public static void GivenSubjectIsNullThenReturnFalse()
{
// Arrange
OutterForImmutableArray<int>.Inner? subject = default;

// Act
bool actual = subject == _sampleValue;

// Assert
actual.ShouldBeFalse();
}

[Fact]
public static void GivenSameValueThenReturnTrue()
{
// Arrange
OutterForImmutableArray<int>.Inner subject = new(_sampleValue);

// Act
bool actual = subject == _sampleValue;

// Assert
actual.ShouldBeTrue();
}

[Fact]
public static void GivenDifferentValueThenReturnFalse()
{
// Arrange
OutterForImmutableArray<int>.Inner subject = new(_sampleValue);

// Act
bool actual = subject == _differentValue;

// Assert
actual.ShouldBeFalse();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
namespace Monify.Console.Classes.Nested.InClass.OutterForImmutableArrayTests;

using System.Collections.Immutable;

public static class WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled
{
private static readonly ImmutableArray<string> _differentValue = ["Delta", "Epsilon", "Zeta"];
private static readonly ImmutableArray<string> _sampleValue = ["Alpha", "Beta", "Gamma"];

[Fact]
public static void GivenBothNullThenReturnTrue()
{
// Arrange
OutterForImmutableArray<int>.Inner? left = default;
OutterForImmutableArray<int>.Inner? right = default;

// Act
bool actual = left == right;

// Assert
actual.ShouldBeTrue();
}

[Fact]
public static void GivenLeftIsNullThenReturnFalse()
{
// Arrange
OutterForImmutableArray<int>.Inner? left = default;
OutterForImmutableArray<int>.Inner right = new(_sampleValue);

// Act
bool actual = left == right;

// Assert
actual.ShouldBeFalse();
}

[Fact]
public static void GivenSameValueThenReturnTrue()
{
// Arrange
OutterForImmutableArray<int>.Inner left = new(_sampleValue);
OutterForImmutableArray<int>.Inner right = new(_sampleValue);

// Act
bool actual = left == right;

// Assert
actual.ShouldBeTrue();
}

[Fact]
public static void GivenEquivalentValuesThenReturnTrue()
{
// Arrange
ImmutableArray<string> leftValues = ["Alpha", "Beta", "Gamma"];
ImmutableArray<string> rightValues = ["Alpha", "Beta", "Gamma"];
OutterForImmutableArray<int>.Inner left = new(leftValues);
OutterForImmutableArray<int>.Inner right = new(rightValues);

// Act
bool actual = left == right;

// Assert
actual.ShouldBeTrue();
}

[Fact]
public static void GivenDifferentValuesThenReturnFalse()
{
// Arrange
OutterForImmutableArray<int>.Inner left = new(_sampleValue);
OutterForImmutableArray<int>.Inner right = new(_differentValue);

// Act
bool actual = left == right;

// Assert
actual.ShouldBeFalse();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
namespace Monify.Console.Classes.Nested.InClass.OutterForImmutableArrayTests;

using System.Collections.Immutable;

public static class WhenEqualsWithImmutableArrayIsCalled
{
private static readonly ImmutableArray<string> _differentValue = ["Delta", "Epsilon", "Zeta"];
private static readonly ImmutableArray<string> _sampleValue = ["Alpha", "Beta", "Gamma"];

[Fact]
public static void GivenSameValueThenReturnTrue()
{
// Arrange
OutterForImmutableArray<int>.Inner subject = new(_sampleValue);

// Act
bool actual = subject.Equals(_sampleValue);

// Assert
actual.ShouldBeTrue();
}

[Fact]
public static void GivenDifferentValueThenReturnFalse()
{
// Arrange
OutterForImmutableArray<int>.Inner subject = new(_sampleValue);

// Act
bool actual = subject.Equals(_differentValue);

// Assert
actual.ShouldBeFalse();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
namespace Monify.Console.Classes.Nested.InClass.OutterForImmutableArrayTests;

using System.Collections.Immutable;

public static class WhenEqualsWithObjectIsCalled
{
private static readonly ImmutableArray<string> _sampleValue = ["Alpha", "Beta", "Gamma"];

[Fact]
public static void GivenNullThenReturnFalse()
{
// Arrange
OutterForImmutableArray<int>.Inner subject = new(_sampleValue);

// Act
bool actual = subject.Equals((object?)default);

// Assert
actual.ShouldBeFalse();
}

[Fact]
public static void GivenEquivalentOutterForImmutableArrayInnerThenReturnTrue()
{
// Arrange
OutterForImmutableArray<int>.Inner subject = new(_sampleValue);
object other = new OutterForImmutableArray<int>.Inner(_sampleValue);

// Act
bool actual = subject.Equals(other);

// Assert
actual.ShouldBeTrue();
}

[Fact]
public static void GivenDifferentTypeThenThrowInvalidCastException()
{
// Arrange
OutterForImmutableArray<int>.Inner subject = new(_sampleValue);
object other = string.Empty;

// Act
Action act = () => subject.Equals(other);

// Assert
_ = Should.Throw<InvalidCastException>(act);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
namespace Monify.Console.Classes.Nested.InClass.OutterForImmutableArrayTests;

using System.Collections.Immutable;

public static class WhenEqualsWithOutterForImmutableArrayInnerIsCalled
{
private static readonly ImmutableArray<string> _differentValue = ["Delta", "Epsilon", "Zeta"];
private static readonly ImmutableArray<string> _sampleValue = ["Alpha", "Beta", "Gamma"];

[Fact]
public static void GivenSameValueThenReturnTrue()
{
// Arrange
OutterForImmutableArray<int>.Inner left = new(_sampleValue);
OutterForImmutableArray<int>.Inner right = new(_sampleValue);

// Act
bool actual = left.Equals(right);

// Assert
actual.ShouldBeTrue();
}

[Fact]
public static void GivenDifferentValueThenReturnFalse()
{
// Arrange
OutterForImmutableArray<int>.Inner left = new(_sampleValue);
OutterForImmutableArray<int>.Inner right = new(_differentValue);

// Act
bool actual = left.Equals(right);

// Assert
actual.ShouldBeFalse();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
namespace Monify.Console.Classes.Nested.InClass.OutterForImmutableArrayTests;

using System.Collections.Immutable;

public static class WhenGetHashCodeIsCalled
{
private static readonly ImmutableArray<string> _firstValue = ["Eta", "Theta", "Iota"];
private static readonly ImmutableArray<string> _secondValue = ["Kappa", "Lambda", "Mu"];

[Fact]
public static void GivenSameValuesThenReturnSameHashCode()
{
// Arrange
OutterForImmutableArray<int>.Inner first = new(_firstValue);
OutterForImmutableArray<int>.Inner second = new(_firstValue);

// Act
int firstHash = first.GetHashCode();
int secondHash = second.GetHashCode();

// Assert
firstHash.ShouldBe(secondHash);
}

[Fact]
public static void GivenDifferentValuesThenReturnDifferentHashCodes()
{
// Arrange
OutterForImmutableArray<int>.Inner first = new(_firstValue);
OutterForImmutableArray<int>.Inner second = new(_secondValue);

// Act
int firstHash = first.GetHashCode();
int secondHash = second.GetHashCode();

// Assert
firstHash.ShouldNotBe(secondHash);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace Monify.Console.Classes.Nested.InClass.OutterForImmutableArrayTests;

using System.Collections.Immutable;

public static class WhenImplicitOperatorFromImmutableArrayIsCalled
{
private static readonly ImmutableArray<string> _sampleValue = ["Alpha", "Beta", "Gamma"];

[Fact]
public static void GivenValueThenReturnsEquivalentInstance()
{
// Arrange
OutterForImmutableArray<int>.Inner result = _sampleValue;

// Act
ImmutableArray<string> actual = result;

// Assert
actual.ShouldBe(_sampleValue);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
namespace Monify.Console.Classes.Nested.InClass.OutterForImmutableArrayTests;

using System.Collections.Immutable;

public static class WhenImplicitOperatorToImmutableArrayIsCalled
{
private static readonly ImmutableArray<string> _sampleValue = ["Alpha", "Beta", "Gamma"];

[Fact]
public static void GivenNullSubjectThenThrowsArgumentNullException()
{
// Arrange
OutterForImmutableArray<int>.Inner? subject = default;

// Act
Action act = () => _ = (ImmutableArray<string>)subject!;

// Assert
ArgumentNullException exception = Should.Throw<ArgumentNullException>(act);
exception.ParamName.ShouldBe(nameof(subject));
}

[Fact]
public static void GivenValidSubjectThenReturnsValue()
{
// Arrange
OutterForImmutableArray<int>.Inner subject = new(_sampleValue);

// Act
ImmutableArray<string> actual = subject;

// Assert
actual.ShouldBe(_sampleValue);
}
}
Loading