diff --git a/CHANGELOG.md b/CHANGELOG.md index d9cc583..4472302 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to Monify will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +# [1.1.3] - TBC + +## Fixed +- Equality checks involing an encapsulated array containing identical values now yield true (#19). +- `ToString` no longer throws a `FormatException`. + # [1.1.2] - 2025-10-20 ## Fixed diff --git a/build/Tests.props b/build/Tests.props index 4d46a3e..4a96ee8 100644 --- a/build/Tests.props +++ b/build/Tests.props @@ -7,7 +7,7 @@ GeneratedCodeAttribute Obsolete **/*.Designer.cs - CA1859;CA1861 + CA1859;CA1861;IDE0039 $(MSBuildProjectName.Replace('.Tests', '')) net9.0 diff --git a/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..4013db0 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForArrayTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForArray.Inner instance = new(_sampleValue); + + // Act + int[] actual = instance; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..68f1b94 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForArrayTests.InnerTests; + +public static class WhenEqualityOperatorWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForArray.Inner? subject = default; + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _differentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..38010b4 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForArrayTests.InnerTests; + +public static class WhenEqualityOperatorWithOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForArray.Inner? left = default; + OutterForArray.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForArray.Inner? left = default; + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs new file mode 100644 index 0000000..179e8e7 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForArrayTests.InnerTests; + +public static class WhenEqualsWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_sampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_differentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..265b9d3 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForArrayTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentOutterForArrayInnerThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + object other = new OutterForArray.Inner(_sampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + object other = string.Empty; + + // Act + Action act = () => subject.Equals(other); + + // Assert + _ = Should.Throw(act); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..02aa82b --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForArrayTests.InnerTests; + +public static class WhenEqualsWithOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..b99f254 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForArrayTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private static readonly int[] _firstValue = [7, 8, 9]; + private static readonly int[] _secondValue = [10, 11, 12]; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForArray.Inner first = new(_firstValue); + OutterForArray.Inner second = new(_firstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForArray.Inner first = new(_firstValue); + OutterForArray.Inner second = new(_secondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs new file mode 100644 index 0000000..7ebcda0 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForArrayTests.InnerTests; + +public static class WhenImplicitOperatorFromIntArrayIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForArray.Inner result = _sampleValue; + + // Act + int[] actual = result; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs new file mode 100644 index 0000000..139a577 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForArrayTests.InnerTests; + +public static class WhenImplicitOperatorToIntArrayIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + OutterForArray.Inner? subject = default; + + // Act + Action act = () => _ = (int[])subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + int[] actual = subject; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..35bc3d4 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForArrayTests.InnerTests; + +public static class WhenInequalityOperatorWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForArray.Inner? subject = default; + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _differentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..7c784ff --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForArrayTests.InnerTests; + +public static class WhenInequalityOperatorWithOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..da96198 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForArrayTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private const string Expected = "Inner { System.Int32[] }"; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + string result = subject.ToString(); + + // Assert + result.ShouldBe(Expected); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..9994343 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForIntTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForInt.Inner instance = new(SampleValue); + + // Act + int actual = instance; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..94df7f3 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForIntTests.InnerTests; + +public static class WhenEqualityOperatorWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForInt.Inner? subject = default; + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject == DifferentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..ff575ca --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForIntTests.InnerTests; + +public static class WhenEqualityOperatorWithOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForInt.Inner? left = default; + OutterForInt.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForInt.Inner? left = default; + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs new file mode 100644 index 0000000..6c28f44 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForIntTests.InnerTests; + +public static class WhenEqualsWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(SampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(DifferentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..fc04672 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForIntTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentOutterForIntInnerThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + object other = new OutterForInt.Inner(SampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + object other = string.Empty; + + // Act + Action act = () => subject.Equals(other); + + // Assert + _ = Should.Throw(act); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualsWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualsWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..eeefec9 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualsWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForIntTests.InnerTests; + +public static class WhenEqualsWithOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..f9ea02a --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForIntTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private const int FirstValue = 5; + private const int SecondValue = 9; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForInt.Inner first = new(FirstValue); + OutterForInt.Inner second = new(FirstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForInt.Inner first = new(FirstValue); + OutterForInt.Inner second = new(SecondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs new file mode 100644 index 0000000..f000a07 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForIntTests.InnerTests; + +public static class WhenImplicitOperatorFromIntIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForInt.Inner result = SampleValue; + + // Act + int actual = result; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs new file mode 100644 index 0000000..af030ea --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForIntTests.InnerTests; + +public static class WhenImplicitOperatorToIntIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + OutterForInt.Inner? subject = default; + + // Act + Action act = () => _ = (int)subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + int actual = subject; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..8a5e808 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForIntTests.InnerTests; + +public static class WhenInequalityOperatorWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForInt.Inner? subject = default; + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject != DifferentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/InnerTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/InnerTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..dc516fb --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/InnerTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForIntTests.InnerTests; + +public static class WhenInequalityOperatorWithOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..4ca6fb8 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForIntTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private const string Expected = "Inner { 42 }"; + private const int SampleValue = 42; + + [Fact] + public static void GivenValueThenTheExpectedStringIsReturned() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + string result = subject.ToString(); + + // Assert + result.ShouldBe(Expected); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..75c0690 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForStringTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForString.Inner instance = new(SampleValue); + + // Act + string actual = instance; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..711ec60 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForStringTests.InnerTests; + +public static class WhenEqualityOperatorWithOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForString.Inner? left = default; + OutterForString.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForString.Inner? left = default; + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..5eb9f80 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForStringTests.InnerTests; + +public static class WhenEqualityOperatorWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForString.Inner? subject = default; + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject == DifferentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..95fba45 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForStringTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentOutterForStringInnerThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + object other = new OutterForString.Inner(SampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + object other = string.Empty; + + // Act + Action act = () => subject.Equals(other); + + // Assert + _ = Should.Throw(act); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualsWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualsWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..4153265 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualsWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForStringTests.InnerTests; + +public static class WhenEqualsWithOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs new file mode 100644 index 0000000..815590d --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForStringTests.InnerTests; + +public static class WhenEqualsWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(SampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(DifferentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..351f276 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForStringTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private const string FirstValue = "Alpha"; + private const string SecondValue = "Beta"; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForString.Inner first = new(FirstValue); + OutterForString.Inner second = new(FirstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForString.Inner first = new(FirstValue); + OutterForString.Inner second = new(SecondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs new file mode 100644 index 0000000..8dd9aa7 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForStringTests.InnerTests; + +public static class WhenImplicitOperatorFromStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForString.Inner result = SampleValue; + + // Act + string actual = result; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs new file mode 100644 index 0000000..ddfa059 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForStringTests.InnerTests; + +public static class WhenImplicitOperatorToStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + OutterForString.Inner? subject = default; + + // Act + Action act = () => _ = (string)subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + string actual = subject; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/InnerTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/InnerTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..f795216 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/InnerTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForStringTests.InnerTests; + +public static class WhenInequalityOperatorWithOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..a4bb004 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForStringTests.InnerTests; + +public static class WhenInequalityOperatorWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForString.Inner? subject = default; + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject != DifferentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..3db4579 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForStringTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private const string Expected = $"Inner {{ {SampleValue} }}"; + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + string result = subject.ToString(); + + // Assert + result.ShouldBe(Expected); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..db29dcf --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForArrayTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + IOutterForArray.Inner instance = new(_sampleValue); + + // Act + int[] actual = instance; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualityOperatorWithIOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualityOperatorWithIOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..5586f91 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualityOperatorWithIOutterForArrayInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForArrayTests.InnerTests; + +public static class WhenEqualityOperatorWithIOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + IOutterForArray.Inner? left = default; + IOutterForArray.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + IOutterForArray.Inner? left = default; + IOutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForArray.Inner left = new(_sampleValue); + IOutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + IOutterForArray.Inner left = new(_sampleValue); + IOutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..dc3b71b --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForArrayTests.InnerTests; + +public static class WhenEqualityOperatorWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + IOutterForArray.Inner? subject = default; + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + IOutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _differentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualsWithIOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualsWithIOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..7352bda --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualsWithIOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForArrayTests.InnerTests; + +public static class WhenEqualsWithIOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForArray.Inner left = new(_sampleValue); + IOutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + IOutterForArray.Inner left = new(_sampleValue); + IOutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs new file mode 100644 index 0000000..bd0efc2 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForArrayTests.InnerTests; + +public static class WhenEqualsWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_sampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + IOutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_differentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..9b38db1 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForArrayTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + IOutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentIOutterForArrayInnerThenReturnTrue() + { + // Arrange + IOutterForArray.Inner subject = new(_sampleValue); + object other = new IOutterForArray.Inner(_sampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + IOutterForArray.Inner subject = new(_sampleValue); + object other = string.Empty; + + // Act + Action act = () => subject.Equals(other); + + // Assert + _ = Should.Throw(act); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..630356f --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForArrayTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private static readonly int[] _firstValue = [7, 8, 9]; + private static readonly int[] _secondValue = [10, 11, 12]; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + IOutterForArray.Inner first = new(_firstValue); + IOutterForArray.Inner second = new(_firstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + IOutterForArray.Inner first = new(_firstValue); + IOutterForArray.Inner second = new(_secondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs new file mode 100644 index 0000000..a2396a7 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForArrayTests.InnerTests; + +public static class WhenImplicitOperatorFromIntArrayIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + IOutterForArray.Inner result = _sampleValue; + + // Act + int[] actual = result; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs new file mode 100644 index 0000000..6e1a2af --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForArrayTests.InnerTests; + +public static class WhenImplicitOperatorToIntArrayIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + IOutterForArray.Inner? subject = default; + + // Act + Action act = () => _ = (int[])subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + IOutterForArray.Inner subject = new(_sampleValue); + + // Act + int[] actual = subject; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenInequalityOperatorWithIOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenInequalityOperatorWithIOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..47530f3 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenInequalityOperatorWithIOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForArrayTests.InnerTests; + +public static class WhenInequalityOperatorWithIOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + IOutterForArray.Inner left = new(_sampleValue); + IOutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + IOutterForArray.Inner left = new(_sampleValue); + IOutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..3fe0d74 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForArrayTests.InnerTests; + +public static class WhenInequalityOperatorWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + IOutterForArray.Inner? subject = default; + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + IOutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + IOutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _differentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..d5e4a6f --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForArrayTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private const string Expected = "Inner { System.Int32[] }"; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + IOutterForArray.Inner subject = new(_sampleValue); + + // Act + string result = subject.ToString(); + + // Assert + result.ShouldBe(Expected); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..aeaac01 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForIntTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + IOutterForInt.Inner instance = new(SampleValue); + + // Act + int actual = instance; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualityOperatorWithIOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualityOperatorWithIOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..8bf48b9 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualityOperatorWithIOutterForIntInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForIntTests.InnerTests; + +public static class WhenEqualityOperatorWithIOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + IOutterForInt.Inner? left = default; + IOutterForInt.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + IOutterForInt.Inner? left = default; + IOutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForInt.Inner left = new(SampleValue); + IOutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + IOutterForInt.Inner left = new(SampleValue); + IOutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..22b819e --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForIntTests.InnerTests; + +public static class WhenEqualityOperatorWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + IOutterForInt.Inner? subject = default; + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + IOutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject == DifferentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualsWithIOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualsWithIOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..dc5e2b1 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualsWithIOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForIntTests.InnerTests; + +public static class WhenEqualsWithIOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForInt.Inner left = new(SampleValue); + IOutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + IOutterForInt.Inner left = new(SampleValue); + IOutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs new file mode 100644 index 0000000..258c1f9 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForIntTests.InnerTests; + +public static class WhenEqualsWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(SampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + IOutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(DifferentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..895828e --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForIntTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + IOutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentIOutterForIntInnerThenReturnTrue() + { + // Arrange + IOutterForInt.Inner subject = new(SampleValue); + object other = new IOutterForInt.Inner(SampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + IOutterForInt.Inner subject = new(SampleValue); + object other = string.Empty; + + // Act + Action act = () => subject.Equals(other); + + // Assert + _ = Should.Throw(act); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..b5c41c3 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForIntTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private const int FirstValue = 5; + private const int SecondValue = 9; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + IOutterForInt.Inner first = new(FirstValue); + IOutterForInt.Inner second = new(FirstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + IOutterForInt.Inner first = new(FirstValue); + IOutterForInt.Inner second = new(SecondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs new file mode 100644 index 0000000..fd137f9 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForIntTests.InnerTests; + +public static class WhenImplicitOperatorFromIntIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + IOutterForInt.Inner result = SampleValue; + + // Act + int actual = result; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs new file mode 100644 index 0000000..75df0df --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForIntTests.InnerTests; + +public static class WhenImplicitOperatorToIntIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + IOutterForInt.Inner? subject = default; + + // Act + Action act = () => _ = (int)subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + IOutterForInt.Inner subject = new(SampleValue); + + // Act + int actual = subject; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/InnerTests/WhenInequalityOperatorWithIOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/InnerTests/WhenInequalityOperatorWithIOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..fa28392 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/InnerTests/WhenInequalityOperatorWithIOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForIntTests.InnerTests; + +public static class WhenInequalityOperatorWithIOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + IOutterForInt.Inner left = new(SampleValue); + IOutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + IOutterForInt.Inner left = new(SampleValue); + IOutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..efd89d4 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForIntTests.InnerTests; + +public static class WhenInequalityOperatorWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + IOutterForInt.Inner? subject = default; + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + IOutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + IOutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject != DifferentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..3f39b87 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForIntTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private const string Expected = "Inner { 42 }"; + private const int SampleValue = 42; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + IOutterForInt.Inner subject = new(SampleValue); + + // Act + string result = subject.ToString(); + + // Assert + result.ShouldBe(Expected); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..9a353f2 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForStringTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + IOutterForString.Inner instance = new(SampleValue); + + // Act + string actual = instance; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualityOperatorWithIOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualityOperatorWithIOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..1dd8c59 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualityOperatorWithIOutterForStringInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForStringTests.InnerTests; + +public static class WhenEqualityOperatorWithIOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + IOutterForString.Inner? left = default; + IOutterForString.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + IOutterForString.Inner? left = default; + IOutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForString.Inner left = new(SampleValue); + IOutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + IOutterForString.Inner left = new(SampleValue); + IOutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..5dd53a1 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForStringTests.InnerTests; + +public static class WhenEqualityOperatorWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + IOutterForString.Inner? subject = default; + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + IOutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject == DifferentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualsWithIOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualsWithIOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..2873bd1 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualsWithIOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForStringTests.InnerTests; + +public static class WhenEqualsWithIOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForString.Inner left = new(SampleValue); + IOutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + IOutterForString.Inner left = new(SampleValue); + IOutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..def40d9 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForStringTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + IOutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentIOutterForStringInnerThenReturnTrue() + { + // Arrange + IOutterForString.Inner subject = new(SampleValue); + object other = new IOutterForString.Inner(SampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + IOutterForString.Inner subject = new(SampleValue); + object other = string.Empty; + + // Act + Action act = () => subject.Equals(other); + + // Assert + _ = Should.Throw(act); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs new file mode 100644 index 0000000..758affa --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForStringTests.InnerTests; + +public static class WhenEqualsWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(SampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + IOutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(DifferentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..da26ec1 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForStringTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private const string FirstValue = "Alpha"; + private const string SecondValue = "Beta"; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + IOutterForString.Inner first = new(FirstValue); + IOutterForString.Inner second = new(FirstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + IOutterForString.Inner first = new(FirstValue); + IOutterForString.Inner second = new(SecondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs new file mode 100644 index 0000000..d834dfb --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForStringTests.InnerTests; + +public static class WhenImplicitOperatorFromStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + IOutterForString.Inner result = SampleValue; + + // Act + string actual = result; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs new file mode 100644 index 0000000..931ef44 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForStringTests.InnerTests; + +public static class WhenImplicitOperatorToStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + IOutterForString.Inner? subject = default; + + // Act + Action act = () => _ = (string)subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + IOutterForString.Inner subject = new(SampleValue); + + // Act + string actual = subject; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/InnerTests/WhenInequalityOperatorWithIOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/InnerTests/WhenInequalityOperatorWithIOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..c51d7aa --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/InnerTests/WhenInequalityOperatorWithIOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForStringTests.InnerTests; + +public static class WhenInequalityOperatorWithIOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + IOutterForString.Inner left = new(SampleValue); + IOutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + IOutterForString.Inner left = new(SampleValue); + IOutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..1370419 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForStringTests.InnerTests; + +public static class WhenInequalityOperatorWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + IOutterForString.Inner? subject = default; + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + IOutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + IOutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject != DifferentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..9400901 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForStringTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private const string Expected = $"Inner {{ {SampleValue} }}"; + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + IOutterForString.Inner subject = new(SampleValue); + + // Act + string result = subject.ToString(); + + // Assert + result.ShouldBe(Expected); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..2b40d88 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForArrayTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForArray.Inner instance = new(_sampleValue); + + // Act + int[] actual = instance; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..b3e48a8 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForArrayTests.InnerTests; + +public static class WhenEqualityOperatorWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForArray.Inner? subject = default; + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _differentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..80c3a44 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForArrayTests.InnerTests; + +public static class WhenEqualityOperatorWithOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForArray.Inner? left = default; + OutterForArray.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForArray.Inner? left = default; + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs new file mode 100644 index 0000000..2483409 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForArrayTests.InnerTests; + +public static class WhenEqualsWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_sampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_differentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..edc6324 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForArrayTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentOutterForArrayInnerThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + object other = new OutterForArray.Inner(_sampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + object other = string.Empty; + + // Act + Action act = () => subject.Equals(other); + + // Assert + _ = Should.Throw(act); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..bd4369c --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForArrayTests.InnerTests; + +public static class WhenEqualsWithOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..bbc12d1 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForArrayTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private static readonly int[] _firstValue = [7, 8, 9]; + private static readonly int[] _secondValue = [10, 11, 12]; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForArray.Inner first = new(_firstValue); + OutterForArray.Inner second = new(_firstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForArray.Inner first = new(_firstValue); + OutterForArray.Inner second = new(_secondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs new file mode 100644 index 0000000..efe939c --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForArrayTests.InnerTests; + +public static class WhenImplicitOperatorFromIntArrayIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForArray.Inner result = _sampleValue; + + // Act + int[] actual = result; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs new file mode 100644 index 0000000..a6f7698 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForArrayTests.InnerTests; + +public static class WhenImplicitOperatorToIntArrayIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + OutterForArray.Inner? subject = default; + + // Act + Action act = () => _ = (int[])subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + int[] actual = subject; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..0842dee --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForArrayTests.InnerTests; + +public static class WhenInequalityOperatorWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForArray.Inner? subject = default; + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _differentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..5d3d149 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForArrayTests.InnerTests; + +public static class WhenInequalityOperatorWithOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..467ace2 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForArrayTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private const string Expected = "Inner { System.Int32[] }"; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + string result = subject.ToString(); + + // Assert + result.ShouldBe(Expected); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..af978f9 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForIntTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForInt.Inner instance = new(SampleValue); + + // Act + int actual = instance; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..7c40a36 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForIntTests.InnerTests; + +public static class WhenEqualityOperatorWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForInt.Inner? subject = default; + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject == DifferentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..a9cc255 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForIntTests.InnerTests; + +public static class WhenEqualityOperatorWithOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForInt.Inner? left = default; + OutterForInt.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForInt.Inner? left = default; + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs new file mode 100644 index 0000000..7156b8c --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForIntTests.InnerTests; + +public static class WhenEqualsWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(SampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(DifferentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..fa4d6b8 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForIntTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentOutterForIntInnerThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + object other = new OutterForInt.Inner(SampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + object other = string.Empty; + + // Act + Action act = () => subject.Equals(other); + + // Assert + _ = Should.Throw(act); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualsWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualsWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..3d454dd --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualsWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForIntTests.InnerTests; + +public static class WhenEqualsWithOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..dba8c77 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForIntTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private const int FirstValue = 5; + private const int SecondValue = 9; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForInt.Inner first = new(FirstValue); + OutterForInt.Inner second = new(FirstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForInt.Inner first = new(FirstValue); + OutterForInt.Inner second = new(SecondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs new file mode 100644 index 0000000..358e331 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForIntTests.InnerTests; + +public static class WhenImplicitOperatorFromIntIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForInt.Inner result = SampleValue; + + // Act + int actual = result; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs new file mode 100644 index 0000000..dc6ec60 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForIntTests.InnerTests; + +public static class WhenImplicitOperatorToIntIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + OutterForInt.Inner? subject = default; + + // Act + Action act = () => _ = (int)subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + int actual = subject; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..0d8d0f4 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForIntTests.InnerTests; + +public static class WhenInequalityOperatorWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForInt.Inner? subject = default; + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject != DifferentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/InnerTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/InnerTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..5174329 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/InnerTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForIntTests.InnerTests; + +public static class WhenInequalityOperatorWithOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..2080306 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForIntTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private const string Expected = "Inner { 42 }"; + private const int SampleValue = 42; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + string result = subject.ToString(); + + // Assert + result.ShouldBe(Expected); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..04049d8 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForStringTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForString.Inner instance = new(SampleValue); + + // Act + string actual = instance; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..43b0192 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForStringTests.InnerTests; + +public static class WhenEqualityOperatorWithOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForString.Inner? left = default; + OutterForString.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForString.Inner? left = default; + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..1082eb6 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForStringTests.InnerTests; + +public static class WhenEqualityOperatorWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForString.Inner? subject = default; + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject == DifferentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..ce307c6 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForStringTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentOutterForStringInnerThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + object other = new OutterForString.Inner(SampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + object other = string.Empty; + + // Act + Action act = () => subject.Equals(other); + + // Assert + _ = Should.Throw(act); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualsWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualsWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..43cb2fe --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualsWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForStringTests.InnerTests; + +public static class WhenEqualsWithOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs new file mode 100644 index 0000000..aa05d4a --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForStringTests.InnerTests; + +public static class WhenEqualsWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(SampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(DifferentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..0069e02 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForStringTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private const string FirstValue = "Alpha"; + private const string SecondValue = "Beta"; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForString.Inner first = new(FirstValue); + OutterForString.Inner second = new(FirstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForString.Inner first = new(FirstValue); + OutterForString.Inner second = new(SecondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs new file mode 100644 index 0000000..97c1964 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForStringTests.InnerTests; + +public static class WhenImplicitOperatorFromStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForString.Inner result = SampleValue; + + // Act + string actual = result; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs new file mode 100644 index 0000000..4f98de8 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForStringTests.InnerTests; + +public static class WhenImplicitOperatorToStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + OutterForString.Inner? subject = default; + + // Act + Action act = () => _ = (string)subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + string actual = subject; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/InnerTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/InnerTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..10dd2cd --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/InnerTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForStringTests.InnerTests; + +public static class WhenInequalityOperatorWithOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..2d5156e --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForStringTests.InnerTests; + +public static class WhenInequalityOperatorWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForString.Inner? subject = default; + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject != DifferentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..773cdb6 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForStringTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private const string Expected = $"Inner {{ {SampleValue} }}"; + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + string result = subject.ToString(); + + // Assert + result.ShouldBe(Expected); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..e43d707 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForArrayTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForArray.Inner instance = new(_sampleValue); + + // Act + int[] actual = instance; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..9d7bcd0 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForArrayTests.InnerTests; + +public static class WhenEqualityOperatorWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForArray.Inner? subject = default; + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _differentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..6410ebf --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForArrayTests.InnerTests; + +public static class WhenEqualityOperatorWithOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForArray.Inner? left = default; + OutterForArray.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForArray.Inner? left = default; + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs new file mode 100644 index 0000000..a9d097b --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForArrayTests.InnerTests; + +public static class WhenEqualsWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_sampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_differentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..066d9f6 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForArrayTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentOutterForArrayInnerThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + object other = new OutterForArray.Inner(_sampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + object other = string.Empty; + + // Act + Action act = () => subject.Equals(other); + + // Assert + _ = Should.Throw(act); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..6c29fc5 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForArrayTests.InnerTests; + +public static class WhenEqualsWithOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..f1c40a1 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForArrayTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private static readonly int[] _firstValue = [7, 8, 9]; + private static readonly int[] _secondValue = [10, 11, 12]; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForArray.Inner first = new(_firstValue); + OutterForArray.Inner second = new(_firstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForArray.Inner first = new(_firstValue); + OutterForArray.Inner second = new(_secondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs new file mode 100644 index 0000000..af0c15d --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForArrayTests.InnerTests; + +public static class WhenImplicitOperatorFromIntArrayIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForArray.Inner result = _sampleValue; + + // Act + int[] actual = result; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs new file mode 100644 index 0000000..adf8961 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForArrayTests.InnerTests; + +public static class WhenImplicitOperatorToIntArrayIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + OutterForArray.Inner? subject = default; + + // Act + Action act = () => _ = (int[])subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + int[] actual = subject; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..2b82276 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForArrayTests.InnerTests; + +public static class WhenInequalityOperatorWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForArray.Inner? subject = default; + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _differentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..b1e37e5 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForArrayTests.InnerTests; + +public static class WhenInequalityOperatorWithOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..5cfae1b --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForArrayTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private const string Expected = "Inner { System.Int32[] }"; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + string result = subject.ToString(); + + // Assert + result.ShouldBe(Expected); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..f707c95 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForIntTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForInt.Inner instance = new(SampleValue); + + // Act + int actual = instance; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..9993c11 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForIntTests.InnerTests; + +public static class WhenEqualityOperatorWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForInt.Inner? subject = default; + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject == DifferentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..50a7ce1 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForIntTests.InnerTests; + +public static class WhenEqualityOperatorWithOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForInt.Inner? left = default; + OutterForInt.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForInt.Inner? left = default; + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs new file mode 100644 index 0000000..660487f --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForIntTests.InnerTests; + +public static class WhenEqualsWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(SampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(DifferentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..35a7a58 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForIntTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentOutterForIntInnerThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + object other = new OutterForInt.Inner(SampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + object other = string.Empty; + + // Act + Action act = () => subject.Equals(other); + + // Assert + _ = Should.Throw(act); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualsWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualsWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..603539a --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualsWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForIntTests.InnerTests; + +public static class WhenEqualsWithOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..ffdd74e --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForIntTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private const int FirstValue = 5; + private const int SecondValue = 9; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForInt.Inner first = new(FirstValue); + OutterForInt.Inner second = new(FirstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForInt.Inner first = new(FirstValue); + OutterForInt.Inner second = new(SecondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs new file mode 100644 index 0000000..57aebd2 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForIntTests.InnerTests; + +public static class WhenImplicitOperatorFromIntIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForInt.Inner result = SampleValue; + + // Act + int actual = result; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs new file mode 100644 index 0000000..98dad76 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForIntTests.InnerTests; + +public static class WhenImplicitOperatorToIntIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + OutterForInt.Inner? subject = default; + + // Act + Action act = () => _ = (int)subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + int actual = subject; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..89d8131 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForIntTests.InnerTests; + +public static class WhenInequalityOperatorWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForInt.Inner? subject = default; + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject != DifferentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..d8a9ea8 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForIntTests.InnerTests; + +public static class WhenInequalityOperatorWithOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..d24947f --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForIntTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private const string Expected = "Inner { 42 }"; + private const int SampleValue = 42; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + string result = subject.ToString(); + + // Assert + result.ShouldBe(Expected); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..4cdad6a --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForStringTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForString.Inner instance = new(SampleValue); + + // Act + string actual = instance; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..c2f1a10 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForStringTests.InnerTests; + +public static class WhenEqualityOperatorWithOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForString.Inner? left = default; + OutterForString.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForString.Inner? left = default; + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..177a507 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForStringTests.InnerTests; + +public static class WhenEqualityOperatorWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForString.Inner? subject = default; + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject == DifferentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..69e0e98 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForStringTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentOutterForStringInnerThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + object other = new OutterForString.Inner(SampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + object other = string.Empty; + + // Act + Action act = () => subject.Equals(other); + + // Assert + _ = Should.Throw(act); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualsWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualsWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..d8e03b9 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualsWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForStringTests.InnerTests; + +public static class WhenEqualsWithOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs new file mode 100644 index 0000000..0b4c724 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForStringTests.InnerTests; + +public static class WhenEqualsWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(SampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(DifferentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..08a1ac9 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForStringTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private const string FirstValue = "Alpha"; + private const string SecondValue = "Beta"; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForString.Inner first = new(FirstValue); + OutterForString.Inner second = new(FirstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForString.Inner first = new(FirstValue); + OutterForString.Inner second = new(SecondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs new file mode 100644 index 0000000..99ee5a7 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForStringTests.InnerTests; + +public static class WhenImplicitOperatorFromStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForString.Inner result = SampleValue; + + // Act + string actual = result; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs new file mode 100644 index 0000000..0ff4e00 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForStringTests.InnerTests; + +public static class WhenImplicitOperatorToStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + OutterForString.Inner? subject = default; + + // Act + Action act = () => _ = (string)subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + string actual = subject; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..5041676 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForStringTests.InnerTests; + +public static class WhenInequalityOperatorWithOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..2e78713 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForStringTests.InnerTests; + +public static class WhenInequalityOperatorWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForString.Inner? subject = default; + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject != DifferentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..72b0122 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForStringTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private const string Expected = $"Inner {{ {SampleValue} }}"; + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + string result = subject.ToString(); + + // Assert + result.ShouldBe(Expected); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..da2d0f4 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForArrayTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForArray.Inner instance = new(_sampleValue); + + // Act + int[] actual = instance; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..ba6991b --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForArrayTests.InnerTests; + +public static class WhenEqualityOperatorWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForArray.Inner? subject = default; + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _differentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..ec4b94e --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForArrayTests.InnerTests; + +public static class WhenEqualityOperatorWithOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForArray.Inner? left = default; + OutterForArray.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForArray.Inner? left = default; + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs new file mode 100644 index 0000000..54b46e4 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForArrayTests.InnerTests; + +public static class WhenEqualsWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_sampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_differentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..5fb9ad7 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForArrayTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentOutterForArrayInnerThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + object other = new OutterForArray.Inner(_sampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + object other = string.Empty; + + // Act + Action act = () => subject.Equals(other); + + // Assert + _ = Should.Throw(act); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..e4f3385 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForArrayTests.InnerTests; + +public static class WhenEqualsWithOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..b8bdd30 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForArrayTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private static readonly int[] _firstValue = [7, 8, 9]; + private static readonly int[] _secondValue = [10, 11, 12]; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForArray.Inner first = new(_firstValue); + OutterForArray.Inner second = new(_firstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForArray.Inner first = new(_firstValue); + OutterForArray.Inner second = new(_secondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs new file mode 100644 index 0000000..affa79b --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForArrayTests.InnerTests; + +public static class WhenImplicitOperatorFromIntArrayIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForArray.Inner result = _sampleValue; + + // Act + int[] actual = result; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs new file mode 100644 index 0000000..022106d --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForArrayTests.InnerTests; + +public static class WhenImplicitOperatorToIntArrayIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + OutterForArray.Inner? subject = default; + + // Act + Action act = () => _ = (int[])subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + int[] actual = subject; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..5cd6430 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForArrayTests.InnerTests; + +public static class WhenInequalityOperatorWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForArray.Inner? subject = default; + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _differentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..201b918 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForArrayTests.InnerTests; + +public static class WhenInequalityOperatorWithOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..f9a4719 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForArrayTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private const string Expected = "Inner { System.Int32[] }"; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + string result = subject.ToString(); + + // Assert + result.ShouldBe(Expected); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..0635ab3 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForIntTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForInt.Inner instance = new(SampleValue); + + // Act + int actual = instance; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..2cd1402 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForIntTests.InnerTests; + +public static class WhenEqualityOperatorWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForInt.Inner? subject = default; + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject == DifferentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..30b12ce --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForIntTests.InnerTests; + +public static class WhenEqualityOperatorWithOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForInt.Inner? left = default; + OutterForInt.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForInt.Inner? left = default; + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs new file mode 100644 index 0000000..091f82d --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForIntTests.InnerTests; + +public static class WhenEqualsWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(SampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(DifferentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..7d231b0 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForIntTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentOutterForIntInnerThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + object other = new OutterForInt.Inner(SampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + object other = string.Empty; + + // Act + Action act = () => subject.Equals(other); + + // Assert + _ = Should.Throw(act); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualsWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualsWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..8aaecc4 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualsWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForIntTests.InnerTests; + +public static class WhenEqualsWithOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..d86cded --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForIntTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private const int FirstValue = 5; + private const int SecondValue = 9; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForInt.Inner first = new(FirstValue); + OutterForInt.Inner second = new(FirstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForInt.Inner first = new(FirstValue); + OutterForInt.Inner second = new(SecondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs new file mode 100644 index 0000000..8cfcb02 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForIntTests.InnerTests; + +public static class WhenImplicitOperatorFromIntIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForInt.Inner result = SampleValue; + + // Act + int actual = result; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs new file mode 100644 index 0000000..14e7572 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForIntTests.InnerTests; + +public static class WhenImplicitOperatorToIntIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + OutterForInt.Inner? subject = default; + + // Act + Action act = () => _ = (int)subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + int actual = subject; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..bef40d6 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForIntTests.InnerTests; + +public static class WhenInequalityOperatorWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForInt.Inner? subject = default; + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject != DifferentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/InnerTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/InnerTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..a0ff6cf --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/InnerTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForIntTests.InnerTests; + +public static class WhenInequalityOperatorWithOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..e8f31d9 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForIntTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private const string Expected = "Inner { 42 }"; + private const int SampleValue = 42; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + string result = subject.ToString(); + + // Assert + result.ShouldBe(Expected); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..fe623e8 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForStringTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForString.Inner instance = new(SampleValue); + + // Act + string actual = instance; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..394b16d --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForStringTests.InnerTests; + +public static class WhenEqualityOperatorWithOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForString.Inner? left = default; + OutterForString.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForString.Inner? left = default; + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..2c12d53 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForStringTests.InnerTests; + +public static class WhenEqualityOperatorWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForString.Inner? subject = default; + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject == DifferentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..aa87016 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForStringTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentOutterForStringInnerThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + object other = new OutterForString.Inner(SampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + object other = string.Empty; + + // Act + Action act = () => subject.Equals(other); + + // Assert + _ = Should.Throw(act); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualsWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualsWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..47b425d --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualsWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForStringTests.InnerTests; + +public static class WhenEqualsWithOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs new file mode 100644 index 0000000..d1a7055 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForStringTests.InnerTests; + +public static class WhenEqualsWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(SampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(DifferentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..02e5c50 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForStringTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private const string FirstValue = "Alpha"; + private const string SecondValue = "Beta"; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForString.Inner first = new(FirstValue); + OutterForString.Inner second = new(FirstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForString.Inner first = new(FirstValue); + OutterForString.Inner second = new(SecondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs new file mode 100644 index 0000000..c71d874 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForStringTests.InnerTests; + +public static class WhenImplicitOperatorFromStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForString.Inner result = SampleValue; + + // Act + string actual = result; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs new file mode 100644 index 0000000..a6df8c0 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForStringTests.InnerTests; + +public static class WhenImplicitOperatorToStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + OutterForString.Inner? subject = default; + + // Act + Action act = () => _ = (string)subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + string actual = subject; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/InnerTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/InnerTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..b77e253 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/InnerTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForStringTests.InnerTests; + +public static class WhenInequalityOperatorWithOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..6c45ad0 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForStringTests.InnerTests; + +public static class WhenInequalityOperatorWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForString.Inner? subject = default; + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject != DifferentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..4687ca9 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForStringTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private const string Expected = $"Inner {{ {SampleValue} }}"; + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + string result = subject.ToString(); + + // Assert + result.ShouldBe(Expected); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Simple/SimpleForArrayTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForArrayTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..08d5573 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForArrayTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Simple.SimpleForArrayTests; + +public static class WhenConstructorIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + SimpleForArray instance = new(_sampleValue); + + // Act + int[] actual = instance; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Simple/SimpleForArrayTests/WhenEqualityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForArrayTests/WhenEqualityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..b33a168 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForArrayTests/WhenEqualityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Simple.SimpleForArrayTests; + +public static class WhenEqualityOperatorWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + SimpleForArray? subject = default; + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForArray subject = new(_sampleValue); + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + SimpleForArray subject = new(_sampleValue); + + // Act + bool actual = subject == _differentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Simple/SimpleForArrayTests/WhenEqualityOperatorWithSimpleForArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForArrayTests/WhenEqualityOperatorWithSimpleForArrayIsCalled.cs new file mode 100644 index 0000000..de2188f --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForArrayTests/WhenEqualityOperatorWithSimpleForArrayIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Classes.Simple.SimpleForArrayTests; + +public static class WhenEqualityOperatorWithSimpleForArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + SimpleForArray? left = default; + SimpleForArray? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + SimpleForArray? left = default; + SimpleForArray right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForArray left = new(_sampleValue); + SimpleForArray right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + SimpleForArray left = new(_sampleValue); + SimpleForArray right = new(_differentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Simple/SimpleForArrayTests/WhenEqualsWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForArrayTests/WhenEqualsWithIntArrayIsCalled.cs new file mode 100644 index 0000000..8091f5b --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForArrayTests/WhenEqualsWithIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Simple.SimpleForArrayTests; + +public static class WhenEqualsWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForArray subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_sampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + SimpleForArray subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_differentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Simple/SimpleForArrayTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForArrayTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..b2da9c6 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForArrayTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Classes.Simple.SimpleForArrayTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + SimpleForArray subject = new(_sampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentSimpleForArrayThenReturnTrue() + { + // Arrange + SimpleForArray subject = new(_sampleValue); + object other = new SimpleForArray(_sampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + SimpleForArray subject = new(_sampleValue); + object other = string.Empty; + + // Act + Action act = () => subject.Equals(other); + + // Assert + _ = Should.Throw(act); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Simple/SimpleForArrayTests/WhenEqualsWithSimpleForArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForArrayTests/WhenEqualsWithSimpleForArrayIsCalled.cs new file mode 100644 index 0000000..0da3057 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForArrayTests/WhenEqualsWithSimpleForArrayIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Simple.SimpleForArrayTests; + +public static class WhenEqualsWithSimpleForArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForArray left = new(_sampleValue); + SimpleForArray right = new(_sampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + SimpleForArray left = new(_sampleValue); + SimpleForArray right = new(_differentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Simple/SimpleForArrayTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForArrayTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..d9322f1 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForArrayTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Classes.Simple.SimpleForArrayTests; + +public static class WhenGetHashCodeIsCalled +{ + private static readonly int[] _firstValue = [7, 8, 9]; + private static readonly int[] _secondValue = [10, 11, 12]; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + SimpleForArray first = new(_firstValue); + SimpleForArray second = new(_firstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + SimpleForArray first = new(_firstValue); + SimpleForArray second = new(_secondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Simple/SimpleForArrayTests/WhenImplicitOperatorFromIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForArrayTests/WhenImplicitOperatorFromIntArrayIsCalled.cs new file mode 100644 index 0000000..dce0568 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForArrayTests/WhenImplicitOperatorFromIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Simple.SimpleForArrayTests; + +public static class WhenImplicitOperatorFromIntArrayIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + SimpleForArray result = _sampleValue; + + // Act + int[] actual = result; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Simple/SimpleForArrayTests/WhenImplicitOperatorToIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForArrayTests/WhenImplicitOperatorToIntArrayIsCalled.cs new file mode 100644 index 0000000..755dfd8 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForArrayTests/WhenImplicitOperatorToIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Simple.SimpleForArrayTests; + +public static class WhenImplicitOperatorToIntArrayIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + SimpleForArray? subject = default; + + // Act + Action act = () => _ = (int[])subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + SimpleForArray subject = new(_sampleValue); + + // Act + int[] actual = subject; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Simple/SimpleForArrayTests/WhenInequalityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForArrayTests/WhenInequalityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..ae61624 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForArrayTests/WhenInequalityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Simple.SimpleForArrayTests; + +public static class WhenInequalityOperatorWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + SimpleForArray? subject = default; + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + SimpleForArray subject = new(_sampleValue); + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + SimpleForArray subject = new(_sampleValue); + + // Act + bool actual = subject != _differentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Simple/SimpleForArrayTests/WhenInequalityOperatorWithSimpleForArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForArrayTests/WhenInequalityOperatorWithSimpleForArrayIsCalled.cs new file mode 100644 index 0000000..2d856a3 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForArrayTests/WhenInequalityOperatorWithSimpleForArrayIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Simple.SimpleForArrayTests; + +public static class WhenInequalityOperatorWithSimpleForArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + SimpleForArray left = new(_sampleValue); + SimpleForArray right = new(_sampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + SimpleForArray left = new(_sampleValue); + SimpleForArray right = new(_differentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Simple/SimpleForArrayTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForArrayTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..edbeb68 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForArrayTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Classes.Simple.SimpleForArrayTests; + +public static class WhenToStringIsCalled +{ + private const string Expected = "SimpleForArray { System.Int32[] }"; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + SimpleForArray subject = new(_sampleValue); + + // Act + string result = subject.ToString(); + + // Assert + result.ShouldBe(Expected); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenEqualityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenEqualityOperatorWithIntIsCalled.cs index 884a359..b94e864 100644 --- a/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenEqualityOperatorWithIntIsCalled.cs +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenEqualityOperatorWithIntIsCalled.cs @@ -2,8 +2,8 @@ namespace Monify.Console.Classes.Simple.SimpleForIntTests; public static class WhenEqualityOperatorWithIntIsCalled { - private const int SampleValue = 101; private const int DifferentValue = 202; + private const int SampleValue = 101; [Fact] public static void GivenSubjectIsNullThenReturnFalse() diff --git a/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenEqualityOperatorWithSimpleForIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenEqualityOperatorWithSimpleForIntIsCalled.cs index 848eb15..2a0369d 100644 --- a/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenEqualityOperatorWithSimpleForIntIsCalled.cs +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenEqualityOperatorWithSimpleForIntIsCalled.cs @@ -2,8 +2,8 @@ namespace Monify.Console.Classes.Simple.SimpleForIntTests; public static class WhenEqualityOperatorWithSimpleForIntIsCalled { - private const int SampleValue = 14; private const int DifferentValue = 17; + private const int SampleValue = 14; [Fact] public static void GivenBothNullThenReturnTrue() diff --git a/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenEqualsWithIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenEqualsWithIntIsCalled.cs index bfa1059..cf9d5fb 100644 --- a/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenEqualsWithIntIsCalled.cs +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenEqualsWithIntIsCalled.cs @@ -2,8 +2,8 @@ namespace Monify.Console.Classes.Simple.SimpleForIntTests; public static class WhenEqualsWithIntIsCalled { - private const int SampleValue = 36; private const int DifferentValue = 12; + private const int SampleValue = 36; [Fact] public static void GivenSameValueThenReturnTrue() diff --git a/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenEqualsWithSimpleForIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenEqualsWithSimpleForIntIsCalled.cs index 5200bcc..506e48f 100644 --- a/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenEqualsWithSimpleForIntIsCalled.cs +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenEqualsWithSimpleForIntIsCalled.cs @@ -2,8 +2,8 @@ namespace Monify.Console.Classes.Simple.SimpleForIntTests; public static class WhenEqualsWithSimpleForIntIsCalled { - private const int SampleValue = 51; private const int DifferentValue = 5; + private const int SampleValue = 51; [Fact] public static void GivenOtherHasSameValueThenReturnTrue() diff --git a/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenImplicitOperatorToIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenImplicitOperatorToIntIsCalled.cs index 42906e9..6e48d22 100644 --- a/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenImplicitOperatorToIntIsCalled.cs +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenImplicitOperatorToIntIsCalled.cs @@ -15,7 +15,7 @@ public static void GivenNullSubjectThenThrowsArgumentNullException() // Assert ArgumentNullException exception = Should.Throw(act); - exception.ParamName.ShouldBe("subject"); + exception.ParamName.ShouldBe(nameof(subject)); } [Fact] diff --git a/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenInequalityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenInequalityOperatorWithIntIsCalled.cs index 59868ec..bf9d622 100644 --- a/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenInequalityOperatorWithIntIsCalled.cs +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenInequalityOperatorWithIntIsCalled.cs @@ -2,8 +2,8 @@ namespace Monify.Console.Classes.Simple.SimpleForIntTests; public static class WhenInequalityOperatorWithIntIsCalled { - private const int SampleValue = 7; private const int DifferentValue = 9; + private const int SampleValue = 7; [Fact] public static void GivenSubjectIsNullThenReturnTrue() diff --git a/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenInequalityOperatorWithSimpleForIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenInequalityOperatorWithSimpleForIntIsCalled.cs index 7d17868..8b7f62c 100644 --- a/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenInequalityOperatorWithSimpleForIntIsCalled.cs +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenInequalityOperatorWithSimpleForIntIsCalled.cs @@ -2,8 +2,8 @@ namespace Monify.Console.Classes.Simple.SimpleForIntTests; public static class WhenInequalityOperatorWithSimpleForIntIsCalled { - private const int SampleValue = 63; private const int DifferentValue = 64; + private const int SampleValue = 63; [Fact] public static void GivenSameValueThenReturnFalse() diff --git a/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenToStringIsCalled.cs index 6a42a34..68da357 100644 --- a/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenToStringIsCalled.cs +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenToStringIsCalled.cs @@ -2,18 +2,19 @@ namespace Monify.Console.Classes.Simple.SimpleForIntTests; public static class WhenToStringIsCalled { + private const string Expected = "SimpleForInt { 91 }"; private const int SampleValue = 91; [Fact] - public static void GivenValueThenThrowFormatException() + public static void GivenValueTheExpectedStringIsReturned() { // Arrange SimpleForInt subject = new(SampleValue); // Act - Action act = () => subject.ToString(); + string result = subject.ToString(); // Assert - _ = Should.Throw(act); + result.ShouldBe(Expected); } } \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Simple/SimpleForStringTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForStringTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..275ee57 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForStringTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Simple.SimpleForStringTests; + +public static class WhenConstructorIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + SimpleForString instance = new(SampleValue); + + // Act + string actual = instance; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Simple/SimpleForStringTests/WhenEqualityOperatorWithSimpleForStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForStringTests/WhenEqualityOperatorWithSimpleForStringIsCalled.cs new file mode 100644 index 0000000..8da71be --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForStringTests/WhenEqualityOperatorWithSimpleForStringIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Classes.Simple.SimpleForStringTests; + +public static class WhenEqualityOperatorWithSimpleForStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + SimpleForString? left = default; + SimpleForString? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + SimpleForString? left = default; + SimpleForString right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForString left = new(SampleValue); + SimpleForString right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + SimpleForString left = new(SampleValue); + SimpleForString right = new(DifferentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Simple/SimpleForStringTests/WhenEqualityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForStringTests/WhenEqualityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..88f6e08 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForStringTests/WhenEqualityOperatorWithStringIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Simple.SimpleForStringTests; + +public static class WhenEqualityOperatorWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + SimpleForString? subject = default; + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForString subject = new(SampleValue); + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + SimpleForString subject = new(SampleValue); + + // Act + bool actual = subject == DifferentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Simple/SimpleForStringTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForStringTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..acdcd4f --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForStringTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Classes.Simple.SimpleForStringTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + SimpleForString subject = new(SampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentSimpleForStringThenReturnTrue() + { + // Arrange + SimpleForString subject = new(SampleValue); + object other = new SimpleForString(SampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + SimpleForString subject = new(SampleValue); + object other = string.Empty; + + // Act + Action act = () => subject.Equals(other); + + // Assert + _ = Should.Throw(act); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Simple/SimpleForStringTests/WhenEqualsWithSimpleForStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForStringTests/WhenEqualsWithSimpleForStringIsCalled.cs new file mode 100644 index 0000000..0e794c9 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForStringTests/WhenEqualsWithSimpleForStringIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Simple.SimpleForStringTests; + +public static class WhenEqualsWithSimpleForStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForString left = new(SampleValue); + SimpleForString right = new(SampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + SimpleForString left = new(SampleValue); + SimpleForString right = new(DifferentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Simple/SimpleForStringTests/WhenEqualsWithStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForStringTests/WhenEqualsWithStringIsCalled.cs new file mode 100644 index 0000000..353dceb --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForStringTests/WhenEqualsWithStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Simple.SimpleForStringTests; + +public static class WhenEqualsWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForString subject = new(SampleValue); + + // Act + bool actual = subject.Equals(SampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + SimpleForString subject = new(SampleValue); + + // Act + bool actual = subject.Equals(DifferentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Simple/SimpleForStringTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForStringTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..1b68d2f --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForStringTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Classes.Simple.SimpleForStringTests; + +public static class WhenGetHashCodeIsCalled +{ + private const string FirstValue = "Alpha"; + private const string SecondValue = "Beta"; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + SimpleForString first = new(FirstValue); + SimpleForString second = new(FirstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + SimpleForString first = new(FirstValue); + SimpleForString second = new(SecondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Simple/SimpleForStringTests/WhenImplicitOperatorFromStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForStringTests/WhenImplicitOperatorFromStringIsCalled.cs new file mode 100644 index 0000000..0aa0fcc --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForStringTests/WhenImplicitOperatorFromStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Simple.SimpleForStringTests; + +public static class WhenImplicitOperatorFromStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + SimpleForString result = SampleValue; + + // Act + string actual = result; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Simple/SimpleForStringTests/WhenImplicitOperatorToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForStringTests/WhenImplicitOperatorToStringIsCalled.cs new file mode 100644 index 0000000..0f2b86c --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForStringTests/WhenImplicitOperatorToStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Simple.SimpleForStringTests; + +public static class WhenImplicitOperatorToStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + SimpleForString? subject = default; + + // Act + Action act = () => _ = (string)subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + SimpleForString subject = new(SampleValue); + + // Act + string actual = subject; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Simple/SimpleForStringTests/WhenInequalityOperatorWithSimpleForStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForStringTests/WhenInequalityOperatorWithSimpleForStringIsCalled.cs new file mode 100644 index 0000000..dad703d --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForStringTests/WhenInequalityOperatorWithSimpleForStringIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Simple.SimpleForStringTests; + +public static class WhenInequalityOperatorWithSimpleForStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + SimpleForString left = new(SampleValue); + SimpleForString right = new(SampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + SimpleForString left = new(SampleValue); + SimpleForString right = new(DifferentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Simple/SimpleForStringTests/WhenInequalityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForStringTests/WhenInequalityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..6946d82 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForStringTests/WhenInequalityOperatorWithStringIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Simple.SimpleForStringTests; + +public static class WhenInequalityOperatorWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + SimpleForString? subject = default; + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + SimpleForString subject = new(SampleValue); + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + SimpleForString subject = new(SampleValue); + + // Act + bool actual = subject != DifferentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Simple/SimpleForStringTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForStringTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..bc5688e --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForStringTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Classes.Simple.SimpleForStringTests; + +public static class WhenToStringIsCalled +{ + private const string Expected = $"SimpleForString {{ {SampleValue} }}"; + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + SimpleForString subject = new(SampleValue); + + // Act + string result = subject.ToString(); + + // Assert + result.ShouldBe(Expected); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..e07fc3d --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForArrayTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForArray.Inner instance = new(_sampleValue); + + // Act + int[] actual = instance; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..7b1faea --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForArrayTests.InnerTests; + +public static class WhenEqualityOperatorWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForArray.Inner? subject = default; + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _differentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..6613df2 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForArrayTests.InnerTests; + +public static class WhenEqualityOperatorWithOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForArray.Inner? left = default; + OutterForArray.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForArray.Inner? left = default; + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs new file mode 100644 index 0000000..5f65afe --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForArrayTests.InnerTests; + +public static class WhenEqualsWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_sampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_differentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..d01b44e --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForArrayTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentOutterForArrayInnerThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + object other = new OutterForArray.Inner(_sampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + object other = string.Empty; + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..acc71f6 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForArrayTests.InnerTests; + +public static class WhenEqualsWithOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..8ab75d9 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForArrayTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private static readonly int[] _firstValue = [7, 8, 9]; + private static readonly int[] _secondValue = [10, 11, 12]; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForArray.Inner first = new(_firstValue); + OutterForArray.Inner second = new(_firstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForArray.Inner first = new(_firstValue); + OutterForArray.Inner second = new(_secondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs new file mode 100644 index 0000000..dd18ba2 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForArrayTests.InnerTests; + +public static class WhenImplicitOperatorFromIntArrayIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForArray.Inner result = _sampleValue; + + // Act + int[] actual = result; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs new file mode 100644 index 0000000..7000f18 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForArrayTests.InnerTests; + +public static class WhenImplicitOperatorToIntArrayIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + OutterForArray.Inner? subject = default; + + // Act + Action act = () => _ = (int[])subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + int[] actual = subject; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..d3296ea --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForArrayTests.InnerTests; + +public static class WhenInequalityOperatorWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForArray.Inner? subject = default; + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _differentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..127f7f2 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForArrayTests.InnerTests; + +public static class WhenInequalityOperatorWithOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..21d81df --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForArrayTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenReturnRecordDescription() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + string actual = subject.ToString(); + + // Assert + actual.ShouldBe("Inner { }"); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..b3e7df6 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForIntTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForInt.Inner instance = new(SampleValue); + + // Act + int actual = instance; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..acfcc6f --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForIntTests.InnerTests; + +public static class WhenEqualityOperatorWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForInt.Inner? subject = default; + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject == DifferentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..2483b07 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForIntTests.InnerTests; + +public static class WhenEqualityOperatorWithOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForInt.Inner? left = default; + OutterForInt.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForInt.Inner? left = default; + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs new file mode 100644 index 0000000..636c75e --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForIntTests.InnerTests; + +public static class WhenEqualsWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(SampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(DifferentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..3c8b6d5 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForIntTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentOutterForIntInnerThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + object other = new OutterForInt.Inner(SampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + object other = string.Empty; + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualsWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualsWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..7122570 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualsWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForIntTests.InnerTests; + +public static class WhenEqualsWithOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..209b4db --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForIntTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private const int FirstValue = 5; + private const int SecondValue = 9; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForInt.Inner first = new(FirstValue); + OutterForInt.Inner second = new(FirstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForInt.Inner first = new(FirstValue); + OutterForInt.Inner second = new(SecondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs new file mode 100644 index 0000000..dab146f --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForIntTests.InnerTests; + +public static class WhenImplicitOperatorFromIntIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForInt.Inner result = SampleValue; + + // Act + int actual = result; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs new file mode 100644 index 0000000..2791ca3 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForIntTests.InnerTests; + +public static class WhenImplicitOperatorToIntIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + OutterForInt.Inner? subject = default; + + // Act + Action act = () => _ = (int)subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + int actual = subject; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..70a5c13 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForIntTests.InnerTests; + +public static class WhenInequalityOperatorWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForInt.Inner? subject = default; + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject != DifferentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/InnerTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/InnerTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..34a4169 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/InnerTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForIntTests.InnerTests; + +public static class WhenInequalityOperatorWithOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..c5f775d --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForIntTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValueThenReturnRecordDescription() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + string actual = subject.ToString(); + + // Assert + actual.ShouldBe("Inner { }"); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..359f93d --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForStringTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForString.Inner instance = new(SampleValue); + + // Act + string actual = instance; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..7ae4156 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForStringTests.InnerTests; + +public static class WhenEqualityOperatorWithOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForString.Inner? left = default; + OutterForString.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForString.Inner? left = default; + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..c5b79ec --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForStringTests.InnerTests; + +public static class WhenEqualityOperatorWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForString.Inner? subject = default; + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject == DifferentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..8bf79b9 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForStringTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentOutterForStringInnerThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + object other = new OutterForString.Inner(SampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + object other = string.Empty; + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualsWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualsWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..9273761 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualsWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForStringTests.InnerTests; + +public static class WhenEqualsWithOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs new file mode 100644 index 0000000..c6e9f96 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForStringTests.InnerTests; + +public static class WhenEqualsWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(SampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(DifferentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..c952794 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForStringTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private const string FirstValue = "Alpha"; + private const string SecondValue = "Beta"; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForString.Inner first = new(FirstValue); + OutterForString.Inner second = new(FirstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForString.Inner first = new(FirstValue); + OutterForString.Inner second = new(SecondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs new file mode 100644 index 0000000..1c78b24 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForStringTests.InnerTests; + +public static class WhenImplicitOperatorFromStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForString.Inner result = SampleValue; + + // Act + string actual = result; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs new file mode 100644 index 0000000..a903a21 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForStringTests.InnerTests; + +public static class WhenImplicitOperatorToStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + OutterForString.Inner? subject = default; + + // Act + Action act = () => _ = (string)subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + string actual = subject; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/InnerTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/InnerTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..ab0ab55 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/InnerTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForStringTests.InnerTests; + +public static class WhenInequalityOperatorWithOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..c2ddc23 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForStringTests.InnerTests; + +public static class WhenInequalityOperatorWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForString.Inner? subject = default; + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject != DifferentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..1130488 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForStringTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenReturnRecordDescription() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + string actual = subject.ToString(); + + // Assert + actual.ShouldBe("Inner { }"); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..6473226 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForArrayTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + IOutterForArray.Inner instance = new(_sampleValue); + + // Act + int[] actual = instance; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualityOperatorWithIOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualityOperatorWithIOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..9f4d305 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualityOperatorWithIOutterForArrayInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForArrayTests.InnerTests; + +public static class WhenEqualityOperatorWithIOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + IOutterForArray.Inner? left = default; + IOutterForArray.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + IOutterForArray.Inner? left = default; + IOutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForArray.Inner left = new(_sampleValue); + IOutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + IOutterForArray.Inner left = new(_sampleValue); + IOutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..7740b0c --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForArrayTests.InnerTests; + +public static class WhenEqualityOperatorWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + IOutterForArray.Inner? subject = default; + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + IOutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _differentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualsWithIOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualsWithIOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..2433eba --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualsWithIOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForArrayTests.InnerTests; + +public static class WhenEqualsWithIOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForArray.Inner left = new(_sampleValue); + IOutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + IOutterForArray.Inner left = new(_sampleValue); + IOutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs new file mode 100644 index 0000000..2dde2c8 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForArrayTests.InnerTests; + +public static class WhenEqualsWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_sampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + IOutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_differentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..305383c --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForArrayTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + IOutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentIOutterForArrayInnerThenReturnTrue() + { + // Arrange + IOutterForArray.Inner subject = new(_sampleValue); + object other = new IOutterForArray.Inner(_sampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenReturnFalse() + { + // Arrange + IOutterForArray.Inner subject = new(_sampleValue); + object other = string.Empty; + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..7a50981 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForArrayTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private static readonly int[] _firstValue = [7, 8, 9]; + private static readonly int[] _secondValue = [10, 11, 12]; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + IOutterForArray.Inner first = new(_firstValue); + IOutterForArray.Inner second = new(_firstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + IOutterForArray.Inner first = new(_firstValue); + IOutterForArray.Inner second = new(_secondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs new file mode 100644 index 0000000..b5591df --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForArrayTests.InnerTests; + +public static class WhenImplicitOperatorFromIntArrayIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + IOutterForArray.Inner result = _sampleValue; + + // Act + int[] actual = result; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs new file mode 100644 index 0000000..8ed5412 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForArrayTests.InnerTests; + +public static class WhenImplicitOperatorToIntArrayIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + IOutterForArray.Inner? subject = default; + + // Act + Action act = () => _ = (int[])subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + IOutterForArray.Inner subject = new(_sampleValue); + + // Act + int[] actual = subject; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenInequalityOperatorWithIOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenInequalityOperatorWithIOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..24d831b --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenInequalityOperatorWithIOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForArrayTests.InnerTests; + +public static class WhenInequalityOperatorWithIOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + IOutterForArray.Inner left = new(_sampleValue); + IOutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + IOutterForArray.Inner left = new(_sampleValue); + IOutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..d43788c --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForArrayTests.InnerTests; + +public static class WhenInequalityOperatorWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + IOutterForArray.Inner? subject = default; + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + IOutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + IOutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _differentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..a71e0b4 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForArrayTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenReturnRecordDescription() + { + // Arrange + IOutterForArray.Inner subject = new(_sampleValue); + + // Act + string actual = subject.ToString(); + + // Assert + actual.ShouldBe("Inner { }"); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..35ce23f --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForIntTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + IOutterForInt.Inner instance = new(SampleValue); + + // Act + int actual = instance; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualityOperatorWithIOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualityOperatorWithIOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..38235f5 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualityOperatorWithIOutterForIntInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForIntTests.InnerTests; + +public static class WhenEqualityOperatorWithIOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + IOutterForInt.Inner? left = default; + IOutterForInt.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + IOutterForInt.Inner? left = default; + IOutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForInt.Inner left = new(SampleValue); + IOutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + IOutterForInt.Inner left = new(SampleValue); + IOutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..fdd9206 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForIntTests.InnerTests; + +public static class WhenEqualityOperatorWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + IOutterForInt.Inner? subject = default; + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + IOutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject == DifferentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualsWithIOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualsWithIOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..58f5397 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualsWithIOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForIntTests.InnerTests; + +public static class WhenEqualsWithIOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForInt.Inner left = new(SampleValue); + IOutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + IOutterForInt.Inner left = new(SampleValue); + IOutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs new file mode 100644 index 0000000..6a3fc7f --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForIntTests.InnerTests; + +public static class WhenEqualsWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(SampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + IOutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(DifferentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..aa142c6 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForIntTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + IOutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentIOutterForIntInnerThenReturnTrue() + { + // Arrange + IOutterForInt.Inner subject = new(SampleValue); + object other = new IOutterForInt.Inner(SampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenReturnFalse() + { + // Arrange + IOutterForInt.Inner subject = new(SampleValue); + object other = string.Empty; + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..bff2635 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForIntTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private const int FirstValue = 5; + private const int SecondValue = 9; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + IOutterForInt.Inner first = new(FirstValue); + IOutterForInt.Inner second = new(FirstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + IOutterForInt.Inner first = new(FirstValue); + IOutterForInt.Inner second = new(SecondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs new file mode 100644 index 0000000..39fe3b2 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForIntTests.InnerTests; + +public static class WhenImplicitOperatorFromIntIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + IOutterForInt.Inner result = SampleValue; + + // Act + int actual = result; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs new file mode 100644 index 0000000..cad179f --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForIntTests.InnerTests; + +public static class WhenImplicitOperatorToIntIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + IOutterForInt.Inner? subject = default; + + // Act + Action act = () => _ = (int)subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + IOutterForInt.Inner subject = new(SampleValue); + + // Act + int actual = subject; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/InnerTests/WhenInequalityOperatorWithIOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/InnerTests/WhenInequalityOperatorWithIOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..6c1cbb7 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/InnerTests/WhenInequalityOperatorWithIOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForIntTests.InnerTests; + +public static class WhenInequalityOperatorWithIOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + IOutterForInt.Inner left = new(SampleValue); + IOutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + IOutterForInt.Inner left = new(SampleValue); + IOutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..74fb2a8 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForIntTests.InnerTests; + +public static class WhenInequalityOperatorWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + IOutterForInt.Inner? subject = default; + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + IOutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + IOutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject != DifferentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..fb59a72 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForIntTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValueThenReturnRecordDescription() + { + // Arrange + IOutterForInt.Inner subject = new(SampleValue); + + // Act + string actual = subject.ToString(); + + // Assert + actual.ShouldBe("Inner { }"); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..c8bf8f5 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForStringTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + IOutterForString.Inner instance = new(SampleValue); + + // Act + string actual = instance; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualityOperatorWithIOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualityOperatorWithIOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..0b19345 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualityOperatorWithIOutterForStringInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForStringTests.InnerTests; + +public static class WhenEqualityOperatorWithIOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + IOutterForString.Inner? left = default; + IOutterForString.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + IOutterForString.Inner? left = default; + IOutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForString.Inner left = new(SampleValue); + IOutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + IOutterForString.Inner left = new(SampleValue); + IOutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..5d618f6 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForStringTests.InnerTests; + +public static class WhenEqualityOperatorWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + IOutterForString.Inner? subject = default; + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + IOutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject == DifferentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualsWithIOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualsWithIOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..4ce3014 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualsWithIOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForStringTests.InnerTests; + +public static class WhenEqualsWithIOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForString.Inner left = new(SampleValue); + IOutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + IOutterForString.Inner left = new(SampleValue); + IOutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..7ca96f5 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForStringTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + IOutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentIOutterForStringInnerThenReturnTrue() + { + // Arrange + IOutterForString.Inner subject = new(SampleValue); + object other = new IOutterForString.Inner(SampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenReturnFalse() + { + // Arrange + IOutterForString.Inner subject = new(SampleValue); + object other = string.Empty; + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs new file mode 100644 index 0000000..d6e8e5c --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForStringTests.InnerTests; + +public static class WhenEqualsWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(SampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + IOutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(DifferentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..4082efb --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForStringTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private const string FirstValue = "Alpha"; + private const string SecondValue = "Beta"; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + IOutterForString.Inner first = new(FirstValue); + IOutterForString.Inner second = new(FirstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + IOutterForString.Inner first = new(FirstValue); + IOutterForString.Inner second = new(SecondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs new file mode 100644 index 0000000..3f35fcb --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForStringTests.InnerTests; + +public static class WhenImplicitOperatorFromStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + IOutterForString.Inner result = SampleValue; + + // Act + string actual = result; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs new file mode 100644 index 0000000..f6cd281 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForStringTests.InnerTests; + +public static class WhenImplicitOperatorToStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + IOutterForString.Inner? subject = default; + + // Act + Action act = () => _ = (string)subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + IOutterForString.Inner subject = new(SampleValue); + + // Act + string actual = subject; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/InnerTests/WhenInequalityOperatorWithIOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/InnerTests/WhenInequalityOperatorWithIOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..4f93b14 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/InnerTests/WhenInequalityOperatorWithIOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForStringTests.InnerTests; + +public static class WhenInequalityOperatorWithIOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + IOutterForString.Inner left = new(SampleValue); + IOutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + IOutterForString.Inner left = new(SampleValue); + IOutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..bed26ae --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForStringTests.InnerTests; + +public static class WhenInequalityOperatorWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + IOutterForString.Inner? subject = default; + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + IOutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + IOutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject != DifferentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..abe9140 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForStringTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenReturnRecordDescription() + { + // Arrange + IOutterForString.Inner subject = new(SampleValue); + + // Act + string actual = subject.ToString(); + + // Assert + actual.ShouldBe("Inner { }"); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..28c0a10 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForArrayTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForArray.Inner instance = new(_sampleValue); + + // Act + int[] actual = instance; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..e220c44 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForArrayTests.InnerTests; + +public static class WhenEqualityOperatorWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForArray.Inner? subject = default; + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _differentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..0ec2601 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForArrayTests.InnerTests; + +public static class WhenEqualityOperatorWithOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForArray.Inner? left = default; + OutterForArray.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForArray.Inner? left = default; + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs new file mode 100644 index 0000000..7ae2270 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForArrayTests.InnerTests; + +public static class WhenEqualsWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_sampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_differentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..c641cd5 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForArrayTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentOutterForArrayInnerThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + object other = new OutterForArray.Inner(_sampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + object other = string.Empty; + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..780c95b --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForArrayTests.InnerTests; + +public static class WhenEqualsWithOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..ff94a4a --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForArrayTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private static readonly int[] _firstValue = [7, 8, 9]; + private static readonly int[] _secondValue = [10, 11, 12]; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForArray.Inner first = new(_firstValue); + OutterForArray.Inner second = new(_firstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForArray.Inner first = new(_firstValue); + OutterForArray.Inner second = new(_secondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs new file mode 100644 index 0000000..1cfaeda --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForArrayTests.InnerTests; + +public static class WhenImplicitOperatorFromIntArrayIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForArray.Inner result = _sampleValue; + + // Act + int[] actual = result; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs new file mode 100644 index 0000000..0f8e9a5 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForArrayTests.InnerTests; + +public static class WhenImplicitOperatorToIntArrayIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + OutterForArray.Inner? subject = default; + + // Act + Action act = () => _ = (int[])subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + int[] actual = subject; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..3d8db6f --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForArrayTests.InnerTests; + +public static class WhenInequalityOperatorWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForArray.Inner? subject = default; + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _differentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..8603901 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForArrayTests.InnerTests; + +public static class WhenInequalityOperatorWithOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..b5f9b87 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForArrayTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenReturnRecordDescription() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + string actual = subject.ToString(); + + // Assert + actual.ShouldBe("Inner { }"); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..776e83b --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForIntTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForInt.Inner instance = new(SampleValue); + + // Act + int actual = instance; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..58ac849 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForIntTests.InnerTests; + +public static class WhenEqualityOperatorWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForInt.Inner? subject = default; + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject == DifferentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..0faa8d6 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForIntTests.InnerTests; + +public static class WhenEqualityOperatorWithOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForInt.Inner? left = default; + OutterForInt.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForInt.Inner? left = default; + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs new file mode 100644 index 0000000..70c74ff --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForIntTests.InnerTests; + +public static class WhenEqualsWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(SampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(DifferentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..d23a119 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForIntTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentOutterForIntInnerThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + object other = new OutterForInt.Inner(SampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + object other = string.Empty; + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualsWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualsWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..74ac333 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualsWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForIntTests.InnerTests; + +public static class WhenEqualsWithOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..9a20a2e --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForIntTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private const int FirstValue = 5; + private const int SecondValue = 9; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForInt.Inner first = new(FirstValue); + OutterForInt.Inner second = new(FirstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForInt.Inner first = new(FirstValue); + OutterForInt.Inner second = new(SecondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs new file mode 100644 index 0000000..09cee1f --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForIntTests.InnerTests; + +public static class WhenImplicitOperatorFromIntIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForInt.Inner result = SampleValue; + + // Act + int actual = result; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs new file mode 100644 index 0000000..faf21e6 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForIntTests.InnerTests; + +public static class WhenImplicitOperatorToIntIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + OutterForInt.Inner? subject = default; + + // Act + Action act = () => _ = (int)subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + int actual = subject; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..69506bc --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForIntTests.InnerTests; + +public static class WhenInequalityOperatorWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForInt.Inner? subject = default; + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject != DifferentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/InnerTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/InnerTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..d0e5a87 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/InnerTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForIntTests.InnerTests; + +public static class WhenInequalityOperatorWithOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..ddefa09 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForIntTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValueThenReturnRecordDescription() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + string actual = subject.ToString(); + + // Assert + actual.ShouldBe("Inner { }"); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..2a5895b --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForStringTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForString.Inner instance = new(SampleValue); + + // Act + string actual = instance; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..bbcc5c1 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForStringTests.InnerTests; + +public static class WhenEqualityOperatorWithOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForString.Inner? left = default; + OutterForString.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForString.Inner? left = default; + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..be04c5f --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForStringTests.InnerTests; + +public static class WhenEqualityOperatorWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForString.Inner? subject = default; + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject == DifferentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..fc2d643 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForStringTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentOutterForStringInnerThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + object other = new OutterForString.Inner(SampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + object other = string.Empty; + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualsWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualsWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..14f42f2 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualsWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForStringTests.InnerTests; + +public static class WhenEqualsWithOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs new file mode 100644 index 0000000..4557b3c --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForStringTests.InnerTests; + +public static class WhenEqualsWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(SampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(DifferentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..fc1a754 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForStringTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private const string FirstValue = "Alpha"; + private const string SecondValue = "Beta"; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForString.Inner first = new(FirstValue); + OutterForString.Inner second = new(FirstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForString.Inner first = new(FirstValue); + OutterForString.Inner second = new(SecondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs new file mode 100644 index 0000000..1a1ab61 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForStringTests.InnerTests; + +public static class WhenImplicitOperatorFromStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForString.Inner result = SampleValue; + + // Act + string actual = result; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs new file mode 100644 index 0000000..3a27da5 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForStringTests.InnerTests; + +public static class WhenImplicitOperatorToStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + OutterForString.Inner? subject = default; + + // Act + Action act = () => _ = (string)subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + string actual = subject; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/InnerTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/InnerTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..cd66cdf --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/InnerTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForStringTests.InnerTests; + +public static class WhenInequalityOperatorWithOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..d102d05 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForStringTests.InnerTests; + +public static class WhenInequalityOperatorWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForString.Inner? subject = default; + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject != DifferentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..7d55327 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForStringTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenReturnRecordDescription() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + string actual = subject.ToString(); + + // Assert + actual.ShouldBe("Inner { }"); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..6b17d37 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForArrayTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForArray.Inner instance = new(_sampleValue); + + // Act + int[] actual = instance; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..0283ce8 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForArrayTests.InnerTests; + +public static class WhenEqualityOperatorWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForArray.Inner? subject = default; + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _differentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..b4952d6 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForArrayTests.InnerTests; + +public static class WhenEqualityOperatorWithOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForArray.Inner? left = default; + OutterForArray.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForArray.Inner? left = default; + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs new file mode 100644 index 0000000..a21ae1b --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForArrayTests.InnerTests; + +public static class WhenEqualsWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_sampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_differentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..53b055c --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForArrayTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentOutterForArrayInnerThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + object other = new OutterForArray.Inner(_sampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + object other = string.Empty; + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..8046333 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForArrayTests.InnerTests; + +public static class WhenEqualsWithOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..d4fe9f4 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForArrayTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private static readonly int[] _firstValue = [7, 8, 9]; + private static readonly int[] _secondValue = [10, 11, 12]; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForArray.Inner first = new(_firstValue); + OutterForArray.Inner second = new(_firstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForArray.Inner first = new(_firstValue); + OutterForArray.Inner second = new(_secondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs new file mode 100644 index 0000000..e1bf6ec --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForArrayTests.InnerTests; + +public static class WhenImplicitOperatorFromIntArrayIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForArray.Inner result = _sampleValue; + + // Act + int[] actual = result; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs new file mode 100644 index 0000000..91ea60a --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForArrayTests.InnerTests; + +public static class WhenImplicitOperatorToIntArrayIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + OutterForArray.Inner? subject = default; + + // Act + Action act = () => _ = (int[])subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + int[] actual = subject; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..0c615e9 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForArrayTests.InnerTests; + +public static class WhenInequalityOperatorWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForArray.Inner? subject = default; + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _differentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..f3de426 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForArrayTests.InnerTests; + +public static class WhenInequalityOperatorWithOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..fccc5f8 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForArrayTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenReturnRecordDescription() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + string actual = subject.ToString(); + + // Assert + actual.ShouldBe("Inner { }"); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..26a7271 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForIntTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForInt.Inner instance = new(SampleValue); + + // Act + int actual = instance; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..6ef252d --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForIntTests.InnerTests; + +public static class WhenEqualityOperatorWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForInt.Inner? subject = default; + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject == DifferentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..b7a012f --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForIntTests.InnerTests; + +public static class WhenEqualityOperatorWithOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForInt.Inner? left = default; + OutterForInt.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForInt.Inner? left = default; + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs new file mode 100644 index 0000000..b6ba974 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForIntTests.InnerTests; + +public static class WhenEqualsWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(SampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(DifferentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..c3339bf --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForIntTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentOutterForIntInnerThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + object other = new OutterForInt.Inner(SampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + object other = string.Empty; + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualsWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualsWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..9ff153a --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualsWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForIntTests.InnerTests; + +public static class WhenEqualsWithOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..2de2f3b --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForIntTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private const int FirstValue = 5; + private const int SecondValue = 9; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForInt.Inner first = new(FirstValue); + OutterForInt.Inner second = new(FirstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForInt.Inner first = new(FirstValue); + OutterForInt.Inner second = new(SecondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs new file mode 100644 index 0000000..3e811a5 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForIntTests.InnerTests; + +public static class WhenImplicitOperatorFromIntIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForInt.Inner result = SampleValue; + + // Act + int actual = result; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs new file mode 100644 index 0000000..74e6c1a --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForIntTests.InnerTests; + +public static class WhenImplicitOperatorToIntIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + OutterForInt.Inner? subject = default; + + // Act + Action act = () => _ = (int)subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + int actual = subject; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..fcb75dc --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForIntTests.InnerTests; + +public static class WhenInequalityOperatorWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForInt.Inner? subject = default; + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject != DifferentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..5446785 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForIntTests.InnerTests; + +public static class WhenInequalityOperatorWithOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..8ce5241 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForIntTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValueThenReturnRecordDescription() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + string actual = subject.ToString(); + + // Assert + actual.ShouldBe("Inner { }"); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..1d91e6c --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForStringTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForString.Inner instance = new(SampleValue); + + // Act + string actual = instance; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..23743cb --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForStringTests.InnerTests; + +public static class WhenEqualityOperatorWithOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForString.Inner? left = default; + OutterForString.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForString.Inner? left = default; + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..c109fa0 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForStringTests.InnerTests; + +public static class WhenEqualityOperatorWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForString.Inner? subject = default; + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject == DifferentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..7a286f2 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForStringTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentOutterForStringInnerThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + object other = new OutterForString.Inner(SampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + object other = string.Empty; + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualsWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualsWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..0389dbc --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualsWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForStringTests.InnerTests; + +public static class WhenEqualsWithOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs new file mode 100644 index 0000000..7dca359 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForStringTests.InnerTests; + +public static class WhenEqualsWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(SampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(DifferentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..2d5f6d6 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForStringTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private const string FirstValue = "Alpha"; + private const string SecondValue = "Beta"; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForString.Inner first = new(FirstValue); + OutterForString.Inner second = new(FirstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForString.Inner first = new(FirstValue); + OutterForString.Inner second = new(SecondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs new file mode 100644 index 0000000..dae94da --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForStringTests.InnerTests; + +public static class WhenImplicitOperatorFromStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForString.Inner result = SampleValue; + + // Act + string actual = result; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs new file mode 100644 index 0000000..e62b634 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForStringTests.InnerTests; + +public static class WhenImplicitOperatorToStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + OutterForString.Inner? subject = default; + + // Act + Action act = () => _ = (string)subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + string actual = subject; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..4ffa318 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForStringTests.InnerTests; + +public static class WhenInequalityOperatorWithOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..25d48d4 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForStringTests.InnerTests; + +public static class WhenInequalityOperatorWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForString.Inner? subject = default; + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject != DifferentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..63edc3d --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForStringTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenReturnRecordDescription() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + string actual = subject.ToString(); + + // Assert + actual.ShouldBe("Inner { }"); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..bb23a1b --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForArrayTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForArray.Inner instance = new(_sampleValue); + + // Act + int[] actual = instance; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..c8890f6 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForArrayTests.InnerTests; + +public static class WhenEqualityOperatorWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForArray.Inner? subject = default; + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _differentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..af9bef4 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForArrayTests.InnerTests; + +public static class WhenEqualityOperatorWithOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForArray.Inner? left = default; + OutterForArray.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForArray.Inner? left = default; + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs new file mode 100644 index 0000000..63f6052 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForArrayTests.InnerTests; + +public static class WhenEqualsWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_sampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_differentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..2019cc0 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForArrayTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentOutterForArrayInnerThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + object other = new OutterForArray.Inner(_sampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + object other = string.Empty; + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..5a5ab0a --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForArrayTests.InnerTests; + +public static class WhenEqualsWithOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..76ba9c7 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForArrayTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private static readonly int[] _firstValue = [7, 8, 9]; + private static readonly int[] _secondValue = [10, 11, 12]; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForArray.Inner first = new(_firstValue); + OutterForArray.Inner second = new(_firstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForArray.Inner first = new(_firstValue); + OutterForArray.Inner second = new(_secondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs new file mode 100644 index 0000000..b32a647 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForArrayTests.InnerTests; + +public static class WhenImplicitOperatorFromIntArrayIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForArray.Inner result = _sampleValue; + + // Act + int[] actual = result; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs new file mode 100644 index 0000000..40d8bee --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForArrayTests.InnerTests; + +public static class WhenImplicitOperatorToIntArrayIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + OutterForArray.Inner? subject = default; + + // Act + Action act = () => _ = (int[])subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + int[] actual = subject; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..a06e654 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForArrayTests.InnerTests; + +public static class WhenInequalityOperatorWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForArray.Inner? subject = default; + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _differentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..5af43df --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForArrayTests.InnerTests; + +public static class WhenInequalityOperatorWithOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..a690380 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForArrayTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenReturnRecordDescription() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + string actual = subject.ToString(); + + // Assert + actual.ShouldBe("Inner { }"); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..c8a238d --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForIntTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForInt.Inner instance = new(SampleValue); + + // Act + int actual = instance; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..19a99c0 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForIntTests.InnerTests; + +public static class WhenEqualityOperatorWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForInt.Inner? subject = default; + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject == DifferentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..4317fd2 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForIntTests.InnerTests; + +public static class WhenEqualityOperatorWithOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForInt.Inner? left = default; + OutterForInt.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForInt.Inner? left = default; + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs new file mode 100644 index 0000000..0da6d59 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForIntTests.InnerTests; + +public static class WhenEqualsWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(SampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(DifferentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..d5b181c --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForIntTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentOutterForIntInnerThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + object other = new OutterForInt.Inner(SampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + object other = string.Empty; + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualsWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualsWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..58e7eb0 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualsWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForIntTests.InnerTests; + +public static class WhenEqualsWithOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..da46448 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForIntTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private const int FirstValue = 5; + private const int SecondValue = 9; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForInt.Inner first = new(FirstValue); + OutterForInt.Inner second = new(FirstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForInt.Inner first = new(FirstValue); + OutterForInt.Inner second = new(SecondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs new file mode 100644 index 0000000..88dd7a8 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForIntTests.InnerTests; + +public static class WhenImplicitOperatorFromIntIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForInt.Inner result = SampleValue; + + // Act + int actual = result; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs new file mode 100644 index 0000000..438bae8 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForIntTests.InnerTests; + +public static class WhenImplicitOperatorToIntIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + OutterForInt.Inner? subject = default; + + // Act + Action act = () => _ = (int)subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + int actual = subject; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..bb31bb4 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForIntTests.InnerTests; + +public static class WhenInequalityOperatorWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForInt.Inner? subject = default; + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject != DifferentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/InnerTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/InnerTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..97a9574 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/InnerTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForIntTests.InnerTests; + +public static class WhenInequalityOperatorWithOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..6019726 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForIntTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValueThenReturnRecordDescription() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + string actual = subject.ToString(); + + // Assert + actual.ShouldBe("Inner { }"); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..cc8eeed --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForStringTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForString.Inner instance = new(SampleValue); + + // Act + string actual = instance; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..4bff482 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForStringTests.InnerTests; + +public static class WhenEqualityOperatorWithOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForString.Inner? left = default; + OutterForString.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForString.Inner? left = default; + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..dbcaa22 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForStringTests.InnerTests; + +public static class WhenEqualityOperatorWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForString.Inner? subject = default; + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject == DifferentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..daf8f67 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForStringTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentOutterForStringInnerThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + object other = new OutterForString.Inner(SampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + object other = string.Empty; + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualsWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualsWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..10cf7c6 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualsWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForStringTests.InnerTests; + +public static class WhenEqualsWithOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs new file mode 100644 index 0000000..1756340 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForStringTests.InnerTests; + +public static class WhenEqualsWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(SampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(DifferentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..94c1523 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForStringTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private const string FirstValue = "Alpha"; + private const string SecondValue = "Beta"; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForString.Inner first = new(FirstValue); + OutterForString.Inner second = new(FirstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForString.Inner first = new(FirstValue); + OutterForString.Inner second = new(SecondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs new file mode 100644 index 0000000..12e3e7d --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForStringTests.InnerTests; + +public static class WhenImplicitOperatorFromStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForString.Inner result = SampleValue; + + // Act + string actual = result; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs new file mode 100644 index 0000000..fb802f9 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForStringTests.InnerTests; + +public static class WhenImplicitOperatorToStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + OutterForString.Inner? subject = default; + + // Act + Action act = () => _ = (string)subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + string actual = subject; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/InnerTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/InnerTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..15d7039 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/InnerTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForStringTests.InnerTests; + +public static class WhenInequalityOperatorWithOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..be88e00 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForStringTests.InnerTests; + +public static class WhenInequalityOperatorWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForString.Inner? subject = default; + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject != DifferentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..4295448 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForStringTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenReturnRecordDescription() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + string actual = subject.ToString(); + + // Assert + actual.ShouldBe("Inner { }"); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Simple/SimpleForArrayTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForArrayTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..5fe711f --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForArrayTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Simple.SimpleForArrayTests; + +public static class WhenConstructorIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + SimpleForArray instance = new(_sampleValue); + + // Act + int[] actual = instance; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Simple/SimpleForArrayTests/WhenEqualityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForArrayTests/WhenEqualityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..52b80e3 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForArrayTests/WhenEqualityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Simple.SimpleForArrayTests; + +public static class WhenEqualityOperatorWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + SimpleForArray? subject = default; + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForArray subject = new(_sampleValue); + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + SimpleForArray subject = new(_sampleValue); + + // Act + bool actual = subject == _differentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Simple/SimpleForArrayTests/WhenEqualityOperatorWithSimpleForArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForArrayTests/WhenEqualityOperatorWithSimpleForArrayIsCalled.cs new file mode 100644 index 0000000..1c7e33f --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForArrayTests/WhenEqualityOperatorWithSimpleForArrayIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Records.Simple.SimpleForArrayTests; + +public static class WhenEqualityOperatorWithSimpleForArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + SimpleForArray? left = default; + SimpleForArray? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + SimpleForArray? left = default; + SimpleForArray right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForArray left = new(_sampleValue); + SimpleForArray right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + SimpleForArray left = new(_sampleValue); + SimpleForArray right = new(_differentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Simple/SimpleForArrayTests/WhenEqualsWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForArrayTests/WhenEqualsWithIntArrayIsCalled.cs new file mode 100644 index 0000000..2d61007 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForArrayTests/WhenEqualsWithIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Simple.SimpleForArrayTests; + +public static class WhenEqualsWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForArray subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_sampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + SimpleForArray subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_differentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Simple/SimpleForArrayTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForArrayTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..601a892 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForArrayTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Records.Simple.SimpleForArrayTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + SimpleForArray subject = new(_sampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentSimpleForArrayThenReturnTrue() + { + // Arrange + SimpleForArray subject = new(_sampleValue); + object other = new SimpleForArray(_sampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenReturnFalse() + { + // Arrange + SimpleForArray subject = new(_sampleValue); + object other = string.Empty; + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Simple/SimpleForArrayTests/WhenEqualsWithSimpleForArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForArrayTests/WhenEqualsWithSimpleForArrayIsCalled.cs new file mode 100644 index 0000000..ce23eb2 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForArrayTests/WhenEqualsWithSimpleForArrayIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Simple.SimpleForArrayTests; + +public static class WhenEqualsWithSimpleForArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForArray left = new(_sampleValue); + SimpleForArray right = new(_sampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + SimpleForArray left = new(_sampleValue); + SimpleForArray right = new(_differentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Simple/SimpleForArrayTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForArrayTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..e099892 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForArrayTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Records.Simple.SimpleForArrayTests; + +public static class WhenGetHashCodeIsCalled +{ + private static readonly int[] _firstValue = [7, 8, 9]; + private static readonly int[] _secondValue = [10, 11, 12]; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + SimpleForArray first = new(_firstValue); + SimpleForArray second = new(_firstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + SimpleForArray first = new(_firstValue); + SimpleForArray second = new(_secondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Simple/SimpleForArrayTests/WhenImplicitOperatorFromIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForArrayTests/WhenImplicitOperatorFromIntArrayIsCalled.cs new file mode 100644 index 0000000..0b1d0b5 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForArrayTests/WhenImplicitOperatorFromIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Simple.SimpleForArrayTests; + +public static class WhenImplicitOperatorFromIntArrayIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + SimpleForArray result = _sampleValue; + + // Act + int[] actual = result; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Simple/SimpleForArrayTests/WhenImplicitOperatorToIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForArrayTests/WhenImplicitOperatorToIntArrayIsCalled.cs new file mode 100644 index 0000000..65d1acd --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForArrayTests/WhenImplicitOperatorToIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Simple.SimpleForArrayTests; + +public static class WhenImplicitOperatorToIntArrayIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + SimpleForArray? subject = default; + + // Act + Action act = () => _ = (int[])subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + SimpleForArray subject = new(_sampleValue); + + // Act + int[] actual = subject; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Simple/SimpleForArrayTests/WhenInequalityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForArrayTests/WhenInequalityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..7f32dd8 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForArrayTests/WhenInequalityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Simple.SimpleForArrayTests; + +public static class WhenInequalityOperatorWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + SimpleForArray? subject = default; + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + SimpleForArray subject = new(_sampleValue); + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + SimpleForArray subject = new(_sampleValue); + + // Act + bool actual = subject != _differentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Simple/SimpleForArrayTests/WhenInequalityOperatorWithSimpleForArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForArrayTests/WhenInequalityOperatorWithSimpleForArrayIsCalled.cs new file mode 100644 index 0000000..c96365d --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForArrayTests/WhenInequalityOperatorWithSimpleForArrayIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Simple.SimpleForArrayTests; + +public static class WhenInequalityOperatorWithSimpleForArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + SimpleForArray left = new(_sampleValue); + SimpleForArray right = new(_sampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + SimpleForArray left = new(_sampleValue); + SimpleForArray right = new(_differentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Simple/SimpleForArrayTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForArrayTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..e6cecc5 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForArrayTests/WhenToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Simple.SimpleForArrayTests; + +public static class WhenToStringIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenReturnRecordDescription() + { + // Arrange + SimpleForArray subject = new(_sampleValue); + + // Act + string actual = subject.ToString(); + + // Assert + actual.ShouldBe("SimpleForArray { }"); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Simple/SimpleForIntTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForIntTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..e949e0f --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForIntTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Simple.SimpleForIntTests; + +public static class WhenConstructorIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + SimpleForInt instance = new(SampleValue); + + // Act + int actual = instance; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Simple/SimpleForIntTests/WhenEqualityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForIntTests/WhenEqualityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..d37b159 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForIntTests/WhenEqualityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Simple.SimpleForIntTests; + +public static class WhenEqualityOperatorWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + SimpleForInt? subject = default; + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForInt subject = new(SampleValue); + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + SimpleForInt subject = new(SampleValue); + + // Act + bool actual = subject == DifferentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Simple/SimpleForIntTests/WhenEqualityOperatorWithSimpleForIntIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForIntTests/WhenEqualityOperatorWithSimpleForIntIsCalled.cs new file mode 100644 index 0000000..8b514af --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForIntTests/WhenEqualityOperatorWithSimpleForIntIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Records.Simple.SimpleForIntTests; + +public static class WhenEqualityOperatorWithSimpleForIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + SimpleForInt? left = default; + SimpleForInt? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + SimpleForInt? left = default; + SimpleForInt right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForInt left = new(SampleValue); + SimpleForInt right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + SimpleForInt left = new(SampleValue); + SimpleForInt right = new(DifferentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Simple/SimpleForIntTests/WhenEqualsWithIntIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForIntTests/WhenEqualsWithIntIsCalled.cs new file mode 100644 index 0000000..3721e85 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForIntTests/WhenEqualsWithIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Simple.SimpleForIntTests; + +public static class WhenEqualsWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForInt subject = new(SampleValue); + + // Act + bool actual = subject.Equals(SampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + SimpleForInt subject = new(SampleValue); + + // Act + bool actual = subject.Equals(DifferentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Simple/SimpleForIntTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForIntTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..de8b1cd --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForIntTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Records.Simple.SimpleForIntTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + SimpleForInt subject = new(SampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentSimpleForIntThenReturnTrue() + { + // Arrange + SimpleForInt subject = new(SampleValue); + object other = new SimpleForInt(SampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenReturnFalse() + { + // Arrange + SimpleForInt subject = new(SampleValue); + object other = string.Empty; + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Simple/SimpleForIntTests/WhenEqualsWithSimpleForIntIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForIntTests/WhenEqualsWithSimpleForIntIsCalled.cs new file mode 100644 index 0000000..3fc32eb --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForIntTests/WhenEqualsWithSimpleForIntIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Simple.SimpleForIntTests; + +public static class WhenEqualsWithSimpleForIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForInt left = new(SampleValue); + SimpleForInt right = new(SampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + SimpleForInt left = new(SampleValue); + SimpleForInt right = new(DifferentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Simple/SimpleForIntTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForIntTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..dea5f46 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForIntTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Records.Simple.SimpleForIntTests; + +public static class WhenGetHashCodeIsCalled +{ + private const int FirstValue = 5; + private const int SecondValue = 9; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + SimpleForInt first = new(FirstValue); + SimpleForInt second = new(FirstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + SimpleForInt first = new(FirstValue); + SimpleForInt second = new(SecondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Simple/SimpleForIntTests/WhenImplicitOperatorFromIntIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForIntTests/WhenImplicitOperatorFromIntIsCalled.cs new file mode 100644 index 0000000..20d0917 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForIntTests/WhenImplicitOperatorFromIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Simple.SimpleForIntTests; + +public static class WhenImplicitOperatorFromIntIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + SimpleForInt result = SampleValue; + + // Act + int actual = result; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Simple/SimpleForIntTests/WhenImplicitOperatorToIntIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForIntTests/WhenImplicitOperatorToIntIsCalled.cs new file mode 100644 index 0000000..174d354 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForIntTests/WhenImplicitOperatorToIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Simple.SimpleForIntTests; + +public static class WhenImplicitOperatorToIntIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + SimpleForInt? subject = default; + + // Act + Action act = () => _ = (int)subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + SimpleForInt subject = new(SampleValue); + + // Act + int actual = subject; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Simple/SimpleForIntTests/WhenInequalityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForIntTests/WhenInequalityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..f6a740c --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForIntTests/WhenInequalityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Simple.SimpleForIntTests; + +public static class WhenInequalityOperatorWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + SimpleForInt? subject = default; + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + SimpleForInt subject = new(SampleValue); + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + SimpleForInt subject = new(SampleValue); + + // Act + bool actual = subject != DifferentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Simple/SimpleForIntTests/WhenInequalityOperatorWithSimpleForIntIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForIntTests/WhenInequalityOperatorWithSimpleForIntIsCalled.cs new file mode 100644 index 0000000..e48da6a --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForIntTests/WhenInequalityOperatorWithSimpleForIntIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Simple.SimpleForIntTests; + +public static class WhenInequalityOperatorWithSimpleForIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + SimpleForInt left = new(SampleValue); + SimpleForInt right = new(SampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + SimpleForInt left = new(SampleValue); + SimpleForInt right = new(DifferentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Simple/SimpleForIntTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForIntTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..0879fd3 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForIntTests/WhenToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Simple.SimpleForIntTests; + +public static class WhenToStringIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValueThenReturnRecordDescription() + { + // Arrange + SimpleForInt subject = new(SampleValue); + + // Act + string actual = subject.ToString(); + + // Assert + actual.ShouldBe("SimpleForInt { }"); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Simple/SimpleForStringTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForStringTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..93200bb --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForStringTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Simple.SimpleForStringTests; + +public static class WhenConstructorIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + SimpleForString instance = new(SampleValue); + + // Act + string actual = instance; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Simple/SimpleForStringTests/WhenEqualityOperatorWithSimpleForStringIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForStringTests/WhenEqualityOperatorWithSimpleForStringIsCalled.cs new file mode 100644 index 0000000..c3da25d --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForStringTests/WhenEqualityOperatorWithSimpleForStringIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Records.Simple.SimpleForStringTests; + +public static class WhenEqualityOperatorWithSimpleForStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + SimpleForString? left = default; + SimpleForString? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + SimpleForString? left = default; + SimpleForString right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForString left = new(SampleValue); + SimpleForString right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + SimpleForString left = new(SampleValue); + SimpleForString right = new(DifferentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Simple/SimpleForStringTests/WhenEqualityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForStringTests/WhenEqualityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..681f458 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForStringTests/WhenEqualityOperatorWithStringIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Simple.SimpleForStringTests; + +public static class WhenEqualityOperatorWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + SimpleForString? subject = default; + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForString subject = new(SampleValue); + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + SimpleForString subject = new(SampleValue); + + // Act + bool actual = subject == DifferentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Simple/SimpleForStringTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForStringTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..ecd6f9b --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForStringTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Records.Simple.SimpleForStringTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + SimpleForString subject = new(SampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentSimpleForStringThenReturnTrue() + { + // Arrange + SimpleForString subject = new(SampleValue); + object other = new SimpleForString(SampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenReturnFalse() + { + // Arrange + SimpleForString subject = new(SampleValue); + object other = string.Empty; + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Simple/SimpleForStringTests/WhenEqualsWithSimpleForStringIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForStringTests/WhenEqualsWithSimpleForStringIsCalled.cs new file mode 100644 index 0000000..41003b1 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForStringTests/WhenEqualsWithSimpleForStringIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Simple.SimpleForStringTests; + +public static class WhenEqualsWithSimpleForStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForString left = new(SampleValue); + SimpleForString right = new(SampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + SimpleForString left = new(SampleValue); + SimpleForString right = new(DifferentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Simple/SimpleForStringTests/WhenEqualsWithStringIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForStringTests/WhenEqualsWithStringIsCalled.cs new file mode 100644 index 0000000..e6c26a1 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForStringTests/WhenEqualsWithStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Simple.SimpleForStringTests; + +public static class WhenEqualsWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForString subject = new(SampleValue); + + // Act + bool actual = subject.Equals(SampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + SimpleForString subject = new(SampleValue); + + // Act + bool actual = subject.Equals(DifferentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Simple/SimpleForStringTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForStringTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..dec2b52 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForStringTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Records.Simple.SimpleForStringTests; + +public static class WhenGetHashCodeIsCalled +{ + private const string FirstValue = "Alpha"; + private const string SecondValue = "Beta"; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + SimpleForString first = new(FirstValue); + SimpleForString second = new(FirstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + SimpleForString first = new(FirstValue); + SimpleForString second = new(SecondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Simple/SimpleForStringTests/WhenImplicitOperatorFromStringIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForStringTests/WhenImplicitOperatorFromStringIsCalled.cs new file mode 100644 index 0000000..1ba6edb --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForStringTests/WhenImplicitOperatorFromStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Simple.SimpleForStringTests; + +public static class WhenImplicitOperatorFromStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + SimpleForString result = SampleValue; + + // Act + string actual = result; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Simple/SimpleForStringTests/WhenImplicitOperatorToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForStringTests/WhenImplicitOperatorToStringIsCalled.cs new file mode 100644 index 0000000..846fedf --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForStringTests/WhenImplicitOperatorToStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Simple.SimpleForStringTests; + +public static class WhenImplicitOperatorToStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + SimpleForString? subject = default; + + // Act + Action act = () => _ = (string)subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + SimpleForString subject = new(SampleValue); + + // Act + string actual = subject; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Simple/SimpleForStringTests/WhenInequalityOperatorWithSimpleForStringIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForStringTests/WhenInequalityOperatorWithSimpleForStringIsCalled.cs new file mode 100644 index 0000000..7833ea8 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForStringTests/WhenInequalityOperatorWithSimpleForStringIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Simple.SimpleForStringTests; + +public static class WhenInequalityOperatorWithSimpleForStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + SimpleForString left = new(SampleValue); + SimpleForString right = new(SampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + SimpleForString left = new(SampleValue); + SimpleForString right = new(DifferentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Simple/SimpleForStringTests/WhenInequalityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForStringTests/WhenInequalityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..b32138e --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForStringTests/WhenInequalityOperatorWithStringIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Simple.SimpleForStringTests; + +public static class WhenInequalityOperatorWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + SimpleForString? subject = default; + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + SimpleForString subject = new(SampleValue); + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + SimpleForString subject = new(SampleValue); + + // Act + bool actual = subject != DifferentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Simple/SimpleForStringTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForStringTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..94cf9ec --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForStringTests/WhenToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Simple.SimpleForStringTests; + +public static class WhenToStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenReturnRecordDescription() + { + // Arrange + SimpleForString subject = new(SampleValue); + + // Act + string actual = subject.ToString(); + + // Assert + actual.ShouldBe("SimpleForString { }"); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..4c087ec --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForArrayTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForArray.Inner instance = new(_sampleValue); + + // Act + int[] actual = instance; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..de2cbab --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForArrayTests.InnerTests; + +public static class WhenEqualityOperatorWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForArray.Inner? subject = default; + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _differentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..4e54acd --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForArrayTests.InnerTests; + +public static class WhenEqualityOperatorWithOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForArray.Inner? left = default; + OutterForArray.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForArray.Inner? left = default; + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs new file mode 100644 index 0000000..812aef2 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForArrayTests.InnerTests; + +public static class WhenEqualsWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_sampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_differentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..268c28d --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForArrayTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenNullThenThrowNullReferenceException() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + Action act = () => subject.Equals((object?)default); + + // Assert + _ = Should.Throw(act); + } + + [Fact] + public static void GivenEquivalentOutterForArrayInnerThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + object other = new OutterForArray.Inner(_sampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + object other = string.Empty; + + // Act + Action act = () => subject.Equals(other); + + // Assert + _ = Should.Throw(act); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..9e7e353 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/InnerTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForArrayTests.InnerTests; + +public static class WhenEqualsWithOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..d6e1ca6 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForArrayTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private static readonly int[] _firstValue = [7, 8, 9]; + private static readonly int[] _secondValue = [10, 11, 12]; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForArray.Inner first = new(_firstValue); + OutterForArray.Inner second = new(_firstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForArray.Inner first = new(_firstValue); + OutterForArray.Inner second = new(_secondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs new file mode 100644 index 0000000..66a7536 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForArrayTests.InnerTests; + +public static class WhenImplicitOperatorFromIntArrayIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForArray.Inner result = _sampleValue; + + // Act + int[] actual = result; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs new file mode 100644 index 0000000..74fbd36 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForArrayTests.InnerTests; + +public static class WhenImplicitOperatorToIntArrayIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + int[] actual = subject; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..bd1b317 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForArrayTests.InnerTests; + +public static class WhenInequalityOperatorWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForArray.Inner? subject = default; + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _differentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..f919007 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForArrayTests.InnerTests; + +public static class WhenInequalityOperatorWithOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..0bfb647 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForArrayTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private const string Expected = "Inner { System.Int32[] }"; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + string result = subject.ToString(); + + // Assert + result.ShouldBe(Expected); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..047d178 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForIntTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForInt.Inner instance = new(SampleValue); + + // Act + int actual = instance; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..964202e --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForIntTests.InnerTests; + +public static class WhenEqualityOperatorWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForInt.Inner? subject = default; + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject == DifferentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..3a513e4 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForIntTests.InnerTests; + +public static class WhenEqualityOperatorWithOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForInt.Inner? left = default; + OutterForInt.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForInt.Inner? left = default; + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs new file mode 100644 index 0000000..43d462c --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForIntTests.InnerTests; + +public static class WhenEqualsWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(SampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(DifferentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..9b53ce4 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForIntTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenNullThenThrowNullReferenceException() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + Action act = () => subject.Equals((object?)default); + + // Assert + _ = Should.Throw(act); + } + + [Fact] + public static void GivenEquivalentOutterForIntInnerThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + object other = new OutterForInt.Inner(SampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + object other = string.Empty; + + // Act + Action act = () => subject.Equals(other); + + // Assert + _ = Should.Throw(act); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualsWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualsWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..ab8a8cd --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/InnerTests/WhenEqualsWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForIntTests.InnerTests; + +public static class WhenEqualsWithOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..28a8a8a --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForIntTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private const int FirstValue = 5; + private const int SecondValue = 9; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForInt.Inner first = new(FirstValue); + OutterForInt.Inner second = new(FirstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForInt.Inner first = new(FirstValue); + OutterForInt.Inner second = new(SecondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs new file mode 100644 index 0000000..aa27b6c --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForIntTests.InnerTests; + +public static class WhenImplicitOperatorFromIntIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForInt.Inner result = SampleValue; + + // Act + int actual = result; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs new file mode 100644 index 0000000..d6754a4 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForIntTests.InnerTests; + +public static class WhenImplicitOperatorToIntIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + int actual = subject; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..86a4418 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForIntTests.InnerTests; + +public static class WhenInequalityOperatorWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForInt.Inner? subject = default; + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject != DifferentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/InnerTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/InnerTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..8e5d066 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/InnerTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForIntTests.InnerTests; + +public static class WhenInequalityOperatorWithOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..b5b94da --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForIntTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private const string Expected = "Inner { 42 }"; + private const int SampleValue = 42; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + string result = subject.ToString(); + + // Assert + result.ShouldBe(Expected); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..c3aedbf --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForStringTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForString.Inner instance = new(SampleValue); + + // Act + string actual = instance; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..7d092e3 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForStringTests.InnerTests; + +public static class WhenEqualityOperatorWithOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForString.Inner? left = default; + OutterForString.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForString.Inner? left = default; + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..e3f9b19 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForStringTests.InnerTests; + +public static class WhenEqualityOperatorWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForString.Inner? subject = default; + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject == DifferentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..8dd6ac0 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForStringTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenNullThenThrowNullReferenceException() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + Action act = () => subject.Equals((object?)default); + + // Assert + _ = Should.Throw(act); + } + + [Fact] + public static void GivenEquivalentOutterForStringInnerThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + object other = new OutterForString.Inner(SampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + object other = string.Empty; + + // Act + Action act = () => subject.Equals(other); + + // Assert + _ = Should.Throw(act); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualsWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualsWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..2c60288 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualsWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForStringTests.InnerTests; + +public static class WhenEqualsWithOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs new file mode 100644 index 0000000..b1a44c6 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForStringTests.InnerTests; + +public static class WhenEqualsWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(SampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(DifferentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..3829ec0 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForStringTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private const string FirstValue = "Alpha"; + private const string SecondValue = "Beta"; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForString.Inner first = new(FirstValue); + OutterForString.Inner second = new(FirstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForString.Inner first = new(FirstValue); + OutterForString.Inner second = new(SecondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs new file mode 100644 index 0000000..06d1bac --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForStringTests.InnerTests; + +public static class WhenImplicitOperatorFromStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForString.Inner result = SampleValue; + + // Act + string actual = result; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs new file mode 100644 index 0000000..55adaa0 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForStringTests.InnerTests; + +public static class WhenImplicitOperatorToStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + string actual = subject; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/InnerTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/InnerTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..db55729 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/InnerTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForStringTests.InnerTests; + +public static class WhenInequalityOperatorWithOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..1b378e4 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForStringTests.InnerTests; + +public static class WhenInequalityOperatorWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForString.Inner? subject = default; + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject != DifferentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..30b5bb8 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForStringTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private const string Expected = $"Inner {{ {SampleValue} }}"; + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + string result = subject.ToString(); + + // Assert + result.ShouldBe(Expected); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..957163d --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForArrayTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + IOutterForArray.Inner instance = new(_sampleValue); + + // Act + int[] actual = instance; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualityOperatorWithIOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualityOperatorWithIOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..ceaf799 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualityOperatorWithIOutterForArrayInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForArrayTests.InnerTests; + +public static class WhenEqualityOperatorWithIOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + IOutterForArray.Inner? left = default; + IOutterForArray.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + IOutterForArray.Inner? left = default; + IOutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForArray.Inner left = new(_sampleValue); + IOutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + IOutterForArray.Inner left = new(_sampleValue); + IOutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..fdd9f1c --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForArrayTests.InnerTests; + +public static class WhenEqualityOperatorWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + IOutterForArray.Inner? subject = default; + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + IOutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _differentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualsWithIOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualsWithIOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..852a4b5 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualsWithIOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForArrayTests.InnerTests; + +public static class WhenEqualsWithIOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForArray.Inner left = new(_sampleValue); + IOutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + IOutterForArray.Inner left = new(_sampleValue); + IOutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs new file mode 100644 index 0000000..937b0b4 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForArrayTests.InnerTests; + +public static class WhenEqualsWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_sampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + IOutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_differentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..149e0ac --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForArrayTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenNullThenThrowNullReferenceException() + { + // Arrange + IOutterForArray.Inner subject = new(_sampleValue); + + // Act + Action act = () => subject.Equals((object?)default); + + // Assert + _ = Should.Throw(act); + } + + [Fact] + public static void GivenEquivalentIOutterForArrayInnerThenReturnTrue() + { + // Arrange + IOutterForArray.Inner subject = new(_sampleValue); + object other = new IOutterForArray.Inner(_sampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + IOutterForArray.Inner subject = new(_sampleValue); + object other = string.Empty; + + // Act + Action act = () => subject.Equals(other); + + // Assert + _ = Should.Throw(act); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..2c13a63 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForArrayTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private static readonly int[] _firstValue = [7, 8, 9]; + private static readonly int[] _secondValue = [10, 11, 12]; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + IOutterForArray.Inner first = new(_firstValue); + IOutterForArray.Inner second = new(_firstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + IOutterForArray.Inner first = new(_firstValue); + IOutterForArray.Inner second = new(_secondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs new file mode 100644 index 0000000..179a01d --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForArrayTests.InnerTests; + +public static class WhenImplicitOperatorFromIntArrayIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + IOutterForArray.Inner result = _sampleValue; + + // Act + int[] actual = result; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs new file mode 100644 index 0000000..2d89b36 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForArrayTests.InnerTests; + +public static class WhenImplicitOperatorToIntArrayIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + IOutterForArray.Inner subject = new(_sampleValue); + + // Act + int[] actual = subject; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenInequalityOperatorWithIOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenInequalityOperatorWithIOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..c731d48 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenInequalityOperatorWithIOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForArrayTests.InnerTests; + +public static class WhenInequalityOperatorWithIOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + IOutterForArray.Inner left = new(_sampleValue); + IOutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + IOutterForArray.Inner left = new(_sampleValue); + IOutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..8916528 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForArrayTests.InnerTests; + +public static class WhenInequalityOperatorWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + IOutterForArray.Inner? subject = default; + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + IOutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + IOutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _differentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..512e591 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForArrayTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private const string Expected = "Inner { System.Int32[] }"; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + IOutterForArray.Inner subject = new(_sampleValue); + + // Act + string result = subject.ToString(); + + // Assert + result.ShouldBe(Expected); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..9d43595 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForIntTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + IOutterForInt.Inner instance = new(SampleValue); + + // Act + int actual = instance; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualityOperatorWithIOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualityOperatorWithIOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..fc7da0e --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualityOperatorWithIOutterForIntInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForIntTests.InnerTests; + +public static class WhenEqualityOperatorWithIOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + IOutterForInt.Inner? left = default; + IOutterForInt.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + IOutterForInt.Inner? left = default; + IOutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForInt.Inner left = new(SampleValue); + IOutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + IOutterForInt.Inner left = new(SampleValue); + IOutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..5dcda31 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForIntTests.InnerTests; + +public static class WhenEqualityOperatorWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + IOutterForInt.Inner? subject = default; + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + IOutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject == DifferentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualsWithIOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualsWithIOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..f2e8d95 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualsWithIOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForIntTests.InnerTests; + +public static class WhenEqualsWithIOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForInt.Inner left = new(SampleValue); + IOutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + IOutterForInt.Inner left = new(SampleValue); + IOutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs new file mode 100644 index 0000000..ec5d9b3 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForIntTests.InnerTests; + +public static class WhenEqualsWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(SampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + IOutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(DifferentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..9a853a0 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForIntTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenNullThenThrowNullReferenceException() + { + // Arrange + IOutterForInt.Inner subject = new(SampleValue); + + // Act + Action act = () => subject.Equals((object?)default); + + // Assert + _ = Should.Throw(act); + } + + [Fact] + public static void GivenEquivalentIOutterForIntInnerThenReturnTrue() + { + // Arrange + IOutterForInt.Inner subject = new(SampleValue); + object other = new IOutterForInt.Inner(SampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + IOutterForInt.Inner subject = new(SampleValue); + object other = string.Empty; + + // Act + Action act = () => subject.Equals(other); + + // Assert + _ = Should.Throw(act); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..76a68e3 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForIntTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private const int FirstValue = 5; + private const int SecondValue = 9; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + IOutterForInt.Inner first = new(FirstValue); + IOutterForInt.Inner second = new(FirstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + IOutterForInt.Inner first = new(FirstValue); + IOutterForInt.Inner second = new(SecondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs new file mode 100644 index 0000000..b1b8504 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForIntTests.InnerTests; + +public static class WhenImplicitOperatorFromIntIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + IOutterForInt.Inner result = SampleValue; + + // Act + int actual = result; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs new file mode 100644 index 0000000..2424dc1 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForIntTests.InnerTests; + +public static class WhenImplicitOperatorToIntIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + IOutterForInt.Inner subject = new(SampleValue); + + // Act + int actual = subject; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/InnerTests/WhenInequalityOperatorWithIOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/InnerTests/WhenInequalityOperatorWithIOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..47bc50d --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/InnerTests/WhenInequalityOperatorWithIOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForIntTests.InnerTests; + +public static class WhenInequalityOperatorWithIOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + IOutterForInt.Inner left = new(SampleValue); + IOutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + IOutterForInt.Inner left = new(SampleValue); + IOutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..19d63a8 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForIntTests.InnerTests; + +public static class WhenInequalityOperatorWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + IOutterForInt.Inner? subject = default; + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + IOutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + IOutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject != DifferentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..401aa58 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForIntTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private const string Expected = "Inner { 42 }"; + private const int SampleValue = 42; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + IOutterForInt.Inner subject = new(SampleValue); + + // Act + string result = subject.ToString(); + + // Assert + result.ShouldBe(Expected); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..82a8d24 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForStringTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + IOutterForString.Inner instance = new(SampleValue); + + // Act + string actual = instance; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualityOperatorWithIOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualityOperatorWithIOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..6b01cd3 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualityOperatorWithIOutterForStringInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForStringTests.InnerTests; + +public static class WhenEqualityOperatorWithIOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + IOutterForString.Inner? left = default; + IOutterForString.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + IOutterForString.Inner? left = default; + IOutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForString.Inner left = new(SampleValue); + IOutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + IOutterForString.Inner left = new(SampleValue); + IOutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..adb0f36 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForStringTests.InnerTests; + +public static class WhenEqualityOperatorWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + IOutterForString.Inner? subject = default; + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + IOutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject == DifferentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualsWithIOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualsWithIOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..6afc267 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualsWithIOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForStringTests.InnerTests; + +public static class WhenEqualsWithIOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForString.Inner left = new(SampleValue); + IOutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + IOutterForString.Inner left = new(SampleValue); + IOutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..83a75ec --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForStringTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenNullThenThrowNullReferenceException() + { + // Arrange + IOutterForString.Inner subject = new(SampleValue); + + // Act + Action act = () => subject.Equals((object?)default); + + // Assert + _ = Should.Throw(act); + } + + [Fact] + public static void GivenEquivalentIOutterForStringInnerThenReturnTrue() + { + // Arrange + IOutterForString.Inner subject = new(SampleValue); + object other = new IOutterForString.Inner(SampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + IOutterForString.Inner subject = new(SampleValue); + object other = string.Empty; + + // Act + Action act = () => subject.Equals(other); + + // Assert + _ = Should.Throw(act); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs new file mode 100644 index 0000000..7f40f80 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForStringTests.InnerTests; + +public static class WhenEqualsWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(SampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + IOutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(DifferentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..2c829c2 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForStringTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private const string FirstValue = "Alpha"; + private const string SecondValue = "Beta"; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + IOutterForString.Inner first = new(FirstValue); + IOutterForString.Inner second = new(FirstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + IOutterForString.Inner first = new(FirstValue); + IOutterForString.Inner second = new(SecondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs new file mode 100644 index 0000000..72bcfa2 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForStringTests.InnerTests; + +public static class WhenImplicitOperatorFromStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + IOutterForString.Inner result = SampleValue; + + // Act + string actual = result; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs new file mode 100644 index 0000000..9417ac8 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForStringTests.InnerTests; + +public static class WhenImplicitOperatorToStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + IOutterForString.Inner subject = new(SampleValue); + + // Act + string actual = subject; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/InnerTests/WhenInequalityOperatorWithIOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/InnerTests/WhenInequalityOperatorWithIOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..005ba1c --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/InnerTests/WhenInequalityOperatorWithIOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForStringTests.InnerTests; + +public static class WhenInequalityOperatorWithIOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + IOutterForString.Inner left = new(SampleValue); + IOutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + IOutterForString.Inner left = new(SampleValue); + IOutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..de89eec --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForStringTests.InnerTests; + +public static class WhenInequalityOperatorWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + IOutterForString.Inner? subject = default; + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + IOutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + IOutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject != DifferentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..8dc363b --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForStringTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private const string Expected = $"Inner {{ {SampleValue} }}"; + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + IOutterForString.Inner subject = new(SampleValue); + + // Act + string result = subject.ToString(); + + // Assert + result.ShouldBe(Expected); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..685b3f1 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForArrayTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForArray.Inner instance = new(_sampleValue); + + // Act + int[] actual = instance; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..46b4376 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForArrayTests.InnerTests; + +public static class WhenEqualityOperatorWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForArray.Inner? subject = default; + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _differentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..330ab6a --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForArrayTests.InnerTests; + +public static class WhenEqualityOperatorWithOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForArray.Inner? left = default; + OutterForArray.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForArray.Inner? left = default; + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs new file mode 100644 index 0000000..676bd85 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForArrayTests.InnerTests; + +public static class WhenEqualsWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_sampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_differentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..d38ef74 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForArrayTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenNullThenThrowNullReferenceException() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + Action act = () => subject.Equals((object?)default); + + // Assert + _ = Should.Throw(act); + } + + [Fact] + public static void GivenEquivalentOutterForArrayInnerThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + object other = new OutterForArray.Inner(_sampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + object other = string.Empty; + + // Act + Action act = () => subject.Equals(other); + + // Assert + _ = Should.Throw(act); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..d9eb62c --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/InnerTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForArrayTests.InnerTests; + +public static class WhenEqualsWithOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..31b6741 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForArrayTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private static readonly int[] _firstValue = [7, 8, 9]; + private static readonly int[] _secondValue = [10, 11, 12]; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForArray.Inner first = new(_firstValue); + OutterForArray.Inner second = new(_firstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForArray.Inner first = new(_firstValue); + OutterForArray.Inner second = new(_secondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs new file mode 100644 index 0000000..87dd862 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForArrayTests.InnerTests; + +public static class WhenImplicitOperatorFromIntArrayIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForArray.Inner result = _sampleValue; + + // Act + int[] actual = result; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs new file mode 100644 index 0000000..1436569 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForArrayTests.InnerTests; + +public static class WhenImplicitOperatorToIntArrayIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + int[] actual = subject; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..9395098 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForArrayTests.InnerTests; + +public static class WhenInequalityOperatorWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForArray.Inner? subject = default; + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _differentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..d5c206a --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForArrayTests.InnerTests; + +public static class WhenInequalityOperatorWithOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..320bc66 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForArrayTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private const string Expected = "Inner { System.Int32[] }"; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + string result = subject.ToString(); + + // Assert + result.ShouldBe(Expected); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..72aff7e --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForIntTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForInt.Inner instance = new(SampleValue); + + // Act + int actual = instance; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..d44224d --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForIntTests.InnerTests; + +public static class WhenEqualityOperatorWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForInt.Inner? subject = default; + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject == DifferentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..970ce3d --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForIntTests.InnerTests; + +public static class WhenEqualityOperatorWithOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForInt.Inner? left = default; + OutterForInt.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForInt.Inner? left = default; + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs new file mode 100644 index 0000000..bd56fa4 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForIntTests.InnerTests; + +public static class WhenEqualsWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(SampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(DifferentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..2a1f6f8 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForIntTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenNullThenThrowNullReferenceException() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + Action act = () => subject.Equals((object?)default); + + // Assert + _ = Should.Throw(act); + } + + [Fact] + public static void GivenEquivalentOutterForIntInnerThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + object other = new OutterForInt.Inner(SampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + object other = string.Empty; + + // Act + Action act = () => subject.Equals(other); + + // Assert + _ = Should.Throw(act); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualsWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualsWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..8c1d0b7 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/InnerTests/WhenEqualsWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForIntTests.InnerTests; + +public static class WhenEqualsWithOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..6d445f0 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForIntTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private const int FirstValue = 5; + private const int SecondValue = 9; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForInt.Inner first = new(FirstValue); + OutterForInt.Inner second = new(FirstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForInt.Inner first = new(FirstValue); + OutterForInt.Inner second = new(SecondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs new file mode 100644 index 0000000..794940d --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForIntTests.InnerTests; + +public static class WhenImplicitOperatorFromIntIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForInt.Inner result = SampleValue; + + // Act + int actual = result; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs new file mode 100644 index 0000000..7e71347 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForIntTests.InnerTests; + +public static class WhenImplicitOperatorToIntIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + int actual = subject; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..d48ae85 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForIntTests.InnerTests; + +public static class WhenInequalityOperatorWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForInt.Inner? subject = default; + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject != DifferentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/InnerTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/InnerTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..d09575a --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/InnerTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForIntTests.InnerTests; + +public static class WhenInequalityOperatorWithOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..5af58cb --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForIntTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private const string Expected = "Inner { 42 }"; + private const int SampleValue = 42; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + string result = subject.ToString(); + + // Assert + result.ShouldBe(Expected); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..fa8d3e0 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForStringTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForString.Inner instance = new(SampleValue); + + // Act + string actual = instance; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..aaa3c3f --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForStringTests.InnerTests; + +public static class WhenEqualityOperatorWithOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForString.Inner? left = default; + OutterForString.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForString.Inner? left = default; + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..00c20ba --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForStringTests.InnerTests; + +public static class WhenEqualityOperatorWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForString.Inner? subject = default; + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject == DifferentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..1207dfe --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForStringTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenNullThenThrowNullReferenceException() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + Action act = () => subject.Equals((object?)default); + + // Assert + _ = Should.Throw(act); + } + + [Fact] + public static void GivenEquivalentOutterForStringInnerThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + object other = new OutterForString.Inner(SampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + object other = string.Empty; + + // Act + Action act = () => subject.Equals(other); + + // Assert + _ = Should.Throw(act); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualsWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualsWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..fc94faf --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualsWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForStringTests.InnerTests; + +public static class WhenEqualsWithOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs new file mode 100644 index 0000000..595c618 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForStringTests.InnerTests; + +public static class WhenEqualsWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(SampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(DifferentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..9712e65 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForStringTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private const string FirstValue = "Alpha"; + private const string SecondValue = "Beta"; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForString.Inner first = new(FirstValue); + OutterForString.Inner second = new(FirstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForString.Inner first = new(FirstValue); + OutterForString.Inner second = new(SecondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs new file mode 100644 index 0000000..a4d8e62 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForStringTests.InnerTests; + +public static class WhenImplicitOperatorFromStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForString.Inner result = SampleValue; + + // Act + string actual = result; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs new file mode 100644 index 0000000..eaaf8f5 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForStringTests.InnerTests; + +public static class WhenImplicitOperatorToStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + string actual = subject; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/InnerTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/InnerTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..7bc8fe3 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/InnerTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForStringTests.InnerTests; + +public static class WhenInequalityOperatorWithOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..3e997e1 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForStringTests.InnerTests; + +public static class WhenInequalityOperatorWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForString.Inner? subject = default; + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject != DifferentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..e627b6d --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForStringTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private const string Expected = $"Inner {{ {SampleValue} }}"; + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + string result = subject.ToString(); + + // Assert + result.ShouldBe(Expected); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..d4b1c87 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForArrayTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForArray.Inner instance = new(_sampleValue); + + // Act + int[] actual = instance; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..3c711ee --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForArrayTests.InnerTests; + +public static class WhenEqualityOperatorWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForArray.Inner? subject = default; + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _differentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..6deeee9 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForArrayTests.InnerTests; + +public static class WhenEqualityOperatorWithOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForArray.Inner? left = default; + OutterForArray.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForArray.Inner? left = default; + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs new file mode 100644 index 0000000..8cfe647 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForArrayTests.InnerTests; + +public static class WhenEqualsWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_sampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_differentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..839ce9d --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForArrayTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenNullThenThrowNullReferenceException() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + Action act = () => subject.Equals((object?)default); + + // Assert + _ = Should.Throw(act); + } + + [Fact] + public static void GivenEquivalentOutterForArrayInnerThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + object other = new OutterForArray.Inner(_sampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + object other = string.Empty; + + // Act + Action act = () => subject.Equals(other); + + // Assert + _ = Should.Throw(act); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..3721ef8 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForArrayTests.InnerTests; + +public static class WhenEqualsWithOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..c29292f --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForArrayTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private static readonly int[] _firstValue = [7, 8, 9]; + private static readonly int[] _secondValue = [10, 11, 12]; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForArray.Inner first = new(_firstValue); + OutterForArray.Inner second = new(_firstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForArray.Inner first = new(_firstValue); + OutterForArray.Inner second = new(_secondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs new file mode 100644 index 0000000..e3ae9ef --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForArrayTests.InnerTests; + +public static class WhenImplicitOperatorFromIntArrayIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForArray.Inner result = _sampleValue; + + // Act + int[] actual = result; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs new file mode 100644 index 0000000..b4265d0 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForArrayTests.InnerTests; + +public static class WhenImplicitOperatorToIntArrayIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + int[] actual = subject; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..9b5506f --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForArrayTests.InnerTests; + +public static class WhenInequalityOperatorWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForArray.Inner? subject = default; + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _differentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..0659efc --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForArrayTests.InnerTests; + +public static class WhenInequalityOperatorWithOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..93f5164 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForArrayTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private const string Expected = "Inner { System.Int32[] }"; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + string result = subject.ToString(); + + // Assert + result.ShouldBe(Expected); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..e6ccc7d --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForIntTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForInt.Inner instance = new(SampleValue); + + // Act + int actual = instance; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..b5df8e9 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForIntTests.InnerTests; + +public static class WhenEqualityOperatorWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForInt.Inner? subject = default; + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject == DifferentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..e1b25e2 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForIntTests.InnerTests; + +public static class WhenEqualityOperatorWithOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForInt.Inner? left = default; + OutterForInt.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForInt.Inner? left = default; + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs new file mode 100644 index 0000000..38f8117 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForIntTests.InnerTests; + +public static class WhenEqualsWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(SampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(DifferentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..ab798ec --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForIntTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenNullThenThrowNullReferenceException() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + Action act = () => subject.Equals((object?)default); + + // Assert + _ = Should.Throw(act); + } + + [Fact] + public static void GivenEquivalentOutterForIntInnerThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + object other = new OutterForInt.Inner(SampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + object other = string.Empty; + + // Act + Action act = () => subject.Equals(other); + + // Assert + _ = Should.Throw(act); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualsWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualsWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..9ae6a48 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenEqualsWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForIntTests.InnerTests; + +public static class WhenEqualsWithOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..dc7544b --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForIntTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private const int FirstValue = 5; + private const int SecondValue = 9; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForInt.Inner first = new(FirstValue); + OutterForInt.Inner second = new(FirstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForInt.Inner first = new(FirstValue); + OutterForInt.Inner second = new(SecondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs new file mode 100644 index 0000000..e941552 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForIntTests.InnerTests; + +public static class WhenImplicitOperatorFromIntIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForInt.Inner result = SampleValue; + + // Act + int actual = result; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs new file mode 100644 index 0000000..1906b93 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForIntTests.InnerTests; + +public static class WhenImplicitOperatorToIntIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + int actual = subject; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..2ca6d86 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForIntTests.InnerTests; + +public static class WhenInequalityOperatorWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForInt.Inner? subject = default; + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject != DifferentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..ae7f9ab --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForIntTests.InnerTests; + +public static class WhenInequalityOperatorWithOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..9d3ea15 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForIntTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private const string Expected = "Inner { 42 }"; + private const int SampleValue = 42; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + string result = subject.ToString(); + + // Assert + result.ShouldBe(Expected); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..dac03f4 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForStringTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForString.Inner instance = new(SampleValue); + + // Act + string actual = instance; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..5b1ee73 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForStringTests.InnerTests; + +public static class WhenEqualityOperatorWithOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForString.Inner? left = default; + OutterForString.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForString.Inner? left = default; + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..b025a0a --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForStringTests.InnerTests; + +public static class WhenEqualityOperatorWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForString.Inner? subject = default; + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject == DifferentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..dfd4da9 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForStringTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenNullThenThrowNullReferenceException() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + Action act = () => subject.Equals((object?)default); + + // Assert + _ = Should.Throw(act); + } + + [Fact] + public static void GivenEquivalentOutterForStringInnerThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + object other = new OutterForString.Inner(SampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + object other = string.Empty; + + // Act + Action act = () => subject.Equals(other); + + // Assert + _ = Should.Throw(act); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualsWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualsWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..4e84d77 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualsWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForStringTests.InnerTests; + +public static class WhenEqualsWithOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs new file mode 100644 index 0000000..e0d3e08 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForStringTests.InnerTests; + +public static class WhenEqualsWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(SampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(DifferentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..23766e9 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForStringTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private const string FirstValue = "Alpha"; + private const string SecondValue = "Beta"; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForString.Inner first = new(FirstValue); + OutterForString.Inner second = new(FirstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForString.Inner first = new(FirstValue); + OutterForString.Inner second = new(SecondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs new file mode 100644 index 0000000..f3aaa50 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForStringTests.InnerTests; + +public static class WhenImplicitOperatorFromStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForString.Inner result = SampleValue; + + // Act + string actual = result; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs new file mode 100644 index 0000000..37b3613 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForStringTests.InnerTests; + +public static class WhenImplicitOperatorToStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + string actual = subject; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..12803a3 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForStringTests.InnerTests; + +public static class WhenInequalityOperatorWithOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..c331187 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForStringTests.InnerTests; + +public static class WhenInequalityOperatorWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForString.Inner? subject = default; + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject != DifferentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..26cf28b --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForStringTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private const string Expected = $"Inner {{ {SampleValue} }}"; + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + string result = subject.ToString(); + + // Assert + result.ShouldBe(Expected); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..28ff4a5 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForArrayTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForArray.Inner instance = new(_sampleValue); + + // Act + int[] actual = instance; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..005ffb9 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForArrayTests.InnerTests; + +public static class WhenEqualityOperatorWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForArray.Inner? subject = default; + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _differentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..d4d22fc --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForArrayTests.InnerTests; + +public static class WhenEqualityOperatorWithOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForArray.Inner? left = default; + OutterForArray.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForArray.Inner? left = default; + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs new file mode 100644 index 0000000..23fa17d --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualsWithIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForArrayTests.InnerTests; + +public static class WhenEqualsWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_sampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_differentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..7168f05 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForArrayTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenNullThenThrowNullReferenceException() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + Action act = () => subject.Equals((object?)default); + + // Assert + _ = Should.Throw(act); + } + + [Fact] + public static void GivenEquivalentOutterForArrayInnerThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + object other = new OutterForArray.Inner(_sampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + object other = string.Empty; + + // Act + Action act = () => subject.Equals(other); + + // Assert + _ = Should.Throw(act); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..0ac51c6 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/InnerTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForArrayTests.InnerTests; + +public static class WhenEqualsWithOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..b95ea35 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForArrayTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private static readonly int[] _firstValue = [7, 8, 9]; + private static readonly int[] _secondValue = [10, 11, 12]; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForArray.Inner first = new(_firstValue); + OutterForArray.Inner second = new(_firstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForArray.Inner first = new(_firstValue); + OutterForArray.Inner second = new(_secondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs new file mode 100644 index 0000000..2bbb495 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/InnerTests/WhenImplicitOperatorFromIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForArrayTests.InnerTests; + +public static class WhenImplicitOperatorFromIntArrayIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForArray.Inner result = _sampleValue; + + // Act + int[] actual = result; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs new file mode 100644 index 0000000..8a62d6c --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/InnerTests/WhenImplicitOperatorToIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForArrayTests.InnerTests; + +public static class WhenImplicitOperatorToIntArrayIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + int[] actual = subject; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..3ff898c --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForArrayTests.InnerTests; + +public static class WhenInequalityOperatorWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForArray.Inner? subject = default; + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _differentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..b5e5bfa --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/InnerTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForArrayTests.InnerTests; + +public static class WhenInequalityOperatorWithOutterForArrayInnerIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_sampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForArray.Inner left = new(_sampleValue); + OutterForArray.Inner right = new(_differentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..8ecb142 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForArrayTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private const string Expected = "Inner { System.Int32[] }"; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + OutterForArray.Inner subject = new(_sampleValue); + + // Act + string result = subject.ToString(); + + // Assert + result.ShouldBe(Expected); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..d480490 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForIntTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForInt.Inner instance = new(SampleValue); + + // Act + int actual = instance; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..d5d26e9 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForIntTests.InnerTests; + +public static class WhenEqualityOperatorWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForInt.Inner? subject = default; + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject == DifferentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..535a0f2 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForIntTests.InnerTests; + +public static class WhenEqualityOperatorWithOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForInt.Inner? left = default; + OutterForInt.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForInt.Inner? left = default; + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs new file mode 100644 index 0000000..e1ae1ee --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualsWithIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForIntTests.InnerTests; + +public static class WhenEqualsWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(SampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(DifferentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..71d4148 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForIntTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenNullThenThrowNullReferenceException() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + Action act = () => subject.Equals((object?)default); + + // Assert + _ = Should.Throw(act); + } + + [Fact] + public static void GivenEquivalentOutterForIntInnerThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + object other = new OutterForInt.Inner(SampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + object other = string.Empty; + + // Act + Action act = () => subject.Equals(other); + + // Assert + _ = Should.Throw(act); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualsWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualsWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..69ea5f1 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/InnerTests/WhenEqualsWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForIntTests.InnerTests; + +public static class WhenEqualsWithOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..6f858a3 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForIntTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private const int FirstValue = 5; + private const int SecondValue = 9; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForInt.Inner first = new(FirstValue); + OutterForInt.Inner second = new(FirstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForInt.Inner first = new(FirstValue); + OutterForInt.Inner second = new(SecondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs new file mode 100644 index 0000000..c4860df --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/InnerTests/WhenImplicitOperatorFromIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForIntTests.InnerTests; + +public static class WhenImplicitOperatorFromIntIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForInt.Inner result = SampleValue; + + // Act + int actual = result; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs new file mode 100644 index 0000000..338894e --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/InnerTests/WhenImplicitOperatorToIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForIntTests.InnerTests; + +public static class WhenImplicitOperatorToIntIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + int actual = subject; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..c04c18f --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/InnerTests/WhenInequalityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForIntTests.InnerTests; + +public static class WhenInequalityOperatorWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForInt.Inner? subject = default; + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + bool actual = subject != DifferentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/InnerTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/InnerTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..1b1b1f4 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/InnerTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForIntTests.InnerTests; + +public static class WhenInequalityOperatorWithOutterForIntInnerIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(SampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForInt.Inner left = new(SampleValue); + OutterForInt.Inner right = new(DifferentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..e742f9c --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForIntTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private const string Expected = "Inner { 42 }"; + private const int SampleValue = 42; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + OutterForInt.Inner subject = new(SampleValue); + + // Act + string result = subject.ToString(); + + // Assert + result.ShouldBe(Expected); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/InnerTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/InnerTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..6b1b911 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/InnerTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForStringTests.InnerTests; + +public static class WhenConstructorIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForString.Inner instance = new(SampleValue); + + // Act + string actual = instance; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..4356e07 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForStringTests.InnerTests; + +public static class WhenEqualityOperatorWithOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForString.Inner? left = default; + OutterForString.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForString.Inner? left = default; + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..9a5fbb7 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualityOperatorWithStringIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForStringTests.InnerTests; + +public static class WhenEqualityOperatorWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForString.Inner? subject = default; + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject == DifferentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..ec2c7b1 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForStringTests.InnerTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenNullThenThrowNullReferenceException() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + Action act = () => subject.Equals((object?)default); + + // Assert + _ = Should.Throw(act); + } + + [Fact] + public static void GivenEquivalentOutterForStringInnerThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + object other = new OutterForString.Inner(SampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + object other = string.Empty; + + // Act + Action act = () => subject.Equals(other); + + // Assert + _ = Should.Throw(act); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualsWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualsWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..c400784 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualsWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForStringTests.InnerTests; + +public static class WhenEqualsWithOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs new file mode 100644 index 0000000..8bd63c6 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/InnerTests/WhenEqualsWithStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForStringTests.InnerTests; + +public static class WhenEqualsWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(SampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject.Equals(DifferentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..27a9815 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/InnerTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForStringTests.InnerTests; + +public static class WhenGetHashCodeIsCalled +{ + private const string FirstValue = "Alpha"; + private const string SecondValue = "Beta"; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForString.Inner first = new(FirstValue); + OutterForString.Inner second = new(FirstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForString.Inner first = new(FirstValue); + OutterForString.Inner second = new(SecondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs new file mode 100644 index 0000000..435819b --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/InnerTests/WhenImplicitOperatorFromStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForStringTests.InnerTests; + +public static class WhenImplicitOperatorFromStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForString.Inner result = SampleValue; + + // Act + string actual = result; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs new file mode 100644 index 0000000..242d81e --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/InnerTests/WhenImplicitOperatorToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForStringTests.InnerTests; + +public static class WhenImplicitOperatorToStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + string actual = subject; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/InnerTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/InnerTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..d5e5ddf --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/InnerTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForStringTests.InnerTests; + +public static class WhenInequalityOperatorWithOutterForStringInnerIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(SampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForString.Inner left = new(SampleValue); + OutterForString.Inner right = new(DifferentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..27bbbef --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/InnerTests/WhenInequalityOperatorWithStringIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForStringTests.InnerTests; + +public static class WhenInequalityOperatorWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForString.Inner? subject = default; + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + bool actual = subject != DifferentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/InnerTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/InnerTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..3ec40bc --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/InnerTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForStringTests.InnerTests; + +public static class WhenToStringIsCalled +{ + private const string Expected = $"Inner {{ {SampleValue} }}"; + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + OutterForString.Inner subject = new(SampleValue); + + // Act + string result = subject.ToString(); + + // Assert + result.ShouldBe(Expected); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Simple/SimpleForArrayTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForArrayTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..e9eacba --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForArrayTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Simple.SimpleForArrayTests; + +public static class WhenConstructorIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + SimpleForArray instance = new(_sampleValue); + + // Act + int[] actual = instance; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Simple/SimpleForArrayTests/WhenEqualityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForArrayTests/WhenEqualityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..9359272 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForArrayTests/WhenEqualityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Simple.SimpleForArrayTests; + +public static class WhenEqualityOperatorWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + SimpleForArray? subject = default; + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForArray subject = new(_sampleValue); + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + SimpleForArray subject = new(_sampleValue); + + // Act + bool actual = subject == _differentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Simple/SimpleForArrayTests/WhenEqualityOperatorWithSimpleForArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForArrayTests/WhenEqualityOperatorWithSimpleForArrayIsCalled.cs new file mode 100644 index 0000000..0197492 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForArrayTests/WhenEqualityOperatorWithSimpleForArrayIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Structs.Simple.SimpleForArrayTests; + +public static class WhenEqualityOperatorWithSimpleForArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + SimpleForArray? left = default; + SimpleForArray? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + SimpleForArray? left = default; + SimpleForArray right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForArray left = new(_sampleValue); + SimpleForArray right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + SimpleForArray left = new(_sampleValue); + SimpleForArray right = new(_differentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Simple/SimpleForArrayTests/WhenEqualsWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForArrayTests/WhenEqualsWithIntArrayIsCalled.cs new file mode 100644 index 0000000..3dbfae7 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForArrayTests/WhenEqualsWithIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Structs.Simple.SimpleForArrayTests; + +public static class WhenEqualsWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForArray subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_sampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + SimpleForArray subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_differentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Simple/SimpleForArrayTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForArrayTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..eb8c363 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForArrayTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Structs.Simple.SimpleForArrayTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenNullThenThrowNullReferenceException() + { + // Arrange + SimpleForArray subject = new(_sampleValue); + + // Act + Action act = () => subject.Equals((object?)default); + + // Assert + _ = Should.Throw(act); + } + + [Fact] + public static void GivenEquivalentSimpleForArrayThenReturnTrue() + { + // Arrange + SimpleForArray subject = new(_sampleValue); + object other = new SimpleForArray(_sampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + SimpleForArray subject = new(_sampleValue); + object other = string.Empty; + + // Act + Action act = () => subject.Equals(other); + + // Assert + _ = Should.Throw(act); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Simple/SimpleForArrayTests/WhenEqualsWithSimpleForArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForArrayTests/WhenEqualsWithSimpleForArrayIsCalled.cs new file mode 100644 index 0000000..1e3cff9 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForArrayTests/WhenEqualsWithSimpleForArrayIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Simple.SimpleForArrayTests; + +public static class WhenEqualsWithSimpleForArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForArray left = new(_sampleValue); + SimpleForArray right = new(_sampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + SimpleForArray left = new(_sampleValue); + SimpleForArray right = new(_differentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Simple/SimpleForArrayTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForArrayTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..0b03908 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForArrayTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Structs.Simple.SimpleForArrayTests; + +public static class WhenGetHashCodeIsCalled +{ + private static readonly int[] _firstValue = [7, 8, 9]; + private static readonly int[] _secondValue = [10, 11, 12]; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + SimpleForArray first = new(_firstValue); + SimpleForArray second = new(_firstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + SimpleForArray first = new(_firstValue); + SimpleForArray second = new(_secondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Simple/SimpleForArrayTests/WhenImplicitOperatorFromIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForArrayTests/WhenImplicitOperatorFromIntArrayIsCalled.cs new file mode 100644 index 0000000..0f4250b --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForArrayTests/WhenImplicitOperatorFromIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Simple.SimpleForArrayTests; + +public static class WhenImplicitOperatorFromIntArrayIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + SimpleForArray result = _sampleValue; + + // Act + int[] actual = result; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Simple/SimpleForArrayTests/WhenImplicitOperatorToIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForArrayTests/WhenImplicitOperatorToIntArrayIsCalled.cs new file mode 100644 index 0000000..c183d33 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForArrayTests/WhenImplicitOperatorToIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Simple.SimpleForArrayTests; + +public static class WhenImplicitOperatorToIntArrayIsCalled +{ + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + SimpleForArray subject = new(_sampleValue); + + // Act + int[] actual = subject; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Simple/SimpleForArrayTests/WhenInequalityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForArrayTests/WhenInequalityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..c805340 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForArrayTests/WhenInequalityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Simple.SimpleForArrayTests; + +public static class WhenInequalityOperatorWithIntArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + SimpleForArray? subject = default; + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + SimpleForArray subject = new(_sampleValue); + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + SimpleForArray subject = new(_sampleValue); + + // Act + bool actual = subject != _differentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Simple/SimpleForArrayTests/WhenInequalityOperatorWithSimpleForArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForArrayTests/WhenInequalityOperatorWithSimpleForArrayIsCalled.cs new file mode 100644 index 0000000..0a2bd8d --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForArrayTests/WhenInequalityOperatorWithSimpleForArrayIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Simple.SimpleForArrayTests; + +public static class WhenInequalityOperatorWithSimpleForArrayIsCalled +{ + private static readonly int[] _differentValue = [4, 5, 6]; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + SimpleForArray left = new(_sampleValue); + SimpleForArray right = new(_sampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + SimpleForArray left = new(_sampleValue); + SimpleForArray right = new(_differentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Simple/SimpleForArrayTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForArrayTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..c536cb1 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForArrayTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Structs.Simple.SimpleForArrayTests; + +public static class WhenToStringIsCalled +{ + private const string Expected = "SimpleForArray { System.Int32[] }"; + private static readonly int[] _sampleValue = [1, 2, 3]; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + SimpleForArray subject = new(_sampleValue); + + // Act + string result = subject.ToString(); + + // Assert + result.ShouldBe(Expected); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Simple/SimpleForIntTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForIntTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..75a0be6 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForIntTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Simple.SimpleForIntTests; + +public static class WhenConstructorIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + SimpleForInt instance = new(SampleValue); + + // Act + int actual = instance; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Simple/SimpleForIntTests/WhenEqualityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForIntTests/WhenEqualityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..413043c --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForIntTests/WhenEqualityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Simple.SimpleForIntTests; + +public static class WhenEqualityOperatorWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + SimpleForInt? subject = default; + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForInt subject = new(SampleValue); + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + SimpleForInt subject = new(SampleValue); + + // Act + bool actual = subject == DifferentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Simple/SimpleForIntTests/WhenEqualityOperatorWithSimpleForIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForIntTests/WhenEqualityOperatorWithSimpleForIntIsCalled.cs new file mode 100644 index 0000000..236242f --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForIntTests/WhenEqualityOperatorWithSimpleForIntIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Structs.Simple.SimpleForIntTests; + +public static class WhenEqualityOperatorWithSimpleForIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + SimpleForInt? left = default; + SimpleForInt? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + SimpleForInt? left = default; + SimpleForInt right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForInt left = new(SampleValue); + SimpleForInt right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + SimpleForInt left = new(SampleValue); + SimpleForInt right = new(DifferentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Simple/SimpleForIntTests/WhenEqualsWithIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForIntTests/WhenEqualsWithIntIsCalled.cs new file mode 100644 index 0000000..8b8d1db --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForIntTests/WhenEqualsWithIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Structs.Simple.SimpleForIntTests; + +public static class WhenEqualsWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForInt subject = new(SampleValue); + + // Act + bool actual = subject.Equals(SampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + SimpleForInt subject = new(SampleValue); + + // Act + bool actual = subject.Equals(DifferentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Simple/SimpleForIntTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForIntTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..ab92fdb --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForIntTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Structs.Simple.SimpleForIntTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenNullThenThrowNullReferenceException() + { + // Arrange + SimpleForInt subject = new(SampleValue); + + // Act + Action act = () => subject.Equals((object?)default); + + // Assert + _ = Should.Throw(act); + } + + [Fact] + public static void GivenEquivalentSimpleForIntThenReturnTrue() + { + // Arrange + SimpleForInt subject = new(SampleValue); + object other = new SimpleForInt(SampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + SimpleForInt subject = new(SampleValue); + object other = string.Empty; + + // Act + Action act = () => subject.Equals(other); + + // Assert + _ = Should.Throw(act); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Simple/SimpleForIntTests/WhenEqualsWithSimpleForIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForIntTests/WhenEqualsWithSimpleForIntIsCalled.cs new file mode 100644 index 0000000..c5e96af --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForIntTests/WhenEqualsWithSimpleForIntIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Simple.SimpleForIntTests; + +public static class WhenEqualsWithSimpleForIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForInt left = new(SampleValue); + SimpleForInt right = new(SampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + SimpleForInt left = new(SampleValue); + SimpleForInt right = new(DifferentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Simple/SimpleForIntTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForIntTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..8c3446c --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForIntTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Structs.Simple.SimpleForIntTests; + +public static class WhenGetHashCodeIsCalled +{ + private const int FirstValue = 5; + private const int SecondValue = 9; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + SimpleForInt first = new(FirstValue); + SimpleForInt second = new(FirstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + SimpleForInt first = new(FirstValue); + SimpleForInt second = new(SecondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Simple/SimpleForIntTests/WhenImplicitOperatorFromIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForIntTests/WhenImplicitOperatorFromIntIsCalled.cs new file mode 100644 index 0000000..b26ce38 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForIntTests/WhenImplicitOperatorFromIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Simple.SimpleForIntTests; + +public static class WhenImplicitOperatorFromIntIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + SimpleForInt result = SampleValue; + + // Act + int actual = result; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Simple/SimpleForIntTests/WhenImplicitOperatorToIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForIntTests/WhenImplicitOperatorToIntIsCalled.cs new file mode 100644 index 0000000..5a6fdd7 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForIntTests/WhenImplicitOperatorToIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Simple.SimpleForIntTests; + +public static class WhenImplicitOperatorToIntIsCalled +{ + private const int SampleValue = 42; + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + SimpleForInt subject = new(SampleValue); + + // Act + int actual = subject; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Simple/SimpleForIntTests/WhenInequalityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForIntTests/WhenInequalityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..5a8556e --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForIntTests/WhenInequalityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Simple.SimpleForIntTests; + +public static class WhenInequalityOperatorWithIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + SimpleForInt? subject = default; + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + SimpleForInt subject = new(SampleValue); + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + SimpleForInt subject = new(SampleValue); + + // Act + bool actual = subject != DifferentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Simple/SimpleForIntTests/WhenInequalityOperatorWithSimpleForIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForIntTests/WhenInequalityOperatorWithSimpleForIntIsCalled.cs new file mode 100644 index 0000000..a0a0a8c --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForIntTests/WhenInequalityOperatorWithSimpleForIntIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Simple.SimpleForIntTests; + +public static class WhenInequalityOperatorWithSimpleForIntIsCalled +{ + private const int DifferentValue = 84; + private const int SampleValue = 42; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + SimpleForInt left = new(SampleValue); + SimpleForInt right = new(SampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + SimpleForInt left = new(SampleValue); + SimpleForInt right = new(DifferentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Simple/SimpleForIntTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForIntTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..71b6926 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForIntTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Structs.Simple.SimpleForIntTests; + +public static class WhenToStringIsCalled +{ + private const string Expected = "SimpleForInt { 42 }"; + private const int SampleValue = 42; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + SimpleForInt subject = new(SampleValue); + + // Act + string result = subject.ToString(); + + // Assert + result.ShouldBe(Expected); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Simple/SimpleForStringTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForStringTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..e7884e6 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForStringTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Simple.SimpleForStringTests; + +public static class WhenConstructorIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + SimpleForString instance = new(SampleValue); + + // Act + string actual = instance; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Simple/SimpleForStringTests/WhenEqualityOperatorWithSimpleForStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForStringTests/WhenEqualityOperatorWithSimpleForStringIsCalled.cs new file mode 100644 index 0000000..301305f --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForStringTests/WhenEqualityOperatorWithSimpleForStringIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Structs.Simple.SimpleForStringTests; + +public static class WhenEqualityOperatorWithSimpleForStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + SimpleForString? left = default; + SimpleForString? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + SimpleForString? left = default; + SimpleForString right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForString left = new(SampleValue); + SimpleForString right = new(SampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + SimpleForString left = new(SampleValue); + SimpleForString right = new(DifferentValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Simple/SimpleForStringTests/WhenEqualityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForStringTests/WhenEqualityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..ac03d32 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForStringTests/WhenEqualityOperatorWithStringIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Simple.SimpleForStringTests; + +public static class WhenEqualityOperatorWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + SimpleForString? subject = default; + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForString subject = new(SampleValue); + + // Act + bool actual = subject == SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + SimpleForString subject = new(SampleValue); + + // Act + bool actual = subject == DifferentValue; + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Simple/SimpleForStringTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForStringTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..7b4c5b8 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForStringTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Structs.Simple.SimpleForStringTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenNullThenThrowNullReferenceException() + { + // Arrange + SimpleForString subject = new(SampleValue); + + // Act + Action act = () => subject.Equals((object?)default); + + // Assert + _ = Should.Throw(act); + } + + [Fact] + public static void GivenEquivalentSimpleForStringThenReturnTrue() + { + // Arrange + SimpleForString subject = new(SampleValue); + object other = new SimpleForString(SampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + SimpleForString subject = new(SampleValue); + object other = string.Empty; + + // Act + Action act = () => subject.Equals(other); + + // Assert + _ = Should.Throw(act); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Simple/SimpleForStringTests/WhenEqualsWithSimpleForStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForStringTests/WhenEqualsWithSimpleForStringIsCalled.cs new file mode 100644 index 0000000..dce9e5b --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForStringTests/WhenEqualsWithSimpleForStringIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Simple.SimpleForStringTests; + +public static class WhenEqualsWithSimpleForStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForString left = new(SampleValue); + SimpleForString right = new(SampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + SimpleForString left = new(SampleValue); + SimpleForString right = new(DifferentValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Simple/SimpleForStringTests/WhenEqualsWithStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForStringTests/WhenEqualsWithStringIsCalled.cs new file mode 100644 index 0000000..1c09a8b --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForStringTests/WhenEqualsWithStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Structs.Simple.SimpleForStringTests; + +public static class WhenEqualsWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForString subject = new(SampleValue); + + // Act + bool actual = subject.Equals(SampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + SimpleForString subject = new(SampleValue); + + // Act + bool actual = subject.Equals(DifferentValue); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Simple/SimpleForStringTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForStringTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..3436c4b --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForStringTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Structs.Simple.SimpleForStringTests; + +public static class WhenGetHashCodeIsCalled +{ + private const string FirstValue = "Alpha"; + private const string SecondValue = "Beta"; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + SimpleForString first = new(FirstValue); + SimpleForString second = new(FirstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + SimpleForString first = new(FirstValue); + SimpleForString second = new(SecondValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldNotBe(secondHash); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Simple/SimpleForStringTests/WhenImplicitOperatorFromStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForStringTests/WhenImplicitOperatorFromStringIsCalled.cs new file mode 100644 index 0000000..eda7e06 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForStringTests/WhenImplicitOperatorFromStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Simple.SimpleForStringTests; + +public static class WhenImplicitOperatorFromStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + SimpleForString result = SampleValue; + + // Act + string actual = result; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Simple/SimpleForStringTests/WhenImplicitOperatorToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForStringTests/WhenImplicitOperatorToStringIsCalled.cs new file mode 100644 index 0000000..52101f7 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForStringTests/WhenImplicitOperatorToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Simple.SimpleForStringTests; + +public static class WhenImplicitOperatorToStringIsCalled +{ + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + SimpleForString subject = new(SampleValue); + + // Act + string actual = subject; + + // Assert + actual.ShouldBe(SampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Simple/SimpleForStringTests/WhenInequalityOperatorWithSimpleForStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForStringTests/WhenInequalityOperatorWithSimpleForStringIsCalled.cs new file mode 100644 index 0000000..90061b2 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForStringTests/WhenInequalityOperatorWithSimpleForStringIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Simple.SimpleForStringTests; + +public static class WhenInequalityOperatorWithSimpleForStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + SimpleForString left = new(SampleValue); + SimpleForString right = new(SampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + SimpleForString left = new(SampleValue); + SimpleForString right = new(DifferentValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Simple/SimpleForStringTests/WhenInequalityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForStringTests/WhenInequalityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..b61ca2d --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForStringTests/WhenInequalityOperatorWithStringIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Simple.SimpleForStringTests; + +public static class WhenInequalityOperatorWithStringIsCalled +{ + private const string SampleValue = "Sample"; + private const string DifferentValue = "Different"; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + SimpleForString? subject = default; + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + SimpleForString subject = new(SampleValue); + + // Act + bool actual = subject != SampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + SimpleForString subject = new(SampleValue); + + // Act + bool actual = subject != DifferentValue; + + // Assert + actual.ShouldBeTrue(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Simple/SimpleForStringTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForStringTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..ea8808a --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForStringTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Structs.Simple.SimpleForStringTests; + +public static class WhenToStringIsCalled +{ + private const string Expected = $"SimpleForString {{ {SampleValue} }}"; + private const string SampleValue = "Sample"; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + SimpleForString subject = new(SampleValue); + + // Act + string result = subject.ToString(); + + // Assert + result.ShouldBe(Expected); + } +} \ No newline at end of file diff --git a/src/Monify.Tests/Snippets/Declarations/Classes/Nested.InClass.Expected.cs b/src/Monify.Tests/Snippets/Declarations/Classes/Nested.InClass.Expected.cs index b609758..0b3d504 100644 --- a/src/Monify.Tests/Snippets/Declarations/Classes/Nested.InClass.Expected.cs +++ b/src/Monify.Tests/Snippets/Declarations/Classes/Nested.InClass.Expected.cs @@ -397,7 +397,7 @@ sealed partial class Inner { public override string ToString() { - return string.Format("Inner { {0} }", _value); + return string.Format("Inner {{ {0} }}", _value); } } } diff --git a/src/Monify.Tests/Snippets/Declarations/Classes/Nested.InInterface.Expected.cs b/src/Monify.Tests/Snippets/Declarations/Classes/Nested.InInterface.Expected.cs index edde3ec..25320d2 100644 --- a/src/Monify.Tests/Snippets/Declarations/Classes/Nested.InInterface.Expected.cs +++ b/src/Monify.Tests/Snippets/Declarations/Classes/Nested.InInterface.Expected.cs @@ -397,7 +397,7 @@ sealed partial class Inner { public override string ToString() { - return string.Format("Inner { {0} }", _value); + return string.Format("Inner {{ {0} }}", _value); } } } diff --git a/src/Monify.Tests/Snippets/Declarations/Classes/Nested.InRecord.Expected.cs b/src/Monify.Tests/Snippets/Declarations/Classes/Nested.InRecord.Expected.cs index b04355f..088b248 100644 --- a/src/Monify.Tests/Snippets/Declarations/Classes/Nested.InRecord.Expected.cs +++ b/src/Monify.Tests/Snippets/Declarations/Classes/Nested.InRecord.Expected.cs @@ -397,7 +397,7 @@ sealed partial class Inner { public override string ToString() { - return string.Format("Inner { {0} }", _value); + return string.Format("Inner {{ {0} }}", _value); } } } diff --git a/src/Monify.Tests/Snippets/Declarations/Classes/Nested.InRecordStruct.Expected.cs b/src/Monify.Tests/Snippets/Declarations/Classes/Nested.InRecordStruct.Expected.cs index bc569de..d0806ca 100644 --- a/src/Monify.Tests/Snippets/Declarations/Classes/Nested.InRecordStruct.Expected.cs +++ b/src/Monify.Tests/Snippets/Declarations/Classes/Nested.InRecordStruct.Expected.cs @@ -397,7 +397,7 @@ sealed partial class Inner { public override string ToString() { - return string.Format("Inner { {0} }", _value); + return string.Format("Inner {{ {0} }}", _value); } } } diff --git a/src/Monify.Tests/Snippets/Declarations/Classes/Nested.InStruct.Expected.cs b/src/Monify.Tests/Snippets/Declarations/Classes/Nested.InStruct.Expected.cs index f26e832..e757d39 100644 --- a/src/Monify.Tests/Snippets/Declarations/Classes/Nested.InStruct.Expected.cs +++ b/src/Monify.Tests/Snippets/Declarations/Classes/Nested.InStruct.Expected.cs @@ -397,7 +397,7 @@ sealed partial class Inner { public override string ToString() { - return string.Format("Inner { {0} }", _value); + return string.Format("Inner {{ {0} }}", _value); } } } diff --git a/src/Monify.Tests/Snippets/Declarations/Classes/Simple.Expected.cs b/src/Monify.Tests/Snippets/Declarations/Classes/Simple.Expected.cs index 28f9012..69c4406 100644 --- a/src/Monify.Tests/Snippets/Declarations/Classes/Simple.Expected.cs +++ b/src/Monify.Tests/Snippets/Declarations/Classes/Simple.Expected.cs @@ -357,7 +357,7 @@ sealed partial class Simple { public override string ToString() { - return string.Format("Simple { {0} }", _value); + return string.Format("Simple {{ {0} }}", _value); } } diff --git a/src/Monify.Tests/Snippets/Declarations/Records/Nested.InClass.Expected.cs b/src/Monify.Tests/Snippets/Declarations/Records/Nested.InClass.Expected.cs index 0be192b..60aa21d 100644 --- a/src/Monify.Tests/Snippets/Declarations/Records/Nested.InClass.Expected.cs +++ b/src/Monify.Tests/Snippets/Declarations/Records/Nested.InClass.Expected.cs @@ -397,7 +397,7 @@ sealed partial record Inner { public override string ToString() { - return string.Format("Inner { {0} }", _value); + return string.Format("Inner {{ {0} }}", _value); } } } diff --git a/src/Monify.Tests/Snippets/Declarations/Records/Nested.InInterface.Expected.cs b/src/Monify.Tests/Snippets/Declarations/Records/Nested.InInterface.Expected.cs index 809a49e..e6ec599 100644 --- a/src/Monify.Tests/Snippets/Declarations/Records/Nested.InInterface.Expected.cs +++ b/src/Monify.Tests/Snippets/Declarations/Records/Nested.InInterface.Expected.cs @@ -397,7 +397,7 @@ sealed partial record Inner { public override string ToString() { - return string.Format("Inner { {0} }", _value); + return string.Format("Inner {{ {0} }}", _value); } } } diff --git a/src/Monify.Tests/Snippets/Declarations/Records/Nested.InRecord.Expected.cs b/src/Monify.Tests/Snippets/Declarations/Records/Nested.InRecord.Expected.cs index b2fded0..d462494 100644 --- a/src/Monify.Tests/Snippets/Declarations/Records/Nested.InRecord.Expected.cs +++ b/src/Monify.Tests/Snippets/Declarations/Records/Nested.InRecord.Expected.cs @@ -397,7 +397,7 @@ sealed partial record Inner { public override string ToString() { - return string.Format("Inner { {0} }", _value); + return string.Format("Inner {{ {0} }}", _value); } } } diff --git a/src/Monify.Tests/Snippets/Declarations/Records/Nested.InRecordStruct.Expected.cs b/src/Monify.Tests/Snippets/Declarations/Records/Nested.InRecordStruct.Expected.cs index cc486d7..355fbef 100644 --- a/src/Monify.Tests/Snippets/Declarations/Records/Nested.InRecordStruct.Expected.cs +++ b/src/Monify.Tests/Snippets/Declarations/Records/Nested.InRecordStruct.Expected.cs @@ -397,7 +397,7 @@ sealed partial record Inner { public override string ToString() { - return string.Format("Inner { {0} }", _value); + return string.Format("Inner {{ {0} }}", _value); } } } diff --git a/src/Monify.Tests/Snippets/Declarations/Records/Nested.InStruct.Expected.cs b/src/Monify.Tests/Snippets/Declarations/Records/Nested.InStruct.Expected.cs index 90be44f..4ccce13 100644 --- a/src/Monify.Tests/Snippets/Declarations/Records/Nested.InStruct.Expected.cs +++ b/src/Monify.Tests/Snippets/Declarations/Records/Nested.InStruct.Expected.cs @@ -397,7 +397,7 @@ sealed partial record Inner { public override string ToString() { - return string.Format("Inner { {0} }", _value); + return string.Format("Inner {{ {0} }}", _value); } } } diff --git a/src/Monify.Tests/Snippets/Declarations/Structs/Nested.InClass.Expected.cs b/src/Monify.Tests/Snippets/Declarations/Structs/Nested.InClass.Expected.cs index 7bb90ca..5e80f4c 100644 --- a/src/Monify.Tests/Snippets/Declarations/Structs/Nested.InClass.Expected.cs +++ b/src/Monify.Tests/Snippets/Declarations/Structs/Nested.InClass.Expected.cs @@ -397,7 +397,7 @@ readonly partial struct Inner { public override string ToString() { - return string.Format("Inner { {0} }", _value); + return string.Format("Inner {{ {0} }}", _value); } } } diff --git a/src/Monify.Tests/Snippets/Declarations/Structs/Nested.InInterface.Expected.cs b/src/Monify.Tests/Snippets/Declarations/Structs/Nested.InInterface.Expected.cs index 0ac032d..ac76da1 100644 --- a/src/Monify.Tests/Snippets/Declarations/Structs/Nested.InInterface.Expected.cs +++ b/src/Monify.Tests/Snippets/Declarations/Structs/Nested.InInterface.Expected.cs @@ -397,7 +397,7 @@ readonly partial struct Inner { public override string ToString() { - return string.Format("Inner { {0} }", _value); + return string.Format("Inner {{ {0} }}", _value); } } } diff --git a/src/Monify.Tests/Snippets/Declarations/Structs/Nested.InRecord.Expected.cs b/src/Monify.Tests/Snippets/Declarations/Structs/Nested.InRecord.Expected.cs index a54a962..3f3917c 100644 --- a/src/Monify.Tests/Snippets/Declarations/Structs/Nested.InRecord.Expected.cs +++ b/src/Monify.Tests/Snippets/Declarations/Structs/Nested.InRecord.Expected.cs @@ -397,7 +397,7 @@ readonly partial struct Inner { public override string ToString() { - return string.Format("Inner { {0} }", _value); + return string.Format("Inner {{ {0} }}", _value); } } } diff --git a/src/Monify.Tests/Snippets/Declarations/Structs/Nested.InRecordStruct.Expected.cs b/src/Monify.Tests/Snippets/Declarations/Structs/Nested.InRecordStruct.Expected.cs index a01fafd..1c9b501 100644 --- a/src/Monify.Tests/Snippets/Declarations/Structs/Nested.InRecordStruct.Expected.cs +++ b/src/Monify.Tests/Snippets/Declarations/Structs/Nested.InRecordStruct.Expected.cs @@ -397,7 +397,7 @@ readonly partial struct Inner { public override string ToString() { - return string.Format("Inner { {0} }", _value); + return string.Format("Inner {{ {0} }}", _value); } } } diff --git a/src/Monify.Tests/Snippets/Declarations/Structs/Nested.InStruct.Expected.cs b/src/Monify.Tests/Snippets/Declarations/Structs/Nested.InStruct.Expected.cs index a0fe201..b943108 100644 --- a/src/Monify.Tests/Snippets/Declarations/Structs/Nested.InStruct.Expected.cs +++ b/src/Monify.Tests/Snippets/Declarations/Structs/Nested.InStruct.Expected.cs @@ -397,7 +397,7 @@ readonly partial struct Inner { public override string ToString() { - return string.Format("Inner { {0} }", _value); + return string.Format("Inner {{ {0} }}", _value); } } } diff --git a/src/Monify.Tests/Snippets/Declarations/Structs/Simple.Expected.cs b/src/Monify.Tests/Snippets/Declarations/Structs/Simple.Expected.cs index f165a45..5432154 100644 --- a/src/Monify.Tests/Snippets/Declarations/Structs/Simple.Expected.cs +++ b/src/Monify.Tests/Snippets/Declarations/Structs/Simple.Expected.cs @@ -357,7 +357,7 @@ partial struct Simple { public override string ToString() { - return string.Format("Simple { {0} }", _value); + return string.Format("Simple {{ {0} }}", _value); } } diff --git a/src/Monify/Model/Subject.cs b/src/Monify/Model/Subject.cs index 9e98366..7e26ab7 100644 --- a/src/Monify/Model/Subject.cs +++ b/src/Monify/Model/Subject.cs @@ -146,6 +146,14 @@ internal sealed partial class Subject /// public bool IsGlobal => string.IsNullOrEmpty(Namespace); + /// + /// Gets or sets a value indicating whether or not the encapsulated type is deemed to be a sequence. + /// + /// + /// The value indicating whether or not the encapsulated type is deemed to be a sequence. + /// + public bool IsSequence { get; set; } + /// /// Gets or sets the name of the subject. /// diff --git a/src/Monify/Semantics/INamedTypeSymbolExtensions.ToSubject.cs b/src/Monify/Semantics/INamedTypeSymbolExtensions.ToSubject.cs index 3c1638c..e4a5e29 100644 --- a/src/Monify/Semantics/INamedTypeSymbolExtensions.ToSubject.cs +++ b/src/Monify/Semantics/INamedTypeSymbolExtensions.ToSubject.cs @@ -64,6 +64,7 @@ internal static partial class INamedTypeSymbolExtensions HasInequalityOperatorForValue = subject.HasInequalityOperator(type: value), IsEquatableToSelf = subject.IsEquatable(compilation), IsEquatableToValue = subject.IsEquatable(compilation, type: value), + IsSequence = value.IsSequence(), Name = subject.Name, Namespace = @namespace, Nesting = nesting, diff --git a/src/Monify/Semantics/ISymbolExtensions.IsAttribute.cs b/src/Monify/Semantics/ISymbolExtensions.IsAttribute.cs index bf9e660..f004510 100644 --- a/src/Monify/Semantics/ISymbolExtensions.IsAttribute.cs +++ b/src/Monify/Semantics/ISymbolExtensions.IsAttribute.cs @@ -7,11 +7,11 @@ /// internal static partial class ISymbolExtensions { - private static readonly SymbolDisplayFormat fullyQualifiedFormat = new( + private static readonly SymbolDisplayFormat _fullyQualifiedFormat = new( typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameAndContainingTypesAndNamespaces, genericsOptions: SymbolDisplayGenericsOptions.None); - private static readonly SymbolDisplayFormat minimallyQualifiedFormat = new( + private static readonly SymbolDisplayFormat _minimallyQualifiedFormat = new( typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameOnly, genericsOptions: SymbolDisplayGenericsOptions.None); @@ -35,12 +35,12 @@ public static bool IsAttribute(this ISymbol? subject, string name) bool IsGlobal() { - return subject.ContainingNamespace.IsGlobalNamespace && subject.ToDisplayString(minimallyQualifiedFormat) == name; + return subject.ContainingNamespace.IsGlobalNamespace && subject.ToDisplayString(_minimallyQualifiedFormat) == name; } bool IsQualified() { - string name = subject.ToDisplayString(fullyQualifiedFormat); + string name = subject.ToDisplayString(_fullyQualifiedFormat); return name == qualifiedName || name == fullyQualifiedName || name == globalQualifiedName; } diff --git a/src/Monify/Semantics/ITypeSymbolExtensions.IsSequence.cs b/src/Monify/Semantics/ITypeSymbolExtensions.IsSequence.cs new file mode 100644 index 0000000..bd5ca52 --- /dev/null +++ b/src/Monify/Semantics/ITypeSymbolExtensions.IsSequence.cs @@ -0,0 +1,25 @@ +namespace Monify.Semantics; + +using Microsoft.CodeAnalysis; + +/// +/// Provides extensions relating to . +/// +internal static class ITypeSymbolExtensions +{ + /// + /// Determines whether or not the represents a sequence. + /// + /// The type to check. + /// if the represents a sequence, otherwise . + public static bool IsSequence(this ITypeSymbol type) + { + static bool IsEnumerable(INamedTypeSymbol @interface) + { + return @interface.OriginalDefinition.SpecialType == SpecialType.System_Collections_Generic_IEnumerable_T + || @interface.SpecialType == SpecialType.System_Collections_IEnumerable; + } + + return type.SpecialType != SpecialType.System_String && (type is IArrayTypeSymbol || type.AllInterfaces.Any(IsEnumerable)); + } +} \ No newline at end of file diff --git a/src/Monify/Strategies/ToStringStrategy.cs b/src/Monify/Strategies/ToStringStrategy.cs index bbfc16a..45b32af 100644 --- a/src/Monify/Strategies/ToStringStrategy.cs +++ b/src/Monify/Strategies/ToStringStrategy.cs @@ -16,12 +16,12 @@ public IEnumerable Generate(Subject subject) yield break; } - string code = $$""" - {{subject.Declaration}} {{subject.Qualification}} + string code = $$$""" + {{{subject.Declaration}}} {{{subject.Qualification}}} { public override string ToString() { - return string.Format("{{subject.Name}} { {0} }", {{FieldStrategy.Name}}); + return string.Format("{{{subject.Name}}} {{ {0} }}", {{{FieldStrategy.Name}}}); } } """; diff --git a/src/Monify/TypeGenerator.cs b/src/Monify/TypeGenerator.cs index 6f30648..2d3a1ab 100644 --- a/src/Monify/TypeGenerator.cs +++ b/src/Monify/TypeGenerator.cs @@ -13,7 +13,7 @@ public sealed class TypeGenerator : IIncrementalGenerator { - private static readonly IStrategy[] strategies = new IStrategy[] + private static readonly IStrategy[] _strategies = new IStrategy[] { new ConstructorStrategy(), new ConvertFromStrategy(), @@ -29,7 +29,7 @@ public sealed class TypeGenerator subject => subject.Qualification), new EquatableStrategy( subject => !subject.IsEquatableToValue, - subject => $"global::System.Collections.Generic.EqualityComparer<{subject.Value}>.Default.Equals({FieldStrategy.Name}, other)", + GetEqualityOperator, subject => !subject.HasEquatableForValue, "Value", subject => subject.Value), @@ -64,7 +64,7 @@ private static void Generate(SourceProductionContext context, Subject? subject) Dictionary files = new(); #endif - foreach (IStrategy strategy in strategies) + foreach (IStrategy strategy in _strategies) { IEnumerable sources = strategy.Generate(subject); @@ -83,6 +83,16 @@ private static void Generate(SourceProductionContext context, Subject? subject) } } + private static string GetEqualityOperator(Subject subject) + { + if (subject.IsSequence) + { + return $"global::Monify.Internal.SequenceEqualityComparer.Default.Equals({FieldStrategy.Name}, other)"; + } + + return $"global::System.Collections.Generic.EqualityComparer<{subject.Value}>.Default.Equals({FieldStrategy.Name}, other)"; + } + private static string GetHint(Source source, Subject subject) { string name = subject.Name;