diff --git a/.editorconfig b/.editorconfig index 6000037..bfb9123 100644 --- a/.editorconfig +++ b/.editorconfig @@ -175,13 +175,15 @@ dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = error dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case -dotnet_naming_rule.private_constant_should_be_pascal_case.severity = error -dotnet_naming_rule.private_constant_should_be_pascal_case.symbols = private_constant -dotnet_naming_rule.private_constant_should_be_pascal_case.style = pascal_case +dotnet_naming_rule.private_constant_fields_should_be_pascal_case.severity = error +dotnet_naming_rule.private_constant_fields_should_be_pascal_case.symbols = private_constant_fields +dotnet_naming_rule.private_constant_fields_should_be_pascal_case.style = pascal_case +dotnet_naming_rule.private_constant_fields_should_be_pascal_case.priority = 1 -dotnet_naming_rule.private_static_field_should_be_camel_case.severity = error -dotnet_naming_rule.private_static_field_should_be_camel_case.symbols = private_static_field -dotnet_naming_rule.private_static_field_should_be_camel_case.style = camel_case +dotnet_naming_rule.private_fields_should_be_camel_case_with_underscore_prefix.severity = error +dotnet_naming_rule.private_fields_should_be_camel_case_with_underscore_prefix.symbols = private_fields +dotnet_naming_rule.private_fields_should_be_camel_case_with_underscore_prefix.style = camel_case_underscore_prefix +dotnet_naming_rule.private_fields_should_be_camel_case_with_underscore_prefix.priority = 2 # Symbol specifications @@ -197,13 +199,13 @@ dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, meth dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal dotnet_naming_symbols.non_field_members.required_modifiers = -dotnet_naming_symbols.private_static_field.applicable_kinds = field -dotnet_naming_symbols.private_static_field.applicable_accessibilities = private -dotnet_naming_symbols.private_static_field.required_modifiers = static +dotnet_naming_symbols.private_fields.applicable_kinds = field +dotnet_naming_symbols.private_fields.applicable_accessibilities = private +dotnet_naming_symbols.private_fields.required_modifiers = -dotnet_naming_symbols.private_constant.applicable_kinds = field -dotnet_naming_symbols.private_constant.applicable_accessibilities = private -dotnet_naming_symbols.private_constant.required_modifiers = const +dotnet_naming_symbols.private_constant_fields.applicable_kinds = field +dotnet_naming_symbols.private_constant_fields.applicable_accessibilities = private +dotnet_naming_symbols.private_constant_fields.required_modifiers = const # Naming styles @@ -221,6 +223,11 @@ dotnet_naming_style.camel_case.required_prefix = dotnet_naming_style.camel_case.required_suffix = dotnet_naming_style.camel_case.word_separator = dotnet_naming_style.camel_case.capitalization = camel_case + +dotnet_naming_style.camel_case_underscore_prefix.required_prefix = _ +dotnet_naming_style.camel_case_underscore_prefix.required_suffix = +dotnet_naming_style.camel_case_underscore_prefix.word_separator = +dotnet_naming_style.camel_case_underscore_prefix.capitalization = camel_case dotnet_diagnostic.S1117.severity = none dotnet_diagnostic.SA1506.severity=silent dotnet_diagnostic.SA1500.severity=error diff --git a/AGENTS.md b/AGENTS.md index 2e4f66b..5522087 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -30,6 +30,7 @@ The project enforces strong C# coding conventions through `.editorconfig`, [Styl - Use `var` for local variables when the type is clear from the right-hand side. - Use `nameof` for member names in exceptions and logging. - Use `string.Empty` instead of `""` for empty strings. +- When possible, place declarations in alphabetical order (e.g. fields, parameters, properties, methods). ### Unit Testing Conventions diff --git a/CHANGELOG.md b/CHANGELOG.md index d9cc583..b308626 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ 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] - 2025-10-31 + +## Fixed +- MONFY03 is no longer raised if the encapsulated type cannot be determined (#22). +- 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/Monify.sln b/Monify.sln index 382f4ac..b593a2f 100644 --- a/Monify.sln +++ b/Monify.sln @@ -65,6 +65,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Rules", "Rules", "{DF5E2435 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Monify.Tests", "src\Monify.Tests\Monify.Tests.csproj", "{9C2086AB-647E-485E-A964-A4A383354230}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Monify.Console", "src\Monify.Console\Monify.Console.csproj", "{8EC2148F-0491-4116-AC04-C4A0AD013C82}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Monify.Console.Tests", "src\Monify.Console.Tests\Monify.Console.Tests.csproj", "{5EE36FF0-4AA4-4EB1-A6C9-9FE144B1D4FB}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -79,6 +83,14 @@ Global {9C2086AB-647E-485E-A964-A4A383354230}.Debug|Any CPU.Build.0 = Debug|Any CPU {9C2086AB-647E-485E-A964-A4A383354230}.Release|Any CPU.ActiveCfg = Release|Any CPU {9C2086AB-647E-485E-A964-A4A383354230}.Release|Any CPU.Build.0 = Release|Any CPU + {8EC2148F-0491-4116-AC04-C4A0AD013C82}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8EC2148F-0491-4116-AC04-C4A0AD013C82}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8EC2148F-0491-4116-AC04-C4A0AD013C82}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8EC2148F-0491-4116-AC04-C4A0AD013C82}.Release|Any CPU.Build.0 = Release|Any CPU + {5EE36FF0-4AA4-4EB1-A6C9-9FE144B1D4FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5EE36FF0-4AA4-4EB1-A6C9-9FE144B1D4FB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5EE36FF0-4AA4-4EB1-A6C9-9FE144B1D4FB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5EE36FF0-4AA4-4EB1-A6C9-9FE144B1D4FB}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE 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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..1ed460c --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForArrayTests; + +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/WhenEqualityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/WhenEqualityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..222798d --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/WhenEqualityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForArrayTests; + +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/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..7ed83b4 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,79 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForArrayTests; + +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 GivenEquivalentValuesThenReturnTrue() + { + // Arrange + int[] leftValues = [1, 2, 3]; + int[] rightValues = [1, 2, 3]; + OutterForArray.Inner left = new(leftValues); + OutterForArray.Inner right = new(rightValues); + + // 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/WhenEqualsWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/WhenEqualsWithIntArrayIsCalled.cs new file mode 100644 index 0000000..d45414e --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/WhenEqualsWithIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForArrayTests; + +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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..9804cc9 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForArrayTests; + +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/WhenEqualsWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..25910c2 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForArrayTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..0775045 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForArrayTests; + +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/WhenImplicitOperatorFromIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/WhenImplicitOperatorFromIntArrayIsCalled.cs new file mode 100644 index 0000000..0917c5e --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/WhenImplicitOperatorFromIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForArrayTests; + +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/WhenImplicitOperatorToIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/WhenImplicitOperatorToIntArrayIsCalled.cs new file mode 100644 index 0000000..e894fbf --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/WhenImplicitOperatorToIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForArrayTests; + +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/WhenInequalityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/WhenInequalityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..3a31d4a --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/WhenInequalityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForArrayTests; + +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/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..8e3d20f --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,51 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForArrayTests; + +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 GivenEquivalentValuesThenReturnFalse() + { + // Arrange + int[] leftValues = [1, 2, 3]; + int[] rightValues = [1, 2, 3]; + OutterForArray.Inner left = new(leftValues); + OutterForArray.Inner right = new(rightValues); + + // 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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..eaef174 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForArrayTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForArrayTests; + +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/OutterForImmutableArrayTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForImmutableArrayTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..659cdfb --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForImmutableArrayTests/WhenConstructorIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenConstructorIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForImmutableArray.Inner instance = new(_sampleValue); + + // Act + ImmutableArray actual = instance; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..20e7e01 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs @@ -0,0 +1,48 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualityOperatorWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner? subject = default; + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForImmutableArrayTests/WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..8bfbeb7 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForImmutableArrayTests/WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,81 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner? left = default; + OutterForImmutableArray.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner? left = default; + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenEquivalentValuesThenReturnTrue() + { + // Arrange + ImmutableArray leftValues = ["Alpha", "Beta", "Gamma"]; + ImmutableArray rightValues = ["Alpha", "Beta", "Gamma"]; + OutterForImmutableArray.Inner left = new(leftValues); + OutterForImmutableArray.Inner right = new(rightValues); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..7cfdd2b --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_sampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..4cad7b0 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,49 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithObjectIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentOutterForImmutableArrayInnerThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + object other = new OutterForImmutableArray.Inner(_sampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualsWithOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForImmutableArrayTests/WhenEqualsWithOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..f98019b --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForImmutableArrayTests/WhenEqualsWithOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..a85bec1 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,39 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenGetHashCodeIsCalled +{ + private static readonly ImmutableArray _firstValue = ["Eta", "Theta", "Iota"]; + private static readonly ImmutableArray _secondValue = ["Kappa", "Lambda", "Mu"]; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForImmutableArray.Inner first = new(_firstValue); + OutterForImmutableArray.Inner second = new(_firstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForImmutableArray.Inner first = new(_firstValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs new file mode 100644 index 0000000..3e4992c --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenImplicitOperatorFromImmutableArrayIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForImmutableArray.Inner result = _sampleValue; + + // Act + ImmutableArray actual = result; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs new file mode 100644 index 0000000..f82853d --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenImplicitOperatorToImmutableArrayIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + OutterForImmutableArray.Inner? subject = default; + + // Act + Action act = () => _ = (ImmutableArray)subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + ImmutableArray actual = subject; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..2911c13 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs @@ -0,0 +1,48 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenInequalityOperatorWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner? subject = default; + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForImmutableArrayTests/WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..e4fd170 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForImmutableArrayTests/WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,53 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentValuesThenReturnFalse() + { + // Arrange + ImmutableArray leftValues = ["Alpha", "Beta", "Gamma"]; + ImmutableArray rightValues = ["Alpha", "Beta", "Gamma"]; + OutterForImmutableArray.Inner left = new(leftValues); + OutterForImmutableArray.Inner right = new(rightValues); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForImmutableArrayTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..0955260 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForImmutableArrayTests/WhenToStringIsCalled.cs @@ -0,0 +1,22 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenToStringIsCalled +{ + private static readonly string Expected = $"Inner {{ {typeof(ImmutableArray)} }}"; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + OutterForImmutableArray.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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..671b353 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForIntTests; + +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/WhenEqualityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/WhenEqualityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..084b1aa --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/WhenEqualityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForIntTests; + +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/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..85d8a4c --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForIntTests; + +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/WhenEqualsWithIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/WhenEqualsWithIntIsCalled.cs new file mode 100644 index 0000000..1145d64 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/WhenEqualsWithIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForIntTests; + +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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..13a34dc --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForIntTests; + +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/WhenEqualsWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/WhenEqualsWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..4808519 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/WhenEqualsWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForIntTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..c6d95f3 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForIntTests; + +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/WhenImplicitOperatorFromIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/WhenImplicitOperatorFromIntIsCalled.cs new file mode 100644 index 0000000..8d82f86 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/WhenImplicitOperatorFromIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForIntTests; + +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/WhenImplicitOperatorToIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/WhenImplicitOperatorToIntIsCalled.cs new file mode 100644 index 0000000..ac6854c --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/WhenImplicitOperatorToIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForIntTests; + +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/WhenInequalityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/WhenInequalityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..8a60df0 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/WhenInequalityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForIntTests; + +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/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..f7083f6 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForIntTests; + +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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..5313eb1 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForIntTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForIntTests; + +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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..681675d --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForStringTests; + +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/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..89f7f1c --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,79 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForStringTests; + +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 GivenEquivalentValuesThenReturnTrue() + { + // Arrange + string leftValue = new(SampleValue.ToCharArray()); + string rightValue = new(SampleValue.ToCharArray()); + OutterForString.Inner left = new(leftValue); + OutterForString.Inner right = new(rightValue); + + // 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/WhenEqualityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/WhenEqualityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..9d0d4c9 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/WhenEqualityOperatorWithStringIsCalled.cs @@ -0,0 +1,61 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForStringTests; + +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 GivenEquivalentValueThenReturnTrue() + { + // Arrange + string subjectValue = new(SampleValue.ToCharArray()); + string comparisonValue = new(SampleValue.ToCharArray()); + OutterForString.Inner subject = new(subjectValue); + + // Act + bool actual = subject == comparisonValue; + + // 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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..bd5f698 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForStringTests; + +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/WhenEqualsWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/WhenEqualsWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..dbb1ded --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/WhenEqualsWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForStringTests; + +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/WhenEqualsWithStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/WhenEqualsWithStringIsCalled.cs new file mode 100644 index 0000000..c2e740a --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/WhenEqualsWithStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForStringTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..b59b59f --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForStringTests; + +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/WhenImplicitOperatorFromStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/WhenImplicitOperatorFromStringIsCalled.cs new file mode 100644 index 0000000..62ae177 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/WhenImplicitOperatorFromStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForStringTests; + +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/WhenImplicitOperatorToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/WhenImplicitOperatorToStringIsCalled.cs new file mode 100644 index 0000000..65f1892 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/WhenImplicitOperatorToStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForStringTests; + +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/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..ef6fa3c --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,51 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForStringTests; + +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 GivenEquivalentValuesThenReturnFalse() + { + // Arrange + string leftValue = new(SampleValue.ToCharArray()); + string rightValue = new(SampleValue.ToCharArray()); + OutterForString.Inner left = new(leftValue); + OutterForString.Inner right = new(rightValue); + + // 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/WhenInequalityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/WhenInequalityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..cd220fd --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/WhenInequalityOperatorWithStringIsCalled.cs @@ -0,0 +1,61 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForStringTests; + +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 GivenEquivalentValueThenReturnFalse() + { + // Arrange + string subjectValue = new(SampleValue.ToCharArray()); + string comparisonValue = new(SampleValue.ToCharArray()); + OutterForString.Inner subject = new(subjectValue); + + // Act + bool actual = subject != comparisonValue; + + // 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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..a997572 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InClass/OutterForStringTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Classes.Nested.InClass.OutterForStringTests; + +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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..b12a038 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForArrayTests; + +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/WhenEqualityOperatorWithIOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/WhenEqualityOperatorWithIOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..24b9d8c --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/WhenEqualityOperatorWithIOutterForArrayInnerIsCalled.cs @@ -0,0 +1,79 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForArrayTests; + +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 GivenEquivalentValuesThenReturnTrue() + { + // Arrange + int[] leftValues = [1, 2, 3]; + int[] rightValues = [1, 2, 3]; + IOutterForArray.Inner left = new(leftValues); + IOutterForArray.Inner right = new(rightValues); + + // 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/WhenEqualityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/WhenEqualityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..863552b --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/WhenEqualityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForArrayTests; + +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/WhenEqualsWithIOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/WhenEqualsWithIOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..53801b0 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/WhenEqualsWithIOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForArrayTests; + +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/WhenEqualsWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/WhenEqualsWithIntArrayIsCalled.cs new file mode 100644 index 0000000..9d9125b --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/WhenEqualsWithIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForArrayTests; + +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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..ce5338d --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForArrayTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..3fd0260 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForArrayTests; + +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/WhenImplicitOperatorFromIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/WhenImplicitOperatorFromIntArrayIsCalled.cs new file mode 100644 index 0000000..12edef7 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/WhenImplicitOperatorFromIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForArrayTests; + +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/WhenImplicitOperatorToIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/WhenImplicitOperatorToIntArrayIsCalled.cs new file mode 100644 index 0000000..51e0ee8 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/WhenImplicitOperatorToIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForArrayTests; + +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/WhenInequalityOperatorWithIOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/WhenInequalityOperatorWithIOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..983ec05 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/WhenInequalityOperatorWithIOutterForArrayInnerIsCalled.cs @@ -0,0 +1,51 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForArrayTests; + +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 GivenEquivalentValuesThenReturnFalse() + { + // Arrange + int[] leftValues = [1, 2, 3]; + int[] rightValues = [1, 2, 3]; + IOutterForArray.Inner left = new(leftValues); + IOutterForArray.Inner right = new(rightValues); + + // 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/WhenInequalityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/WhenInequalityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..36cd5c2 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/WhenInequalityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForArrayTests; + +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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..ce5b910 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForArrayTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForArrayTests; + +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/IOutterForImmutableArrayTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForImmutableArrayTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..1774750 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForImmutableArrayTests/WhenConstructorIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenConstructorIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + IOutterForImmutableArray.Inner instance = new(_sampleValue); + + // Act + ImmutableArray actual = instance; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForImmutableArrayTests/WhenEqualityOperatorWithIOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForImmutableArrayTests/WhenEqualityOperatorWithIOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..48f9a40 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForImmutableArrayTests/WhenEqualityOperatorWithIOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,81 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualityOperatorWithIOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + IOutterForImmutableArray.Inner? left = default; + IOutterForImmutableArray.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + IOutterForImmutableArray.Inner? left = default; + IOutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForImmutableArray.Inner left = new(_sampleValue); + IOutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenEquivalentValuesThenReturnTrue() + { + // Arrange + ImmutableArray leftValues = ["Alpha", "Beta", "Gamma"]; + ImmutableArray rightValues = ["Alpha", "Beta", "Gamma"]; + IOutterForImmutableArray.Inner left = new(leftValues); + IOutterForImmutableArray.Inner right = new(rightValues); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + IOutterForImmutableArray.Inner left = new(_sampleValue); + IOutterForImmutableArray.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/IOutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..d090c10 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs @@ -0,0 +1,48 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualityOperatorWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + IOutterForImmutableArray.Inner? subject = default; + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + IOutterForImmutableArray.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/IOutterForImmutableArrayTests/WhenEqualsWithIOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForImmutableArrayTests/WhenEqualsWithIOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..a0fed9e --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForImmutableArrayTests/WhenEqualsWithIOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithIOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForImmutableArray.Inner left = new(_sampleValue); + IOutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + IOutterForImmutableArray.Inner left = new(_sampleValue); + IOutterForImmutableArray.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/IOutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..66cb2b1 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_sampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + IOutterForImmutableArray.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/IOutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..d50c73d --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,49 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithObjectIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + IOutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentIOutterForImmutableArrayInnerThenReturnTrue() + { + // Arrange + IOutterForImmutableArray.Inner subject = new(_sampleValue); + object other = new IOutterForImmutableArray.Inner(_sampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + IOutterForImmutableArray.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/IOutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..bcec7ef --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,39 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenGetHashCodeIsCalled +{ + private static readonly ImmutableArray _firstValue = ["Eta", "Theta", "Iota"]; + private static readonly ImmutableArray _secondValue = ["Kappa", "Lambda", "Mu"]; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + IOutterForImmutableArray.Inner first = new(_firstValue); + IOutterForImmutableArray.Inner second = new(_firstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + IOutterForImmutableArray.Inner first = new(_firstValue); + IOutterForImmutableArray.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/IOutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs new file mode 100644 index 0000000..793c6fb --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenImplicitOperatorFromImmutableArrayIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + IOutterForImmutableArray.Inner result = _sampleValue; + + // Act + ImmutableArray actual = result; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs new file mode 100644 index 0000000..d6b34f2 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenImplicitOperatorToImmutableArrayIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + IOutterForImmutableArray.Inner? subject = default; + + // Act + Action act = () => _ = (ImmutableArray)subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + IOutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + ImmutableArray actual = subject; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForImmutableArrayTests/WhenInequalityOperatorWithIOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForImmutableArrayTests/WhenInequalityOperatorWithIOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..52f7506 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForImmutableArrayTests/WhenInequalityOperatorWithIOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,53 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenInequalityOperatorWithIOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + IOutterForImmutableArray.Inner left = new(_sampleValue); + IOutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentValuesThenReturnFalse() + { + // Arrange + ImmutableArray leftValues = ["Alpha", "Beta", "Gamma"]; + ImmutableArray rightValues = ["Alpha", "Beta", "Gamma"]; + IOutterForImmutableArray.Inner left = new(leftValues); + IOutterForImmutableArray.Inner right = new(rightValues); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + IOutterForImmutableArray.Inner left = new(_sampleValue); + IOutterForImmutableArray.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/IOutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..a32e292 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs @@ -0,0 +1,48 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenInequalityOperatorWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + IOutterForImmutableArray.Inner? subject = default; + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + IOutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + IOutterForImmutableArray.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/IOutterForImmutableArrayTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForImmutableArrayTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..388a178 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForImmutableArrayTests/WhenToStringIsCalled.cs @@ -0,0 +1,22 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenToStringIsCalled +{ + private static readonly string Expected = $"Inner {{ {typeof(ImmutableArray)} }}"; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + IOutterForImmutableArray.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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..4511330 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForIntTests; + +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/WhenEqualityOperatorWithIOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/WhenEqualityOperatorWithIOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..bef600b --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/WhenEqualityOperatorWithIOutterForIntInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForIntTests; + +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/WhenEqualityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/WhenEqualityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..50ed275 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/WhenEqualityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForIntTests; + +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/WhenEqualsWithIOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/WhenEqualsWithIOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..e34ff93 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/WhenEqualsWithIOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForIntTests; + +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/WhenEqualsWithIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/WhenEqualsWithIntIsCalled.cs new file mode 100644 index 0000000..ba2c9a5 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/WhenEqualsWithIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForIntTests; + +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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..d8c15c6 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForIntTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..fd6691c --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForIntTests; + +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/WhenImplicitOperatorFromIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/WhenImplicitOperatorFromIntIsCalled.cs new file mode 100644 index 0000000..0307431 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/WhenImplicitOperatorFromIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForIntTests; + +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/WhenImplicitOperatorToIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/WhenImplicitOperatorToIntIsCalled.cs new file mode 100644 index 0000000..9ca7e47 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/WhenImplicitOperatorToIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForIntTests; + +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/WhenInequalityOperatorWithIOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/WhenInequalityOperatorWithIOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..be0ba99 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/WhenInequalityOperatorWithIOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForIntTests; + +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/WhenInequalityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/WhenInequalityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..9ab2a2b --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/WhenInequalityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForIntTests; + +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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..b98bf41 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForIntTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForIntTests; + +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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..48171fc --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForStringTests; + +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/WhenEqualityOperatorWithIOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/WhenEqualityOperatorWithIOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..e3614e1 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/WhenEqualityOperatorWithIOutterForStringInnerIsCalled.cs @@ -0,0 +1,79 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForStringTests; + +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 GivenEquivalentValuesThenReturnTrue() + { + // Arrange + string leftValue = new(SampleValue.ToCharArray()); + string rightValue = new(SampleValue.ToCharArray()); + IOutterForString.Inner left = new(leftValue); + IOutterForString.Inner right = new(rightValue); + + // 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/WhenEqualityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/WhenEqualityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..822e15f --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/WhenEqualityOperatorWithStringIsCalled.cs @@ -0,0 +1,61 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForStringTests; + +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 GivenEquivalentValueThenReturnTrue() + { + // Arrange + string subjectValue = new(SampleValue.ToCharArray()); + string comparisonValue = new(SampleValue.ToCharArray()); + IOutterForString.Inner subject = new(subjectValue); + + // Act + bool actual = subject == comparisonValue; + + // 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/WhenEqualsWithIOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/WhenEqualsWithIOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..0aa53a8 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/WhenEqualsWithIOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForStringTests; + +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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..26c36ad --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForStringTests; + +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/WhenEqualsWithStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/WhenEqualsWithStringIsCalled.cs new file mode 100644 index 0000000..483e1b5 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/WhenEqualsWithStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForStringTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..b128128 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForStringTests; + +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/WhenImplicitOperatorFromStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/WhenImplicitOperatorFromStringIsCalled.cs new file mode 100644 index 0000000..5c5665d --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/WhenImplicitOperatorFromStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForStringTests; + +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/WhenImplicitOperatorToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/WhenImplicitOperatorToStringIsCalled.cs new file mode 100644 index 0000000..ae01030 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/WhenImplicitOperatorToStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForStringTests; + +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/WhenInequalityOperatorWithIOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/WhenInequalityOperatorWithIOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..c2e1c97 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/WhenInequalityOperatorWithIOutterForStringInnerIsCalled.cs @@ -0,0 +1,51 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForStringTests; + +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 GivenEquivalentValuesThenReturnFalse() + { + // Arrange + string leftValue = new(SampleValue.ToCharArray()); + string rightValue = new(SampleValue.ToCharArray()); + IOutterForString.Inner left = new(leftValue); + IOutterForString.Inner right = new(rightValue); + + // 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/WhenInequalityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/WhenInequalityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..3085da2 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/WhenInequalityOperatorWithStringIsCalled.cs @@ -0,0 +1,61 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForStringTests; + +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 GivenEquivalentValueThenReturnFalse() + { + // Arrange + string subjectValue = new(SampleValue.ToCharArray()); + string comparisonValue = new(SampleValue.ToCharArray()); + IOutterForString.Inner subject = new(subjectValue); + + // Act + bool actual = subject != comparisonValue; + + // 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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..ef0c606 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InInterface/IOutterForStringTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Classes.Nested.InInterface.IOutterForStringTests; + +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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..139432e --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForArrayTests; + +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/WhenEqualityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/WhenEqualityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..c34c94d --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/WhenEqualityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForArrayTests; + +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/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..12a83ad --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,79 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForArrayTests; + +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 GivenEquivalentValuesThenReturnTrue() + { + // Arrange + int[] leftValues = [1, 2, 3]; + int[] rightValues = [1, 2, 3]; + OutterForArray.Inner left = new(leftValues); + OutterForArray.Inner right = new(rightValues); + + // 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/WhenEqualsWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/WhenEqualsWithIntArrayIsCalled.cs new file mode 100644 index 0000000..e6fe1b0 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/WhenEqualsWithIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForArrayTests; + +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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..bb2b733 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForArrayTests; + +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/WhenEqualsWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..b8bc837 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForArrayTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..54c357e --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForArrayTests; + +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/WhenImplicitOperatorFromIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/WhenImplicitOperatorFromIntArrayIsCalled.cs new file mode 100644 index 0000000..e1c18e7 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/WhenImplicitOperatorFromIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForArrayTests; + +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/WhenImplicitOperatorToIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/WhenImplicitOperatorToIntArrayIsCalled.cs new file mode 100644 index 0000000..e38b4d3 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/WhenImplicitOperatorToIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForArrayTests; + +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/WhenInequalityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/WhenInequalityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..8b56711 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/WhenInequalityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForArrayTests; + +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/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..d17796c --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,51 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForArrayTests; + +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 GivenEquivalentValuesThenReturnFalse() + { + // Arrange + int[] leftValues = [1, 2, 3]; + int[] rightValues = [1, 2, 3]; + OutterForArray.Inner left = new(leftValues); + OutterForArray.Inner right = new(rightValues); + + // 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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..666180b --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForArrayTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForArrayTests; + +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/OutterForImmutableArrayTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForImmutableArrayTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..0b97681 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForImmutableArrayTests/WhenConstructorIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenConstructorIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForImmutableArray.Inner instance = new(_sampleValue); + + // Act + ImmutableArray actual = instance; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..0d4a74d --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs @@ -0,0 +1,48 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualityOperatorWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner? subject = default; + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForImmutableArrayTests/WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..190cc9a --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForImmutableArrayTests/WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,81 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner? left = default; + OutterForImmutableArray.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner? left = default; + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenEquivalentValuesThenReturnTrue() + { + // Arrange + ImmutableArray leftValues = ["Alpha", "Beta", "Gamma"]; + ImmutableArray rightValues = ["Alpha", "Beta", "Gamma"]; + OutterForImmutableArray.Inner left = new(leftValues); + OutterForImmutableArray.Inner right = new(rightValues); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..62f4dc0 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_sampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..5388283 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,49 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithObjectIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentOutterForImmutableArrayInnerThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + object other = new OutterForImmutableArray.Inner(_sampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualsWithOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForImmutableArrayTests/WhenEqualsWithOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..e0ced72 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForImmutableArrayTests/WhenEqualsWithOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..aed304e --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,39 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenGetHashCodeIsCalled +{ + private static readonly ImmutableArray _firstValue = ["Eta", "Theta", "Iota"]; + private static readonly ImmutableArray _secondValue = ["Kappa", "Lambda", "Mu"]; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForImmutableArray.Inner first = new(_firstValue); + OutterForImmutableArray.Inner second = new(_firstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForImmutableArray.Inner first = new(_firstValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs new file mode 100644 index 0000000..1fd772b --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenImplicitOperatorFromImmutableArrayIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForImmutableArray.Inner result = _sampleValue; + + // Act + ImmutableArray actual = result; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs new file mode 100644 index 0000000..9fe6447 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenImplicitOperatorToImmutableArrayIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + OutterForImmutableArray.Inner? subject = default; + + // Act + Action act = () => _ = (ImmutableArray)subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + ImmutableArray actual = subject; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..f3d3cc5 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs @@ -0,0 +1,48 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenInequalityOperatorWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner? subject = default; + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForImmutableArrayTests/WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..743ff66 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForImmutableArrayTests/WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,53 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentValuesThenReturnFalse() + { + // Arrange + ImmutableArray leftValues = ["Alpha", "Beta", "Gamma"]; + ImmutableArray rightValues = ["Alpha", "Beta", "Gamma"]; + OutterForImmutableArray.Inner left = new(leftValues); + OutterForImmutableArray.Inner right = new(rightValues); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForImmutableArrayTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..48e7cb5 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForImmutableArrayTests/WhenToStringIsCalled.cs @@ -0,0 +1,22 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenToStringIsCalled +{ + private static readonly string Expected = $"Inner {{ {typeof(ImmutableArray)} }}"; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + OutterForImmutableArray.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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..7a0b5be --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForIntTests; + +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/WhenEqualityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/WhenEqualityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..7bd9f95 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/WhenEqualityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForIntTests; + +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/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..e4ce0f4 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForIntTests; + +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/WhenEqualsWithIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/WhenEqualsWithIntIsCalled.cs new file mode 100644 index 0000000..24340a9 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/WhenEqualsWithIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForIntTests; + +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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..fa9bfab --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForIntTests; + +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/WhenEqualsWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/WhenEqualsWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..459d986 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/WhenEqualsWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForIntTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..a0112a2 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForIntTests; + +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/WhenImplicitOperatorFromIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/WhenImplicitOperatorFromIntIsCalled.cs new file mode 100644 index 0000000..227582f --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/WhenImplicitOperatorFromIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForIntTests; + +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/WhenImplicitOperatorToIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/WhenImplicitOperatorToIntIsCalled.cs new file mode 100644 index 0000000..5667147 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/WhenImplicitOperatorToIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForIntTests; + +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/WhenInequalityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/WhenInequalityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..eb8ae27 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/WhenInequalityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForIntTests; + +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/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..e39f15f --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForIntTests; + +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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..ec82150 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForIntTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForIntTests; + +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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..4a9cf4f --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForStringTests; + +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/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..a0a6255 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,79 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForStringTests; + +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 GivenEquivalentValuesThenReturnTrue() + { + // Arrange + string leftValue = new(SampleValue.ToCharArray()); + string rightValue = new(SampleValue.ToCharArray()); + OutterForString.Inner left = new(leftValue); + OutterForString.Inner right = new(rightValue); + + // 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/WhenEqualityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/WhenEqualityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..b39fb73 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/WhenEqualityOperatorWithStringIsCalled.cs @@ -0,0 +1,61 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForStringTests; + +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 GivenEquivalentValueThenReturnTrue() + { + // Arrange + string subjectValue = new(SampleValue.ToCharArray()); + string comparisonValue = new(SampleValue.ToCharArray()); + OutterForString.Inner subject = new(subjectValue); + + // Act + bool actual = subject == comparisonValue; + + // 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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..fc10917 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForStringTests; + +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/WhenEqualsWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/WhenEqualsWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..318260b --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/WhenEqualsWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForStringTests; + +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/WhenEqualsWithStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/WhenEqualsWithStringIsCalled.cs new file mode 100644 index 0000000..2dd8ea3 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/WhenEqualsWithStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForStringTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..2409d4f --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForStringTests; + +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/WhenImplicitOperatorFromStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/WhenImplicitOperatorFromStringIsCalled.cs new file mode 100644 index 0000000..7048edf --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/WhenImplicitOperatorFromStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForStringTests; + +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/WhenImplicitOperatorToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/WhenImplicitOperatorToStringIsCalled.cs new file mode 100644 index 0000000..a2553be --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/WhenImplicitOperatorToStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForStringTests; + +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/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..209103d --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,51 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForStringTests; + +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 GivenEquivalentValuesThenReturnFalse() + { + // Arrange + string leftValue = new(SampleValue.ToCharArray()); + string rightValue = new(SampleValue.ToCharArray()); + OutterForString.Inner left = new(leftValue); + OutterForString.Inner right = new(rightValue); + + // 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/WhenInequalityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/WhenInequalityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..ae2afae --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/WhenInequalityOperatorWithStringIsCalled.cs @@ -0,0 +1,61 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForStringTests; + +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 GivenEquivalentValueThenReturnFalse() + { + // Arrange + string subjectValue = new(SampleValue.ToCharArray()); + string comparisonValue = new(SampleValue.ToCharArray()); + OutterForString.Inner subject = new(subjectValue); + + // Act + bool actual = subject != comparisonValue; + + // 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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..d9257fd --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecord/OutterForStringTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Classes.Nested.InRecord.OutterForStringTests; + +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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..a43dabc --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForArrayTests; + +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/WhenEqualityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/WhenEqualityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..ffa5fb8 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/WhenEqualityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForArrayTests; + +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/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..422eca5 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,79 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForArrayTests; + +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 GivenEquivalentValuesThenReturnTrue() + { + // Arrange + int[] leftValues = [1, 2, 3]; + int[] rightValues = [1, 2, 3]; + OutterForArray.Inner left = new(leftValues); + OutterForArray.Inner right = new(rightValues); + + // 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/WhenEqualsWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/WhenEqualsWithIntArrayIsCalled.cs new file mode 100644 index 0000000..fbcfc4d --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/WhenEqualsWithIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForArrayTests; + +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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..886091f --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForArrayTests; + +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/WhenEqualsWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..b069c15 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForArrayTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..aa334ab --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForArrayTests; + +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/WhenImplicitOperatorFromIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/WhenImplicitOperatorFromIntArrayIsCalled.cs new file mode 100644 index 0000000..8fe2528 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/WhenImplicitOperatorFromIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForArrayTests; + +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/WhenImplicitOperatorToIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/WhenImplicitOperatorToIntArrayIsCalled.cs new file mode 100644 index 0000000..df6d944 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/WhenImplicitOperatorToIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForArrayTests; + +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/WhenInequalityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/WhenInequalityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..a3eb37b --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/WhenInequalityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForArrayTests; + +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/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..468b755 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,51 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForArrayTests; + +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 GivenEquivalentValuesThenReturnFalse() + { + // Arrange + int[] leftValues = [1, 2, 3]; + int[] rightValues = [1, 2, 3]; + OutterForArray.Inner left = new(leftValues); + OutterForArray.Inner right = new(rightValues); + + // 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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..9842d19 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForArrayTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForArrayTests; + +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/OutterForImmutableArrayTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..62e0967 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenConstructorIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenConstructorIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForImmutableArray.Inner instance = new(_sampleValue); + + // Act + ImmutableArray actual = instance; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..d753513 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs @@ -0,0 +1,48 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualityOperatorWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner? subject = default; + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..c3d258a --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,81 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner? left = default; + OutterForImmutableArray.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner? left = default; + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenEquivalentValuesThenReturnTrue() + { + // Arrange + ImmutableArray leftValues = ["Alpha", "Beta", "Gamma"]; + ImmutableArray rightValues = ["Alpha", "Beta", "Gamma"]; + OutterForImmutableArray.Inner left = new(leftValues); + OutterForImmutableArray.Inner right = new(rightValues); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..04cbc01 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_sampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..2d56753 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,49 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithObjectIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentOutterForImmutableArrayInnerThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + object other = new OutterForImmutableArray.Inner(_sampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualsWithOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenEqualsWithOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..0898d8d --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenEqualsWithOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..cffc9b2 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,39 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenGetHashCodeIsCalled +{ + private static readonly ImmutableArray _firstValue = ["Eta", "Theta", "Iota"]; + private static readonly ImmutableArray _secondValue = ["Kappa", "Lambda", "Mu"]; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForImmutableArray.Inner first = new(_firstValue); + OutterForImmutableArray.Inner second = new(_firstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForImmutableArray.Inner first = new(_firstValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs new file mode 100644 index 0000000..c997bff --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenImplicitOperatorFromImmutableArrayIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForImmutableArray.Inner result = _sampleValue; + + // Act + ImmutableArray actual = result; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs new file mode 100644 index 0000000..aa2e908 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenImplicitOperatorToImmutableArrayIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + OutterForImmutableArray.Inner? subject = default; + + // Act + Action act = () => _ = (ImmutableArray)subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + ImmutableArray actual = subject; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..b5f9882 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs @@ -0,0 +1,48 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenInequalityOperatorWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner? subject = default; + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..84eb0e9 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,53 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentValuesThenReturnFalse() + { + // Arrange + ImmutableArray leftValues = ["Alpha", "Beta", "Gamma"]; + ImmutableArray rightValues = ["Alpha", "Beta", "Gamma"]; + OutterForImmutableArray.Inner left = new(leftValues); + OutterForImmutableArray.Inner right = new(rightValues); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..64933f1 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenToStringIsCalled.cs @@ -0,0 +1,22 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenToStringIsCalled +{ + private static readonly string Expected = $"Inner {{ {typeof(ImmutableArray)} }}"; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + OutterForImmutableArray.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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..c0d02a1 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForIntTests; + +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/WhenEqualityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/WhenEqualityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..2b149de --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/WhenEqualityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForIntTests; + +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/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..c420d7a --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForIntTests; + +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/WhenEqualsWithIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/WhenEqualsWithIntIsCalled.cs new file mode 100644 index 0000000..80ea8b2 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/WhenEqualsWithIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForIntTests; + +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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..a21c0fa --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForIntTests; + +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/WhenEqualsWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/WhenEqualsWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..c151f8e --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/WhenEqualsWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForIntTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..7669d47 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForIntTests; + +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/WhenImplicitOperatorFromIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/WhenImplicitOperatorFromIntIsCalled.cs new file mode 100644 index 0000000..67257ad --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/WhenImplicitOperatorFromIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForIntTests; + +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/WhenImplicitOperatorToIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/WhenImplicitOperatorToIntIsCalled.cs new file mode 100644 index 0000000..4bf988c --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/WhenImplicitOperatorToIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForIntTests; + +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/WhenInequalityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/WhenInequalityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..061c5c4 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/WhenInequalityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForIntTests; + +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/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..3ea6dd1 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForIntTests; + +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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..c2fbca9 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForIntTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForIntTests; + +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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..80d18b7 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForStringTests; + +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/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..217a8e7 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,79 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForStringTests; + +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 GivenEquivalentValuesThenReturnTrue() + { + // Arrange + string leftValue = new(SampleValue.ToCharArray()); + string rightValue = new(SampleValue.ToCharArray()); + OutterForString.Inner left = new(leftValue); + OutterForString.Inner right = new(rightValue); + + // 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/WhenEqualityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/WhenEqualityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..5dd325c --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/WhenEqualityOperatorWithStringIsCalled.cs @@ -0,0 +1,61 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForStringTests; + +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 GivenEquivalentValueThenReturnTrue() + { + // Arrange + string subjectValue = new(SampleValue.ToCharArray()); + string comparisonValue = new(SampleValue.ToCharArray()); + OutterForString.Inner subject = new(subjectValue); + + // Act + bool actual = subject == comparisonValue; + + // 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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..53cee1d --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForStringTests; + +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/WhenEqualsWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/WhenEqualsWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..341e4db --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/WhenEqualsWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForStringTests; + +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/WhenEqualsWithStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/WhenEqualsWithStringIsCalled.cs new file mode 100644 index 0000000..a9828af --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/WhenEqualsWithStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForStringTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..fdffe10 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForStringTests; + +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/WhenImplicitOperatorFromStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/WhenImplicitOperatorFromStringIsCalled.cs new file mode 100644 index 0000000..c3720c7 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/WhenImplicitOperatorFromStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForStringTests; + +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/WhenImplicitOperatorToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/WhenImplicitOperatorToStringIsCalled.cs new file mode 100644 index 0000000..d1c4b0f --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/WhenImplicitOperatorToStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForStringTests; + +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/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..fd65973 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,51 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForStringTests; + +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 GivenEquivalentValuesThenReturnFalse() + { + // Arrange + string leftValue = new(SampleValue.ToCharArray()); + string rightValue = new(SampleValue.ToCharArray()); + OutterForString.Inner left = new(leftValue); + OutterForString.Inner right = new(rightValue); + + // 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/WhenInequalityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/WhenInequalityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..88a8562 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/WhenInequalityOperatorWithStringIsCalled.cs @@ -0,0 +1,61 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForStringTests; + +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 GivenEquivalentValueThenReturnFalse() + { + // Arrange + string subjectValue = new(SampleValue.ToCharArray()); + string comparisonValue = new(SampleValue.ToCharArray()); + OutterForString.Inner subject = new(subjectValue); + + // Act + bool actual = subject != comparisonValue; + + // 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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..f27be4c --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InRecordStruct/OutterForStringTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct.OutterForStringTests; + +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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..b17838a --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForArrayTests; + +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/WhenEqualityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/WhenEqualityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..441fd79 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/WhenEqualityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForArrayTests; + +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/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..3ddf8a6 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,79 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForArrayTests; + +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 GivenEquivalentValuesThenReturnTrue() + { + // Arrange + int[] leftValues = [1, 2, 3]; + int[] rightValues = [1, 2, 3]; + OutterForArray.Inner left = new(leftValues); + OutterForArray.Inner right = new(rightValues); + + // 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/WhenEqualsWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/WhenEqualsWithIntArrayIsCalled.cs new file mode 100644 index 0000000..23eff74 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/WhenEqualsWithIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForArrayTests; + +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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..c92b222 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForArrayTests; + +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/WhenEqualsWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..cce3bc4 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForArrayTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..ef6835e --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForArrayTests; + +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/WhenImplicitOperatorFromIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/WhenImplicitOperatorFromIntArrayIsCalled.cs new file mode 100644 index 0000000..8bb1489 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/WhenImplicitOperatorFromIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForArrayTests; + +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/WhenImplicitOperatorToIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/WhenImplicitOperatorToIntArrayIsCalled.cs new file mode 100644 index 0000000..f4171c5 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/WhenImplicitOperatorToIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForArrayTests; + +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/WhenInequalityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/WhenInequalityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..f2c381c --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/WhenInequalityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForArrayTests; + +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/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..bc4e3ca --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,51 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForArrayTests; + +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 GivenEquivalentValuesThenReturnFalse() + { + // Arrange + int[] leftValues = [1, 2, 3]; + int[] rightValues = [1, 2, 3]; + OutterForArray.Inner left = new(leftValues); + OutterForArray.Inner right = new(rightValues); + + // 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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..605e90c --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForArrayTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForArrayTests; + +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/OutterForImmutableArrayTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForImmutableArrayTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..608fe61 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForImmutableArrayTests/WhenConstructorIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenConstructorIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForImmutableArray.Inner instance = new(_sampleValue); + + // Act + ImmutableArray actual = instance; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..38ff15d --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs @@ -0,0 +1,48 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualityOperatorWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner? subject = default; + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForImmutableArrayTests/WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..32902a4 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForImmutableArrayTests/WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,81 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner? left = default; + OutterForImmutableArray.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner? left = default; + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenEquivalentValuesThenReturnTrue() + { + // Arrange + ImmutableArray leftValues = ["Alpha", "Beta", "Gamma"]; + ImmutableArray rightValues = ["Alpha", "Beta", "Gamma"]; + OutterForImmutableArray.Inner left = new(leftValues); + OutterForImmutableArray.Inner right = new(rightValues); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..76877c5 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_sampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..69b9b68 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,49 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithObjectIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentOutterForImmutableArrayInnerThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + object other = new OutterForImmutableArray.Inner(_sampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualsWithOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForImmutableArrayTests/WhenEqualsWithOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..7a8843d --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForImmutableArrayTests/WhenEqualsWithOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..8504f6a --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,39 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenGetHashCodeIsCalled +{ + private static readonly ImmutableArray _firstValue = ["Eta", "Theta", "Iota"]; + private static readonly ImmutableArray _secondValue = ["Kappa", "Lambda", "Mu"]; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForImmutableArray.Inner first = new(_firstValue); + OutterForImmutableArray.Inner second = new(_firstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForImmutableArray.Inner first = new(_firstValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs new file mode 100644 index 0000000..5a3a040 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenImplicitOperatorFromImmutableArrayIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForImmutableArray.Inner result = _sampleValue; + + // Act + ImmutableArray actual = result; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs new file mode 100644 index 0000000..4863cc6 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenImplicitOperatorToImmutableArrayIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + OutterForImmutableArray.Inner? subject = default; + + // Act + Action act = () => _ = (ImmutableArray)subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + ImmutableArray actual = subject; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..673648b --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs @@ -0,0 +1,48 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenInequalityOperatorWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner? subject = default; + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForImmutableArrayTests/WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..01ff34a --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForImmutableArrayTests/WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,53 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentValuesThenReturnFalse() + { + // Arrange + ImmutableArray leftValues = ["Alpha", "Beta", "Gamma"]; + ImmutableArray rightValues = ["Alpha", "Beta", "Gamma"]; + OutterForImmutableArray.Inner left = new(leftValues); + OutterForImmutableArray.Inner right = new(rightValues); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForImmutableArrayTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..17b096c --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForImmutableArrayTests/WhenToStringIsCalled.cs @@ -0,0 +1,22 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenToStringIsCalled +{ + private static readonly string Expected = $"Inner {{ {typeof(ImmutableArray)} }}"; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + OutterForImmutableArray.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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..caab433 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForIntTests; + +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/WhenEqualityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/WhenEqualityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..6adbf30 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/WhenEqualityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForIntTests; + +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/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..cf649d3 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForIntTests; + +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/WhenEqualsWithIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/WhenEqualsWithIntIsCalled.cs new file mode 100644 index 0000000..2492a3f --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/WhenEqualsWithIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForIntTests; + +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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..2c24702 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForIntTests; + +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/WhenEqualsWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/WhenEqualsWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..523764c --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/WhenEqualsWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForIntTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..fa0af97 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForIntTests; + +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/WhenImplicitOperatorFromIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/WhenImplicitOperatorFromIntIsCalled.cs new file mode 100644 index 0000000..7e8302a --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/WhenImplicitOperatorFromIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForIntTests; + +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/WhenImplicitOperatorToIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/WhenImplicitOperatorToIntIsCalled.cs new file mode 100644 index 0000000..be98734 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/WhenImplicitOperatorToIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForIntTests; + +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/WhenInequalityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/WhenInequalityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..7344d60 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/WhenInequalityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForIntTests; + +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/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..bc4f632 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForIntTests; + +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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..2bda27a --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForIntTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForIntTests; + +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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..d2ad5fc --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForStringTests; + +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/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..2774d00 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,79 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForStringTests; + +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 GivenEquivalentValuesThenReturnTrue() + { + // Arrange + string leftValue = new(SampleValue.ToCharArray()); + string rightValue = new(SampleValue.ToCharArray()); + OutterForString.Inner left = new(leftValue); + OutterForString.Inner right = new(rightValue); + + // 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/WhenEqualityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/WhenEqualityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..53194c6 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/WhenEqualityOperatorWithStringIsCalled.cs @@ -0,0 +1,61 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForStringTests; + +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 GivenEquivalentValueThenReturnTrue() + { + // Arrange + string subjectValue = new(SampleValue.ToCharArray()); + string comparisonValue = new(SampleValue.ToCharArray()); + OutterForString.Inner subject = new(subjectValue); + + // Act + bool actual = subject == comparisonValue; + + // 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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..7e57eb7 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForStringTests; + +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/WhenEqualsWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/WhenEqualsWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..54957c9 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/WhenEqualsWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForStringTests; + +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/WhenEqualsWithStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/WhenEqualsWithStringIsCalled.cs new file mode 100644 index 0000000..6a2feb5 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/WhenEqualsWithStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForStringTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..1eea965 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForStringTests; + +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/WhenImplicitOperatorFromStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/WhenImplicitOperatorFromStringIsCalled.cs new file mode 100644 index 0000000..f1db47a --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/WhenImplicitOperatorFromStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForStringTests; + +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/WhenImplicitOperatorToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/WhenImplicitOperatorToStringIsCalled.cs new file mode 100644 index 0000000..ecc2ef2 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/WhenImplicitOperatorToStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForStringTests; + +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/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..967ac88 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,51 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForStringTests; + +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 GivenEquivalentValuesThenReturnFalse() + { + // Arrange + string leftValue = new(SampleValue.ToCharArray()); + string rightValue = new(SampleValue.ToCharArray()); + OutterForString.Inner left = new(leftValue); + OutterForString.Inner right = new(rightValue); + + // 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/WhenInequalityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/WhenInequalityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..f0e04dc --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/WhenInequalityOperatorWithStringIsCalled.cs @@ -0,0 +1,61 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForStringTests; + +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 GivenEquivalentValueThenReturnFalse() + { + // Arrange + string subjectValue = new(SampleValue.ToCharArray()); + string comparisonValue = new(SampleValue.ToCharArray()); + OutterForString.Inner subject = new(subjectValue); + + // Act + bool actual = subject != comparisonValue; + + // 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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..b8a7080 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Nested/InStruct/OutterForStringTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Classes.Nested.InStruct.OutterForStringTests; + +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..d5b488b --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForArrayTests/WhenEqualityOperatorWithSimpleForArrayIsCalled.cs @@ -0,0 +1,79 @@ +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 GivenEquivalentValuesThenReturnTrue() + { + // Arrange + int[] leftValues = [1, 2, 3]; + int[] rightValues = [1, 2, 3]; + SimpleForArray left = new(leftValues); + SimpleForArray right = new(rightValues); + + // 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..5ab87e1 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForArrayTests/WhenInequalityOperatorWithSimpleForArrayIsCalled.cs @@ -0,0 +1,51 @@ +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 GivenEquivalentValuesThenReturnFalse() + { + // Arrange + int[] leftValues = [1, 2, 3]; + int[] rightValues = [1, 2, 3]; + SimpleForArray left = new(leftValues); + SimpleForArray right = new(rightValues); + + // 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/SimpleForImmutableArrayTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForImmutableArrayTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..f2967bd --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForImmutableArrayTests/WhenConstructorIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Classes.Simple.SimpleForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenConstructorIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + SimpleForImmutableArray instance = new(_sampleValue); + + // Act + ImmutableArray actual = instance; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Simple/SimpleForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..d41f000 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs @@ -0,0 +1,48 @@ +namespace Monify.Console.Classes.Simple.SimpleForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualityOperatorWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + SimpleForImmutableArray? subject = default; + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForImmutableArray subject = new(_sampleValue); + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + SimpleForImmutableArray 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/SimpleForImmutableArrayTests/WhenEqualityOperatorWithSimpleForImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForImmutableArrayTests/WhenEqualityOperatorWithSimpleForImmutableArrayIsCalled.cs new file mode 100644 index 0000000..f35d082 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForImmutableArrayTests/WhenEqualityOperatorWithSimpleForImmutableArrayIsCalled.cs @@ -0,0 +1,81 @@ +namespace Monify.Console.Classes.Simple.SimpleForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualityOperatorWithSimpleForImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + SimpleForImmutableArray? left = default; + SimpleForImmutableArray? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + SimpleForImmutableArray? left = default; + SimpleForImmutableArray right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForImmutableArray left = new(_sampleValue); + SimpleForImmutableArray right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenEquivalentValuesThenReturnTrue() + { + // Arrange + ImmutableArray leftValues = ["Alpha", "Beta", "Gamma"]; + ImmutableArray rightValues = ["Alpha", "Beta", "Gamma"]; + SimpleForImmutableArray left = new(leftValues); + SimpleForImmutableArray right = new(rightValues); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + SimpleForImmutableArray left = new(_sampleValue); + SimpleForImmutableArray 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/SimpleForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..d54764d --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Simple.SimpleForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForImmutableArray subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_sampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + SimpleForImmutableArray 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/SimpleForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..14ff91f --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,49 @@ +namespace Monify.Console.Classes.Simple.SimpleForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithObjectIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + SimpleForImmutableArray subject = new(_sampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentSimpleForImmutableArrayThenReturnTrue() + { + // Arrange + SimpleForImmutableArray subject = new(_sampleValue); + object other = new SimpleForImmutableArray(_sampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + SimpleForImmutableArray 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/SimpleForImmutableArrayTests/WhenEqualsWithSimpleForImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForImmutableArrayTests/WhenEqualsWithSimpleForImmutableArrayIsCalled.cs new file mode 100644 index 0000000..84649f2 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForImmutableArrayTests/WhenEqualsWithSimpleForImmutableArrayIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Classes.Simple.SimpleForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithSimpleForImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForImmutableArray left = new(_sampleValue); + SimpleForImmutableArray right = new(_sampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + SimpleForImmutableArray left = new(_sampleValue); + SimpleForImmutableArray 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/SimpleForImmutableArrayTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForImmutableArrayTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..719b7cd --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForImmutableArrayTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,39 @@ +namespace Monify.Console.Classes.Simple.SimpleForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenGetHashCodeIsCalled +{ + private static readonly ImmutableArray _firstValue = ["Eta", "Theta", "Iota"]; + private static readonly ImmutableArray _secondValue = ["Kappa", "Lambda", "Mu"]; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + SimpleForImmutableArray first = new(_firstValue); + SimpleForImmutableArray second = new(_firstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + SimpleForImmutableArray first = new(_firstValue); + SimpleForImmutableArray 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/SimpleForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs new file mode 100644 index 0000000..add0bfa --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Classes.Simple.SimpleForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenImplicitOperatorFromImmutableArrayIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + SimpleForImmutableArray result = _sampleValue; + + // Act + ImmutableArray actual = result; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Simple/SimpleForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs new file mode 100644 index 0000000..a65e7e7 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Simple.SimpleForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenImplicitOperatorToImmutableArrayIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + SimpleForImmutableArray? subject = default; + + // Act + Action act = () => _ = (ImmutableArray)subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + SimpleForImmutableArray subject = new(_sampleValue); + + // Act + ImmutableArray actual = subject; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Simple/SimpleForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..727c3ec --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs @@ -0,0 +1,48 @@ +namespace Monify.Console.Classes.Simple.SimpleForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenInequalityOperatorWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + SimpleForImmutableArray? subject = default; + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + SimpleForImmutableArray subject = new(_sampleValue); + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + SimpleForImmutableArray 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/SimpleForImmutableArrayTests/WhenInequalityOperatorWithSimpleForImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForImmutableArrayTests/WhenInequalityOperatorWithSimpleForImmutableArrayIsCalled.cs new file mode 100644 index 0000000..47c5933 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForImmutableArrayTests/WhenInequalityOperatorWithSimpleForImmutableArrayIsCalled.cs @@ -0,0 +1,53 @@ +namespace Monify.Console.Classes.Simple.SimpleForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenInequalityOperatorWithSimpleForImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + SimpleForImmutableArray left = new(_sampleValue); + SimpleForImmutableArray right = new(_sampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentValuesThenReturnFalse() + { + // Arrange + ImmutableArray leftValues = ["Alpha", "Beta", "Gamma"]; + ImmutableArray rightValues = ["Alpha", "Beta", "Gamma"]; + SimpleForImmutableArray left = new(leftValues); + SimpleForImmutableArray right = new(rightValues); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + SimpleForImmutableArray left = new(_sampleValue); + SimpleForImmutableArray 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/SimpleForImmutableArrayTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForImmutableArrayTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..aa13cf5 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForImmutableArrayTests/WhenToStringIsCalled.cs @@ -0,0 +1,22 @@ +namespace Monify.Console.Classes.Simple.SimpleForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenToStringIsCalled +{ + private static readonly string Expected = $"SimpleForImmutableArray {{ {typeof(ImmutableArray)} }}"; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + SimpleForImmutableArray 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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..c8f24ec --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.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/Classes/Simple/SimpleForIntTests/WhenEqualityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenEqualityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..b94e864 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenEqualityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Simple.SimpleForIntTests; + +public static class WhenEqualityOperatorWithIntIsCalled +{ + private const int DifferentValue = 202; + private const int SampleValue = 101; + + [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/Classes/Simple/SimpleForIntTests/WhenEqualityOperatorWithSimpleForIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenEqualityOperatorWithSimpleForIntIsCalled.cs new file mode 100644 index 0000000..2a0369d --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenEqualityOperatorWithSimpleForIntIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Classes.Simple.SimpleForIntTests; + +public static class WhenEqualityOperatorWithSimpleForIntIsCalled +{ + private const int DifferentValue = 17; + private const int SampleValue = 14; + + [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/Classes/Simple/SimpleForIntTests/WhenEqualsWithIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenEqualsWithIntIsCalled.cs new file mode 100644 index 0000000..cf9d5fb --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenEqualsWithIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.Simple.SimpleForIntTests; + +public static class WhenEqualsWithIntIsCalled +{ + private const int DifferentValue = 12; + private const int SampleValue = 36; + + [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/Classes/Simple/SimpleForIntTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..c0efa9c --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Classes.Simple.SimpleForIntTests; + +public static class WhenEqualsWithObjectIsCalled +{ + private const int SampleValue = 28; + + [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 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/Classes/Simple/SimpleForIntTests/WhenEqualsWithSimpleForIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenEqualsWithSimpleForIntIsCalled.cs new file mode 100644 index 0000000..506e48f --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenEqualsWithSimpleForIntIsCalled.cs @@ -0,0 +1,49 @@ +namespace Monify.Console.Classes.Simple.SimpleForIntTests; + +public static class WhenEqualsWithSimpleForIntIsCalled +{ + private const int DifferentValue = 5; + private const int SampleValue = 51; + + [Fact] + public static void GivenOtherHasSameValueThenReturnTrue() + { + // Arrange + SimpleForInt subject = new(SampleValue); + SimpleForInt other = new(SampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenOtherIsNullThenReturnFalse() + { + // Arrange + SimpleForInt subject = new(SampleValue); + SimpleForInt? other = default; + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenOtherHasDifferentValueThenReturnFalse() + { + // Arrange + SimpleForInt subject = new(SampleValue); + SimpleForInt other = new(DifferentValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeFalse(); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..b71acbd --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Classes.Simple.SimpleForIntTests; + +public static class WhenGetHashCodeIsCalled +{ + private const int FirstValue = 3; + private const int SecondValue = 4; + + [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/Classes/Simple/SimpleForIntTests/WhenImplicitOperatorFromIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenImplicitOperatorFromIntIsCalled.cs new file mode 100644 index 0000000..296bbe3 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenImplicitOperatorFromIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Simple.SimpleForIntTests; + +public static class WhenImplicitOperatorFromIntIsCalled +{ + private const int SampleValue = 77; + + [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/Classes/Simple/SimpleForIntTests/WhenImplicitOperatorToIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenImplicitOperatorToIntIsCalled.cs new file mode 100644 index 0000000..6e48d22 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenImplicitOperatorToIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Classes.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/Classes/Simple/SimpleForIntTests/WhenInequalityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenInequalityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..bf9d622 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenInequalityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Classes.Simple.SimpleForIntTests; + +public static class WhenInequalityOperatorWithIntIsCalled +{ + private const int DifferentValue = 9; + private const int SampleValue = 7; + + [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/Classes/Simple/SimpleForIntTests/WhenInequalityOperatorWithSimpleForIntIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenInequalityOperatorWithSimpleForIntIsCalled.cs new file mode 100644 index 0000000..8b7f62c --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenInequalityOperatorWithSimpleForIntIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Classes.Simple.SimpleForIntTests; + +public static class WhenInequalityOperatorWithSimpleForIntIsCalled +{ + private const int DifferentValue = 64; + private const int SampleValue = 63; + + [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/Classes/Simple/SimpleForIntTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..68da357 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +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 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/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..89a88a0 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForStringTests/WhenEqualityOperatorWithSimpleForStringIsCalled.cs @@ -0,0 +1,79 @@ +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 GivenEquivalentValuesThenReturnTrue() + { + // Arrange + string leftValue = new(SampleValue.ToCharArray()); + string rightValue = new(SampleValue.ToCharArray()); + SimpleForString left = new(leftValue); + SimpleForString right = new(rightValue); + + // 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..3860bb3 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForStringTests/WhenEqualityOperatorWithStringIsCalled.cs @@ -0,0 +1,61 @@ +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 GivenEquivalentValueThenReturnTrue() + { + // Arrange + string subjectValue = new(SampleValue.ToCharArray()); + string comparisonValue = new(SampleValue.ToCharArray()); + SimpleForString subject = new(subjectValue); + + // Act + bool actual = subject == comparisonValue; + + // 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..0ef1770 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForStringTests/WhenInequalityOperatorWithSimpleForStringIsCalled.cs @@ -0,0 +1,51 @@ +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 GivenEquivalentValuesThenReturnFalse() + { + // Arrange + string leftValue = new(SampleValue.ToCharArray()); + string rightValue = new(SampleValue.ToCharArray()); + SimpleForString left = new(leftValue); + SimpleForString right = new(rightValue); + + // 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..43d941e --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForStringTests/WhenInequalityOperatorWithStringIsCalled.cs @@ -0,0 +1,61 @@ +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 GivenEquivalentValueThenReturnFalse() + { + // Arrange + string subjectValue = new(SampleValue.ToCharArray()); + string comparisonValue = new(SampleValue.ToCharArray()); + SimpleForString subject = new(subjectValue); + + // Act + bool actual = subject != comparisonValue; + + // 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/Monify.Console.Tests.csproj b/src/Monify.Console.Tests/Monify.Console.Tests.csproj new file mode 100644 index 0000000..c698432 --- /dev/null +++ b/src/Monify.Console.Tests/Monify.Console.Tests.csproj @@ -0,0 +1,16 @@ + + + + all + runtime; build; native; contentfiles; analyzers + + + all + runtime; build; native; contentfiles; analyzers + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..6c17b1f --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForArrayTests; + +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/WhenEqualityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/WhenEqualityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..7b3c739 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/WhenEqualityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForArrayTests; + +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/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..1d2f532 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,79 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForArrayTests; + +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 GivenEquivalentValuesThenReturnFalse() + { + // Arrange + int[] leftValues = [1, 2, 3]; + int[] rightValues = [1, 2, 3]; + OutterForArray.Inner left = new(leftValues); + OutterForArray.Inner right = new(rightValues); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [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/WhenEqualsWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/WhenEqualsWithIntArrayIsCalled.cs new file mode 100644 index 0000000..725b78b --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/WhenEqualsWithIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForArrayTests; + +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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..ff211a4 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForArrayTests; + +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/WhenEqualsWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..8945ab2 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForArrayTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..ddedc3a --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForArrayTests; + +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/WhenImplicitOperatorFromIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/WhenImplicitOperatorFromIntArrayIsCalled.cs new file mode 100644 index 0000000..0294ea9 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/WhenImplicitOperatorFromIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForArrayTests; + +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/WhenImplicitOperatorToIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/WhenImplicitOperatorToIntArrayIsCalled.cs new file mode 100644 index 0000000..4a37b41 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/WhenImplicitOperatorToIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForArrayTests; + +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/WhenInequalityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/WhenInequalityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..e0e8b6c --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/WhenInequalityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForArrayTests; + +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/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..e456a0f --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,51 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForArrayTests; + +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 GivenEquivalentValuesThenReturnTrue() + { + // Arrange + int[] leftValues = [1, 2, 3]; + int[] rightValues = [1, 2, 3]; + OutterForArray.Inner left = new(leftValues); + OutterForArray.Inner right = new(rightValues); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } + + [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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..5bb1d5b --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForArrayTests/WhenToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForArrayTests; + +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/OutterForImmutableArrayTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForImmutableArrayTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..c3a9142 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForImmutableArrayTests/WhenConstructorIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenConstructorIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForImmutableArray.Inner instance = new(_sampleValue); + + // Act + ImmutableArray actual = instance; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InClass/OutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..d86f269 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs @@ -0,0 +1,48 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualityOperatorWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner? subject = default; + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForImmutableArrayTests/WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..6776909 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForImmutableArrayTests/WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,81 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner? left = default; + OutterForImmutableArray.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner? left = default; + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenEquivalentValuesThenReturnFalse() + { + // Arrange + ImmutableArray leftValues = ["Alpha", "Beta", "Gamma"]; + ImmutableArray rightValues = ["Alpha", "Beta", "Gamma"]; + OutterForImmutableArray.Inner left = new(leftValues); + OutterForImmutableArray.Inner right = new(rightValues); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..5fadf36 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_sampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..7114cf5 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,49 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithObjectIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentOutterForImmutableArrayInnerThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + object other = new OutterForImmutableArray.Inner(_sampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenReturnFalse() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualsWithOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForImmutableArrayTests/WhenEqualsWithOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..e9bec05 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForImmutableArrayTests/WhenEqualsWithOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..104d33a --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,39 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenGetHashCodeIsCalled +{ + private static readonly ImmutableArray _firstValue = ["Eta", "Theta", "Iota"]; + private static readonly ImmutableArray _secondValue = ["Kappa", "Lambda", "Mu"]; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForImmutableArray.Inner first = new(_firstValue); + OutterForImmutableArray.Inner second = new(_firstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForImmutableArray.Inner first = new(_firstValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs new file mode 100644 index 0000000..d54883b --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenImplicitOperatorFromImmutableArrayIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForImmutableArray.Inner result = _sampleValue; + + // Act + ImmutableArray actual = result; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InClass/OutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs new file mode 100644 index 0000000..103589d --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenImplicitOperatorToImmutableArrayIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + OutterForImmutableArray.Inner? subject = default; + + // Act + Action act = () => _ = (ImmutableArray)subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + ImmutableArray actual = subject; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InClass/OutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..451eae9 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs @@ -0,0 +1,48 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenInequalityOperatorWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner? subject = default; + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForImmutableArrayTests/WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..0f1b2d5 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForImmutableArrayTests/WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,53 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentValuesThenReturnTrue() + { + // Arrange + ImmutableArray leftValues = ["Alpha", "Beta", "Gamma"]; + ImmutableArray rightValues = ["Alpha", "Beta", "Gamma"]; + OutterForImmutableArray.Inner left = new(leftValues); + OutterForImmutableArray.Inner right = new(rightValues); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForImmutableArrayTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..d480285 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForImmutableArrayTests/WhenToStringIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenToStringIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenReturnRecordDescription() + { + // Arrange + OutterForImmutableArray.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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..ad15ef0 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForIntTests; + +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/WhenEqualityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/WhenEqualityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..012a354 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/WhenEqualityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForIntTests; + +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/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..62d9574 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForIntTests; + +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/WhenEqualsWithIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/WhenEqualsWithIntIsCalled.cs new file mode 100644 index 0000000..f3bed8f --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/WhenEqualsWithIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForIntTests; + +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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..c1a3bd9 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForIntTests; + +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/WhenEqualsWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/WhenEqualsWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..16be97b --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/WhenEqualsWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForIntTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..df9baf8 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForIntTests; + +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/WhenImplicitOperatorFromIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/WhenImplicitOperatorFromIntIsCalled.cs new file mode 100644 index 0000000..d90d4a1 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/WhenImplicitOperatorFromIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForIntTests; + +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/WhenImplicitOperatorToIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/WhenImplicitOperatorToIntIsCalled.cs new file mode 100644 index 0000000..1c74126 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/WhenImplicitOperatorToIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForIntTests; + +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/WhenInequalityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/WhenInequalityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..b338a4a --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/WhenInequalityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForIntTests; + +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/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..3b15445 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForIntTests; + +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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..c2b7385 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForIntTests/WhenToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForIntTests; + +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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..d6f9abd --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForStringTests; + +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/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..841ff82 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,79 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForStringTests; + +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 GivenEquivalentValuesThenReturnTrue() + { + // Arrange + string leftValue = new(SampleValue.ToCharArray()); + string rightValue = new(SampleValue.ToCharArray()); + OutterForString.Inner left = new(leftValue); + OutterForString.Inner right = new(rightValue); + + // 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/WhenEqualityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/WhenEqualityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..196019b --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/WhenEqualityOperatorWithStringIsCalled.cs @@ -0,0 +1,61 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForStringTests; + +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 GivenEquivalentValueThenReturnTrue() + { + // Arrange + string subjectValue = new(SampleValue.ToCharArray()); + string comparisonValue = new(SampleValue.ToCharArray()); + OutterForString.Inner subject = new(subjectValue); + + // Act + bool actual = subject == comparisonValue; + + // 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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..17dd8d9 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForStringTests; + +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/WhenEqualsWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/WhenEqualsWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..4ceffeb --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/WhenEqualsWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForStringTests; + +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/WhenEqualsWithStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/WhenEqualsWithStringIsCalled.cs new file mode 100644 index 0000000..c6cc8ca --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/WhenEqualsWithStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForStringTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..9d84d93 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForStringTests; + +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/WhenImplicitOperatorFromStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/WhenImplicitOperatorFromStringIsCalled.cs new file mode 100644 index 0000000..6ce709e --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/WhenImplicitOperatorFromStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForStringTests; + +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/WhenImplicitOperatorToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/WhenImplicitOperatorToStringIsCalled.cs new file mode 100644 index 0000000..9fa4803 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/WhenImplicitOperatorToStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForStringTests; + +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/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..b076889 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,51 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForStringTests; + +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 GivenEquivalentValuesThenReturnFalse() + { + // Arrange + string leftValue = new(SampleValue.ToCharArray()); + string rightValue = new(SampleValue.ToCharArray()); + OutterForString.Inner left = new(leftValue); + OutterForString.Inner right = new(rightValue); + + // 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/WhenInequalityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/WhenInequalityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..4829195 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/WhenInequalityOperatorWithStringIsCalled.cs @@ -0,0 +1,61 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForStringTests; + +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 GivenEquivalentValueThenReturnFalse() + { + // Arrange + string subjectValue = new(SampleValue.ToCharArray()); + string comparisonValue = new(SampleValue.ToCharArray()); + OutterForString.Inner subject = new(subjectValue); + + // Act + bool actual = subject != comparisonValue; + + // 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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..0a3876d --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InClass/OutterForStringTests/WhenToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InClass.OutterForStringTests; + +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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..7fd9358 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForArrayTests; + +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/WhenEqualityOperatorWithIOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/WhenEqualityOperatorWithIOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..c470ebd --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/WhenEqualityOperatorWithIOutterForArrayInnerIsCalled.cs @@ -0,0 +1,79 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForArrayTests; + +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 GivenEquivalentValuesThenReturnFalse() + { + // Arrange + int[] leftValues = [1, 2, 3]; + int[] rightValues = [1, 2, 3]; + IOutterForArray.Inner left = new(leftValues); + IOutterForArray.Inner right = new(rightValues); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [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/WhenEqualityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/WhenEqualityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..008b108 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/WhenEqualityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForArrayTests; + +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/WhenEqualsWithIOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/WhenEqualsWithIOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..a1323fc --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/WhenEqualsWithIOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForArrayTests; + +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/WhenEqualsWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/WhenEqualsWithIntArrayIsCalled.cs new file mode 100644 index 0000000..c2c4d05 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/WhenEqualsWithIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForArrayTests; + +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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..d47ea93 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForArrayTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..4fa5eb4 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForArrayTests; + +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/WhenImplicitOperatorFromIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/WhenImplicitOperatorFromIntArrayIsCalled.cs new file mode 100644 index 0000000..eb7ba2a --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/WhenImplicitOperatorFromIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForArrayTests; + +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/WhenImplicitOperatorToIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/WhenImplicitOperatorToIntArrayIsCalled.cs new file mode 100644 index 0000000..e28f40b --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/WhenImplicitOperatorToIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForArrayTests; + +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/WhenInequalityOperatorWithIOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/WhenInequalityOperatorWithIOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..e95eb00 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/WhenInequalityOperatorWithIOutterForArrayInnerIsCalled.cs @@ -0,0 +1,51 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForArrayTests; + +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 GivenEquivalentValuesThenReturnTrue() + { + // Arrange + int[] leftValues = [1, 2, 3]; + int[] rightValues = [1, 2, 3]; + IOutterForArray.Inner left = new(leftValues); + IOutterForArray.Inner right = new(rightValues); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } + + [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/WhenInequalityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/WhenInequalityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..d478bd8 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/WhenInequalityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForArrayTests; + +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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..1c94238 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForArrayTests/WhenToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForArrayTests; + +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/IOutterForImmutableArrayTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForImmutableArrayTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..3f27c12 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForImmutableArrayTests/WhenConstructorIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenConstructorIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + IOutterForImmutableArray.Inner instance = new(_sampleValue); + + // Act + ImmutableArray actual = instance; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForImmutableArrayTests/WhenEqualityOperatorWithIOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForImmutableArrayTests/WhenEqualityOperatorWithIOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..5e3d04a --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForImmutableArrayTests/WhenEqualityOperatorWithIOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,81 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualityOperatorWithIOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + IOutterForImmutableArray.Inner? left = default; + IOutterForImmutableArray.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + IOutterForImmutableArray.Inner? left = default; + IOutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForImmutableArray.Inner left = new(_sampleValue); + IOutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenEquivalentValuesThenReturnFalse() + { + // Arrange + ImmutableArray leftValues = ["Alpha", "Beta", "Gamma"]; + ImmutableArray rightValues = ["Alpha", "Beta", "Gamma"]; + IOutterForImmutableArray.Inner left = new(leftValues); + IOutterForImmutableArray.Inner right = new(rightValues); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + IOutterForImmutableArray.Inner left = new(_sampleValue); + IOutterForImmutableArray.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/IOutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..7136271 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs @@ -0,0 +1,48 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualityOperatorWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + IOutterForImmutableArray.Inner? subject = default; + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + IOutterForImmutableArray.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/IOutterForImmutableArrayTests/WhenEqualsWithIOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForImmutableArrayTests/WhenEqualsWithIOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..87b3fe3 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForImmutableArrayTests/WhenEqualsWithIOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithIOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForImmutableArray.Inner left = new(_sampleValue); + IOutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + IOutterForImmutableArray.Inner left = new(_sampleValue); + IOutterForImmutableArray.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/IOutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..bdd383b --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_sampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + IOutterForImmutableArray.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/IOutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..fc3326e --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,49 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithObjectIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + IOutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentIOutterForImmutableArrayInnerThenReturnTrue() + { + // Arrange + IOutterForImmutableArray.Inner subject = new(_sampleValue); + object other = new IOutterForImmutableArray.Inner(_sampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenReturnFalse() + { + // Arrange + IOutterForImmutableArray.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/IOutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..bc28806 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,39 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenGetHashCodeIsCalled +{ + private static readonly ImmutableArray _firstValue = ["Eta", "Theta", "Iota"]; + private static readonly ImmutableArray _secondValue = ["Kappa", "Lambda", "Mu"]; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + IOutterForImmutableArray.Inner first = new(_firstValue); + IOutterForImmutableArray.Inner second = new(_firstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + IOutterForImmutableArray.Inner first = new(_firstValue); + IOutterForImmutableArray.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/IOutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs new file mode 100644 index 0000000..313f5ae --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenImplicitOperatorFromImmutableArrayIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + IOutterForImmutableArray.Inner result = _sampleValue; + + // Act + ImmutableArray actual = result; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs new file mode 100644 index 0000000..94f5a0f --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenImplicitOperatorToImmutableArrayIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + IOutterForImmutableArray.Inner? subject = default; + + // Act + Action act = () => _ = (ImmutableArray)subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + IOutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + ImmutableArray actual = subject; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForImmutableArrayTests/WhenInequalityOperatorWithIOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForImmutableArrayTests/WhenInequalityOperatorWithIOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..2943598 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForImmutableArrayTests/WhenInequalityOperatorWithIOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,53 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenInequalityOperatorWithIOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + IOutterForImmutableArray.Inner left = new(_sampleValue); + IOutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentValuesThenReturnTrue() + { + // Arrange + ImmutableArray leftValues = ["Alpha", "Beta", "Gamma"]; + ImmutableArray rightValues = ["Alpha", "Beta", "Gamma"]; + IOutterForImmutableArray.Inner left = new(leftValues); + IOutterForImmutableArray.Inner right = new(rightValues); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + IOutterForImmutableArray.Inner left = new(_sampleValue); + IOutterForImmutableArray.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/IOutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..559e8d6 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs @@ -0,0 +1,48 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenInequalityOperatorWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + IOutterForImmutableArray.Inner? subject = default; + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + IOutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + IOutterForImmutableArray.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/IOutterForImmutableArrayTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForImmutableArrayTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..64a6343 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForImmutableArrayTests/WhenToStringIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenToStringIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenReturnRecordDescription() + { + // Arrange + IOutterForImmutableArray.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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..ed612d8 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForIntTests; + +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/WhenEqualityOperatorWithIOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/WhenEqualityOperatorWithIOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..c18b8b9 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/WhenEqualityOperatorWithIOutterForIntInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForIntTests; + +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/WhenEqualityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/WhenEqualityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..b18037c --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/WhenEqualityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForIntTests; + +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/WhenEqualsWithIOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/WhenEqualsWithIOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..faf4528 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/WhenEqualsWithIOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForIntTests; + +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/WhenEqualsWithIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/WhenEqualsWithIntIsCalled.cs new file mode 100644 index 0000000..309bf36 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/WhenEqualsWithIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForIntTests; + +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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..038d2ce --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForIntTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..d51d927 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForIntTests; + +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/WhenImplicitOperatorFromIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/WhenImplicitOperatorFromIntIsCalled.cs new file mode 100644 index 0000000..198bc49 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/WhenImplicitOperatorFromIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForIntTests; + +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/WhenImplicitOperatorToIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/WhenImplicitOperatorToIntIsCalled.cs new file mode 100644 index 0000000..3be47c1 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/WhenImplicitOperatorToIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForIntTests; + +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/WhenInequalityOperatorWithIOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/WhenInequalityOperatorWithIOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..6d1aa6d --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/WhenInequalityOperatorWithIOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForIntTests; + +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/WhenInequalityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/WhenInequalityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..0c60b7c --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/WhenInequalityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForIntTests; + +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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..7a545b2 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForIntTests/WhenToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForIntTests; + +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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..976b42a --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForStringTests; + +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/WhenEqualityOperatorWithIOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/WhenEqualityOperatorWithIOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..919acb3 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/WhenEqualityOperatorWithIOutterForStringInnerIsCalled.cs @@ -0,0 +1,79 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForStringTests; + +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 GivenEquivalentValuesThenReturnTrue() + { + // Arrange + string leftValue = new(SampleValue.ToCharArray()); + string rightValue = new(SampleValue.ToCharArray()); + IOutterForString.Inner left = new(leftValue); + IOutterForString.Inner right = new(rightValue); + + // 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/WhenEqualityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/WhenEqualityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..59a51f0 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/WhenEqualityOperatorWithStringIsCalled.cs @@ -0,0 +1,61 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForStringTests; + +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 GivenEquivalentValueThenReturnTrue() + { + // Arrange + string subjectValue = new(SampleValue.ToCharArray()); + string comparisonValue = new(SampleValue.ToCharArray()); + IOutterForString.Inner subject = new(subjectValue); + + // Act + bool actual = subject == comparisonValue; + + // 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/WhenEqualsWithIOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/WhenEqualsWithIOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..5d075a2 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/WhenEqualsWithIOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForStringTests; + +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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..8b2466e --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForStringTests; + +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/WhenEqualsWithStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/WhenEqualsWithStringIsCalled.cs new file mode 100644 index 0000000..a33b297 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/WhenEqualsWithStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForStringTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..7c19bb9 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForStringTests; + +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/WhenImplicitOperatorFromStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/WhenImplicitOperatorFromStringIsCalled.cs new file mode 100644 index 0000000..711bce0 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/WhenImplicitOperatorFromStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForStringTests; + +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/WhenImplicitOperatorToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/WhenImplicitOperatorToStringIsCalled.cs new file mode 100644 index 0000000..28f7f52 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/WhenImplicitOperatorToStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForStringTests; + +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/WhenInequalityOperatorWithIOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/WhenInequalityOperatorWithIOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..f29b0ef --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/WhenInequalityOperatorWithIOutterForStringInnerIsCalled.cs @@ -0,0 +1,51 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForStringTests; + +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 GivenEquivalentValuesThenReturnFalse() + { + // Arrange + string leftValue = new(SampleValue.ToCharArray()); + string rightValue = new(SampleValue.ToCharArray()); + IOutterForString.Inner left = new(leftValue); + IOutterForString.Inner right = new(rightValue); + + // 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/WhenInequalityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/WhenInequalityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..333477d --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/WhenInequalityOperatorWithStringIsCalled.cs @@ -0,0 +1,61 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForStringTests; + +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 GivenEquivalentValueThenReturnFalse() + { + // Arrange + string subjectValue = new(SampleValue.ToCharArray()); + string comparisonValue = new(SampleValue.ToCharArray()); + IOutterForString.Inner subject = new(subjectValue); + + // Act + bool actual = subject != comparisonValue; + + // 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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..bf6d7c6 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InInterface/IOutterForStringTests/WhenToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InInterface.IOutterForStringTests; + +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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..c493da8 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForArrayTests; + +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/WhenEqualityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/WhenEqualityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..e6cd0ce --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/WhenEqualityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForArrayTests; + +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/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..4b702cc --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,79 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForArrayTests; + +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 GivenEquivalentValuesThenReturnFalse() + { + // Arrange + int[] leftValues = [1, 2, 3]; + int[] rightValues = [1, 2, 3]; + OutterForArray.Inner left = new(leftValues); + OutterForArray.Inner right = new(rightValues); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [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/WhenEqualsWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/WhenEqualsWithIntArrayIsCalled.cs new file mode 100644 index 0000000..8ad4f74 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/WhenEqualsWithIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForArrayTests; + +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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..35aaeeb --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForArrayTests; + +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/WhenEqualsWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..c66b0eb --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForArrayTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..1a4534e --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForArrayTests; + +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/WhenImplicitOperatorFromIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/WhenImplicitOperatorFromIntArrayIsCalled.cs new file mode 100644 index 0000000..b51fe74 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/WhenImplicitOperatorFromIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForArrayTests; + +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/WhenImplicitOperatorToIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/WhenImplicitOperatorToIntArrayIsCalled.cs new file mode 100644 index 0000000..d12d6db --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/WhenImplicitOperatorToIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForArrayTests; + +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/WhenInequalityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/WhenInequalityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..f58a433 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/WhenInequalityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForArrayTests; + +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/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..5a7796d --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,51 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForArrayTests; + +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 GivenEquivalentValuesThenReturnTrue() + { + // Arrange + int[] leftValues = [1, 2, 3]; + int[] rightValues = [1, 2, 3]; + OutterForArray.Inner left = new(leftValues); + OutterForArray.Inner right = new(rightValues); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } + + [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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..6a7395f --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForArrayTests/WhenToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForArrayTests; + +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/OutterForImmutableArrayTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForImmutableArrayTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..68619ac --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForImmutableArrayTests/WhenConstructorIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenConstructorIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForImmutableArray.Inner instance = new(_sampleValue); + + // Act + ImmutableArray actual = instance; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..f0af24a --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs @@ -0,0 +1,48 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualityOperatorWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner? subject = default; + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForImmutableArrayTests/WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..5de747f --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForImmutableArrayTests/WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,81 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner? left = default; + OutterForImmutableArray.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner? left = default; + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenEquivalentValuesThenReturnFalse() + { + // Arrange + ImmutableArray leftValues = ["Alpha", "Beta", "Gamma"]; + ImmutableArray rightValues = ["Alpha", "Beta", "Gamma"]; + OutterForImmutableArray.Inner left = new(leftValues); + OutterForImmutableArray.Inner right = new(rightValues); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..8d25817 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_sampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..71e5d55 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,49 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithObjectIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentOutterForImmutableArrayInnerThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + object other = new OutterForImmutableArray.Inner(_sampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenReturnFalse() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualsWithOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForImmutableArrayTests/WhenEqualsWithOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..d352eac --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForImmutableArrayTests/WhenEqualsWithOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..6f48636 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,39 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenGetHashCodeIsCalled +{ + private static readonly ImmutableArray _firstValue = ["Eta", "Theta", "Iota"]; + private static readonly ImmutableArray _secondValue = ["Kappa", "Lambda", "Mu"]; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForImmutableArray.Inner first = new(_firstValue); + OutterForImmutableArray.Inner second = new(_firstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForImmutableArray.Inner first = new(_firstValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs new file mode 100644 index 0000000..41cf4c1 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenImplicitOperatorFromImmutableArrayIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForImmutableArray.Inner result = _sampleValue; + + // Act + ImmutableArray actual = result; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs new file mode 100644 index 0000000..298f02c --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenImplicitOperatorToImmutableArrayIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + OutterForImmutableArray.Inner? subject = default; + + // Act + Action act = () => _ = (ImmutableArray)subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + ImmutableArray actual = subject; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..809a2d6 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs @@ -0,0 +1,48 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenInequalityOperatorWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner? subject = default; + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForImmutableArrayTests/WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..aae046f --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForImmutableArrayTests/WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,53 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentValuesThenReturnTrue() + { + // Arrange + ImmutableArray leftValues = ["Alpha", "Beta", "Gamma"]; + ImmutableArray rightValues = ["Alpha", "Beta", "Gamma"]; + OutterForImmutableArray.Inner left = new(leftValues); + OutterForImmutableArray.Inner right = new(rightValues); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForImmutableArrayTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..32929b0 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForImmutableArrayTests/WhenToStringIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenToStringIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenReturnRecordDescription() + { + // Arrange + OutterForImmutableArray.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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..acb2cca --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForIntTests; + +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/WhenEqualityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/WhenEqualityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..9560cdf --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/WhenEqualityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForIntTests; + +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/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..fee0040 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForIntTests; + +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/WhenEqualsWithIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/WhenEqualsWithIntIsCalled.cs new file mode 100644 index 0000000..84a26f9 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/WhenEqualsWithIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForIntTests; + +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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..9371b2c --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForIntTests; + +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/WhenEqualsWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/WhenEqualsWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..dfaf2b8 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/WhenEqualsWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForIntTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..a6a73b6 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForIntTests; + +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/WhenImplicitOperatorFromIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/WhenImplicitOperatorFromIntIsCalled.cs new file mode 100644 index 0000000..9d89192 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/WhenImplicitOperatorFromIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForIntTests; + +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/WhenImplicitOperatorToIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/WhenImplicitOperatorToIntIsCalled.cs new file mode 100644 index 0000000..705d712 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/WhenImplicitOperatorToIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForIntTests; + +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/WhenInequalityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/WhenInequalityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..3ef1df4 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/WhenInequalityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForIntTests; + +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/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..7414374 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForIntTests; + +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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..bed3007 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForIntTests/WhenToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForIntTests; + +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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..0887f1b --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForStringTests; + +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/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..355881c --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,79 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForStringTests; + +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 GivenEquivalentValuesThenReturnTrue() + { + // Arrange + string leftValue = new(SampleValue.ToCharArray()); + string rightValue = new(SampleValue.ToCharArray()); + OutterForString.Inner left = new(leftValue); + OutterForString.Inner right = new(rightValue); + + // 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/WhenEqualityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/WhenEqualityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..c0ce4d0 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/WhenEqualityOperatorWithStringIsCalled.cs @@ -0,0 +1,61 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForStringTests; + +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 GivenEquivalentValueThenReturnTrue() + { + // Arrange + string subjectValue = new(SampleValue.ToCharArray()); + string comparisonValue = new(SampleValue.ToCharArray()); + OutterForString.Inner subject = new(subjectValue); + + // Act + bool actual = subject == comparisonValue; + + // 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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..a90b93c --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForStringTests; + +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/WhenEqualsWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/WhenEqualsWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..a8c4b77 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/WhenEqualsWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForStringTests; + +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/WhenEqualsWithStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/WhenEqualsWithStringIsCalled.cs new file mode 100644 index 0000000..575cadc --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/WhenEqualsWithStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForStringTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..cfaa56f --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForStringTests; + +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/WhenImplicitOperatorFromStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/WhenImplicitOperatorFromStringIsCalled.cs new file mode 100644 index 0000000..5c80f96 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/WhenImplicitOperatorFromStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForStringTests; + +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/WhenImplicitOperatorToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/WhenImplicitOperatorToStringIsCalled.cs new file mode 100644 index 0000000..d11e51a --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/WhenImplicitOperatorToStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForStringTests; + +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/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..fb9f1dd --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,51 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForStringTests; + +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 GivenEquivalentValuesThenReturnFalse() + { + // Arrange + string leftValue = new(SampleValue.ToCharArray()); + string rightValue = new(SampleValue.ToCharArray()); + OutterForString.Inner left = new(leftValue); + OutterForString.Inner right = new(rightValue); + + // 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/WhenInequalityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/WhenInequalityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..e094102 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/WhenInequalityOperatorWithStringIsCalled.cs @@ -0,0 +1,61 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForStringTests; + +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 GivenEquivalentValueThenReturnFalse() + { + // Arrange + string subjectValue = new(SampleValue.ToCharArray()); + string comparisonValue = new(SampleValue.ToCharArray()); + OutterForString.Inner subject = new(subjectValue); + + // Act + bool actual = subject != comparisonValue; + + // 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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..c5ca5b7 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecord/OutterForStringTests/WhenToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InRecord.OutterForStringTests; + +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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..404da34 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForArrayTests; + +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/WhenEqualityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/WhenEqualityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..b999020 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/WhenEqualityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForArrayTests; + +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/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..9dd1a0e --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,79 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForArrayTests; + +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 GivenEquivalentValuesThenReturnFalse() + { + // Arrange + int[] leftValues = [1, 2, 3]; + int[] rightValues = [1, 2, 3]; + OutterForArray.Inner left = new(leftValues); + OutterForArray.Inner right = new(rightValues); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [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/WhenEqualsWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/WhenEqualsWithIntArrayIsCalled.cs new file mode 100644 index 0000000..10acab5 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/WhenEqualsWithIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForArrayTests; + +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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..77ab582 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForArrayTests; + +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/WhenEqualsWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..0684356 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForArrayTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..49cdc02 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForArrayTests; + +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/WhenImplicitOperatorFromIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/WhenImplicitOperatorFromIntArrayIsCalled.cs new file mode 100644 index 0000000..7b2b1c9 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/WhenImplicitOperatorFromIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForArrayTests; + +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/WhenImplicitOperatorToIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/WhenImplicitOperatorToIntArrayIsCalled.cs new file mode 100644 index 0000000..969c2e2 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/WhenImplicitOperatorToIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForArrayTests; + +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/WhenInequalityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/WhenInequalityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..111c951 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/WhenInequalityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForArrayTests; + +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/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..bdce581 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,51 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForArrayTests; + +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 GivenEquivalentValuesThenReturnTrue() + { + // Arrange + int[] leftValues = [1, 2, 3]; + int[] rightValues = [1, 2, 3]; + OutterForArray.Inner left = new(leftValues); + OutterForArray.Inner right = new(rightValues); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } + + [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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..fbfb6eb --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForArrayTests/WhenToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForArrayTests; + +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/OutterForImmutableArrayTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..9684e7a --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenConstructorIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenConstructorIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForImmutableArray.Inner instance = new(_sampleValue); + + // Act + ImmutableArray actual = instance; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..949c679 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs @@ -0,0 +1,48 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualityOperatorWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner? subject = default; + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..51bc9d2 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,81 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner? left = default; + OutterForImmutableArray.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner? left = default; + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenEquivalentValuesThenReturnFalse() + { + // Arrange + ImmutableArray leftValues = ["Alpha", "Beta", "Gamma"]; + ImmutableArray rightValues = ["Alpha", "Beta", "Gamma"]; + OutterForImmutableArray.Inner left = new(leftValues); + OutterForImmutableArray.Inner right = new(rightValues); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..46b6bc8 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_sampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..d88bd10 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,49 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithObjectIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentOutterForImmutableArrayInnerThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + object other = new OutterForImmutableArray.Inner(_sampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenReturnFalse() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualsWithOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenEqualsWithOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..b55028d --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenEqualsWithOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..ddf6968 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,39 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenGetHashCodeIsCalled +{ + private static readonly ImmutableArray _firstValue = ["Eta", "Theta", "Iota"]; + private static readonly ImmutableArray _secondValue = ["Kappa", "Lambda", "Mu"]; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForImmutableArray.Inner first = new(_firstValue); + OutterForImmutableArray.Inner second = new(_firstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForImmutableArray.Inner first = new(_firstValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs new file mode 100644 index 0000000..b49095b --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenImplicitOperatorFromImmutableArrayIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForImmutableArray.Inner result = _sampleValue; + + // Act + ImmutableArray actual = result; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs new file mode 100644 index 0000000..0e31e3d --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenImplicitOperatorToImmutableArrayIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + OutterForImmutableArray.Inner? subject = default; + + // Act + Action act = () => _ = (ImmutableArray)subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + ImmutableArray actual = subject; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..c6d9e57 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs @@ -0,0 +1,48 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenInequalityOperatorWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner? subject = default; + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..071cd3c --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,53 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentValuesThenReturnTrue() + { + // Arrange + ImmutableArray leftValues = ["Alpha", "Beta", "Gamma"]; + ImmutableArray rightValues = ["Alpha", "Beta", "Gamma"]; + OutterForImmutableArray.Inner left = new(leftValues); + OutterForImmutableArray.Inner right = new(rightValues); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..acda113 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenToStringIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenToStringIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenReturnRecordDescription() + { + // Arrange + OutterForImmutableArray.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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..16d5257 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForIntTests; + +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/WhenEqualityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/WhenEqualityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..723cfe5 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/WhenEqualityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForIntTests; + +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/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..aa6040d --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForIntTests; + +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/WhenEqualsWithIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/WhenEqualsWithIntIsCalled.cs new file mode 100644 index 0000000..20023a3 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/WhenEqualsWithIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForIntTests; + +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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..84ba7e6 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForIntTests; + +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/WhenEqualsWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/WhenEqualsWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..1193a28 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/WhenEqualsWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForIntTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..a1a626c --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForIntTests; + +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/WhenImplicitOperatorFromIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/WhenImplicitOperatorFromIntIsCalled.cs new file mode 100644 index 0000000..6ce3916 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/WhenImplicitOperatorFromIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForIntTests; + +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/WhenImplicitOperatorToIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/WhenImplicitOperatorToIntIsCalled.cs new file mode 100644 index 0000000..754c014 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/WhenImplicitOperatorToIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForIntTests; + +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/WhenInequalityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/WhenInequalityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..9147376 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/WhenInequalityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForIntTests; + +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/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..0246bf7 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForIntTests; + +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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..614da8e --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForIntTests/WhenToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForIntTests; + +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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..c683829 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForStringTests; + +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/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..7e001e8 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,79 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForStringTests; + +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 GivenEquivalentValuesThenReturnTrue() + { + // Arrange + string leftValue = new(SampleValue.ToCharArray()); + string rightValue = new(SampleValue.ToCharArray()); + OutterForString.Inner left = new(leftValue); + OutterForString.Inner right = new(rightValue); + + // 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/WhenEqualityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/WhenEqualityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..1b5930c --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/WhenEqualityOperatorWithStringIsCalled.cs @@ -0,0 +1,61 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForStringTests; + +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 GivenEquivalentValueThenReturnTrue() + { + // Arrange + string subjectValue = new(SampleValue.ToCharArray()); + string comparisonValue = new(SampleValue.ToCharArray()); + OutterForString.Inner subject = new(subjectValue); + + // Act + bool actual = subject == comparisonValue; + + // 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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..cb2d7d6 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForStringTests; + +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/WhenEqualsWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/WhenEqualsWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..a7dfbee --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/WhenEqualsWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForStringTests; + +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/WhenEqualsWithStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/WhenEqualsWithStringIsCalled.cs new file mode 100644 index 0000000..04c5ad9 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/WhenEqualsWithStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForStringTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..c863f43 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForStringTests; + +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/WhenImplicitOperatorFromStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/WhenImplicitOperatorFromStringIsCalled.cs new file mode 100644 index 0000000..bb90141 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/WhenImplicitOperatorFromStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForStringTests; + +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/WhenImplicitOperatorToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/WhenImplicitOperatorToStringIsCalled.cs new file mode 100644 index 0000000..c46a38b --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/WhenImplicitOperatorToStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForStringTests; + +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/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..13ac0cf --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,51 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForStringTests; + +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 GivenEquivalentValuesThenReturnFalse() + { + // Arrange + string leftValue = new(SampleValue.ToCharArray()); + string rightValue = new(SampleValue.ToCharArray()); + OutterForString.Inner left = new(leftValue); + OutterForString.Inner right = new(rightValue); + + // 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/WhenInequalityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/WhenInequalityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..cd49f12 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/WhenInequalityOperatorWithStringIsCalled.cs @@ -0,0 +1,61 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForStringTests; + +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 GivenEquivalentValueThenReturnFalse() + { + // Arrange + string subjectValue = new(SampleValue.ToCharArray()); + string comparisonValue = new(SampleValue.ToCharArray()); + OutterForString.Inner subject = new(subjectValue); + + // Act + bool actual = subject != comparisonValue; + + // 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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..bcb2492 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InRecordStruct/OutterForStringTests/WhenToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InRecordStruct.OutterForStringTests; + +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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..324ab01 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForArrayTests; + +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/WhenEqualityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/WhenEqualityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..70497b3 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/WhenEqualityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForArrayTests; + +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/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..7e04409 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,79 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForArrayTests; + +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 GivenEquivalentValuesThenReturnFalse() + { + // Arrange + int[] leftValues = [1, 2, 3]; + int[] rightValues = [1, 2, 3]; + OutterForArray.Inner left = new(leftValues); + OutterForArray.Inner right = new(rightValues); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [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/WhenEqualsWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/WhenEqualsWithIntArrayIsCalled.cs new file mode 100644 index 0000000..be0c741 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/WhenEqualsWithIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForArrayTests; + +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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..3a3fcdc --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForArrayTests; + +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/WhenEqualsWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..177b68f --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForArrayTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..b082456 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForArrayTests; + +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/WhenImplicitOperatorFromIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/WhenImplicitOperatorFromIntArrayIsCalled.cs new file mode 100644 index 0000000..5091c58 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/WhenImplicitOperatorFromIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForArrayTests; + +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/WhenImplicitOperatorToIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/WhenImplicitOperatorToIntArrayIsCalled.cs new file mode 100644 index 0000000..b82cb37 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/WhenImplicitOperatorToIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForArrayTests; + +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/WhenInequalityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/WhenInequalityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..64f1e9d --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/WhenInequalityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForArrayTests; + +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/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..52428bd --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,51 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForArrayTests; + +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 GivenEquivalentValuesThenReturnTrue() + { + // Arrange + int[] leftValues = [1, 2, 3]; + int[] rightValues = [1, 2, 3]; + OutterForArray.Inner left = new(leftValues); + OutterForArray.Inner right = new(rightValues); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } + + [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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..1ebdad4 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForArrayTests/WhenToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForArrayTests; + +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/OutterForImmutableArrayTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForImmutableArrayTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..3569015 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForImmutableArrayTests/WhenConstructorIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenConstructorIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForImmutableArray.Inner instance = new(_sampleValue); + + // Act + ImmutableArray actual = instance; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..f7733be --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs @@ -0,0 +1,48 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualityOperatorWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner? subject = default; + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForImmutableArrayTests/WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..9d6e018 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForImmutableArrayTests/WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,81 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner? left = default; + OutterForImmutableArray.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner? left = default; + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenEquivalentValuesThenReturnFalse() + { + // Arrange + ImmutableArray leftValues = ["Alpha", "Beta", "Gamma"]; + ImmutableArray rightValues = ["Alpha", "Beta", "Gamma"]; + OutterForImmutableArray.Inner left = new(leftValues); + OutterForImmutableArray.Inner right = new(rightValues); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..bf21048 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_sampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..36d6809 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,49 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithObjectIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentOutterForImmutableArrayInnerThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + object other = new OutterForImmutableArray.Inner(_sampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenReturnFalse() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualsWithOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForImmutableArrayTests/WhenEqualsWithOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..37e40ce --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForImmutableArrayTests/WhenEqualsWithOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..ff6b073 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,39 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenGetHashCodeIsCalled +{ + private static readonly ImmutableArray _firstValue = ["Eta", "Theta", "Iota"]; + private static readonly ImmutableArray _secondValue = ["Kappa", "Lambda", "Mu"]; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForImmutableArray.Inner first = new(_firstValue); + OutterForImmutableArray.Inner second = new(_firstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForImmutableArray.Inner first = new(_firstValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs new file mode 100644 index 0000000..d18c69f --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenImplicitOperatorFromImmutableArrayIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForImmutableArray.Inner result = _sampleValue; + + // Act + ImmutableArray actual = result; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs new file mode 100644 index 0000000..4d99e76 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenImplicitOperatorToImmutableArrayIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + OutterForImmutableArray.Inner? subject = default; + + // Act + Action act = () => _ = (ImmutableArray)subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + ImmutableArray actual = subject; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..eacc063 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs @@ -0,0 +1,48 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenInequalityOperatorWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner? subject = default; + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForImmutableArrayTests/WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..5639c9d --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForImmutableArrayTests/WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,53 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentValuesThenReturnTrue() + { + // Arrange + ImmutableArray leftValues = ["Alpha", "Beta", "Gamma"]; + ImmutableArray rightValues = ["Alpha", "Beta", "Gamma"]; + OutterForImmutableArray.Inner left = new(leftValues); + OutterForImmutableArray.Inner right = new(rightValues); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForImmutableArrayTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..aa73335 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForImmutableArrayTests/WhenToStringIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenToStringIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenReturnRecordDescription() + { + // Arrange + OutterForImmutableArray.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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..108f67a --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForIntTests; + +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/WhenEqualityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/WhenEqualityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..4cc3da8 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/WhenEqualityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForIntTests; + +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/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..b948668 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForIntTests; + +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/WhenEqualsWithIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/WhenEqualsWithIntIsCalled.cs new file mode 100644 index 0000000..5d9e716 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/WhenEqualsWithIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForIntTests; + +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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..0ec92c6 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForIntTests; + +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/WhenEqualsWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/WhenEqualsWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..fd278ac --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/WhenEqualsWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForIntTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..619a2ed --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForIntTests; + +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/WhenImplicitOperatorFromIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/WhenImplicitOperatorFromIntIsCalled.cs new file mode 100644 index 0000000..87602e8 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/WhenImplicitOperatorFromIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForIntTests; + +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/WhenImplicitOperatorToIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/WhenImplicitOperatorToIntIsCalled.cs new file mode 100644 index 0000000..b748e7f --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/WhenImplicitOperatorToIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForIntTests; + +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/WhenInequalityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/WhenInequalityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..276a333 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/WhenInequalityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForIntTests; + +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/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..65cb417 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForIntTests; + +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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..85e8f85 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForIntTests/WhenToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForIntTests; + +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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..619eb3d --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForStringTests; + +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/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..1d1e17a --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,79 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForStringTests; + +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 GivenEquivalentValuesThenReturnTrue() + { + // Arrange + string leftValue = new(SampleValue.ToCharArray()); + string rightValue = new(SampleValue.ToCharArray()); + OutterForString.Inner left = new(leftValue); + OutterForString.Inner right = new(rightValue); + + // 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/WhenEqualityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/WhenEqualityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..3a93ad5 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/WhenEqualityOperatorWithStringIsCalled.cs @@ -0,0 +1,61 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForStringTests; + +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 GivenEquivalentValueThenReturnTrue() + { + // Arrange + string subjectValue = new(SampleValue.ToCharArray()); + string comparisonValue = new(SampleValue.ToCharArray()); + OutterForString.Inner subject = new(subjectValue); + + // Act + bool actual = subject == comparisonValue; + + // 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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..496c56b --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForStringTests; + +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/WhenEqualsWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/WhenEqualsWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..b96967f --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/WhenEqualsWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForStringTests; + +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/WhenEqualsWithStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/WhenEqualsWithStringIsCalled.cs new file mode 100644 index 0000000..5af86ce --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/WhenEqualsWithStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForStringTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..0063eb1 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForStringTests; + +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/WhenImplicitOperatorFromStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/WhenImplicitOperatorFromStringIsCalled.cs new file mode 100644 index 0000000..5656830 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/WhenImplicitOperatorFromStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForStringTests; + +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/WhenImplicitOperatorToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/WhenImplicitOperatorToStringIsCalled.cs new file mode 100644 index 0000000..6c90fdd --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/WhenImplicitOperatorToStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForStringTests; + +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/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..cfba7f0 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,51 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForStringTests; + +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 GivenEquivalentValuesThenReturnFalse() + { + // Arrange + string leftValue = new(SampleValue.ToCharArray()); + string rightValue = new(SampleValue.ToCharArray()); + OutterForString.Inner left = new(leftValue); + OutterForString.Inner right = new(rightValue); + + // 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/WhenInequalityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/WhenInequalityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..18e1f40 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/WhenInequalityOperatorWithStringIsCalled.cs @@ -0,0 +1,61 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForStringTests; + +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 GivenEquivalentValueThenReturnFalse() + { + // Arrange + string subjectValue = new(SampleValue.ToCharArray()); + string comparisonValue = new(SampleValue.ToCharArray()); + OutterForString.Inner subject = new(subjectValue); + + // Act + bool actual = subject != comparisonValue; + + // 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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..8d27e86 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Nested/InStruct/OutterForStringTests/WhenToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Records.Nested.InStruct.OutterForStringTests; + +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..7979df8 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForArrayTests/WhenEqualityOperatorWithSimpleForArrayIsCalled.cs @@ -0,0 +1,79 @@ +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 GivenEquivalentValuesThenReturnFalse() + { + // Arrange + int[] leftValues = [1, 2, 3]; + int[] rightValues = [1, 2, 3]; + SimpleForArray left = new(leftValues); + SimpleForArray right = new(rightValues); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [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..d915d9e --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForArrayTests/WhenInequalityOperatorWithSimpleForArrayIsCalled.cs @@ -0,0 +1,51 @@ +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 GivenEquivalentValuesThenReturnTrue() + { + // Arrange + int[] leftValues = [1, 2, 3]; + int[] rightValues = [1, 2, 3]; + SimpleForArray left = new(leftValues); + SimpleForArray right = new(rightValues); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } + + [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/SimpleForImmutableArrayTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForImmutableArrayTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..5e467b9 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForImmutableArrayTests/WhenConstructorIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Records.Simple.SimpleForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenConstructorIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + SimpleForImmutableArray instance = new(_sampleValue); + + // Act + ImmutableArray actual = instance; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Simple/SimpleForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..2674122 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs @@ -0,0 +1,48 @@ +namespace Monify.Console.Records.Simple.SimpleForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualityOperatorWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + SimpleForImmutableArray? subject = default; + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForImmutableArray subject = new(_sampleValue); + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + SimpleForImmutableArray 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/SimpleForImmutableArrayTests/WhenEqualityOperatorWithSimpleForImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForImmutableArrayTests/WhenEqualityOperatorWithSimpleForImmutableArrayIsCalled.cs new file mode 100644 index 0000000..374fc87 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForImmutableArrayTests/WhenEqualityOperatorWithSimpleForImmutableArrayIsCalled.cs @@ -0,0 +1,81 @@ +namespace Monify.Console.Records.Simple.SimpleForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualityOperatorWithSimpleForImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + SimpleForImmutableArray? left = default; + SimpleForImmutableArray? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + SimpleForImmutableArray? left = default; + SimpleForImmutableArray right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForImmutableArray left = new(_sampleValue); + SimpleForImmutableArray right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenEquivalentValuesThenReturnFalse() + { + // Arrange + ImmutableArray leftValues = ["Alpha", "Beta", "Gamma"]; + ImmutableArray rightValues = ["Alpha", "Beta", "Gamma"]; + SimpleForImmutableArray left = new(leftValues); + SimpleForImmutableArray right = new(rightValues); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + SimpleForImmutableArray left = new(_sampleValue); + SimpleForImmutableArray 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/SimpleForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..adf0500 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Simple.SimpleForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForImmutableArray subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_sampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + SimpleForImmutableArray 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/SimpleForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..7355267 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,49 @@ +namespace Monify.Console.Records.Simple.SimpleForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithObjectIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenNullThenReturnFalse() + { + // Arrange + SimpleForImmutableArray subject = new(_sampleValue); + + // Act + bool actual = subject.Equals((object?)default); + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentSimpleForImmutableArrayThenReturnTrue() + { + // Arrange + SimpleForImmutableArray subject = new(_sampleValue); + object other = new SimpleForImmutableArray(_sampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenReturnFalse() + { + // Arrange + SimpleForImmutableArray 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/SimpleForImmutableArrayTests/WhenEqualsWithSimpleForImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForImmutableArrayTests/WhenEqualsWithSimpleForImmutableArrayIsCalled.cs new file mode 100644 index 0000000..8530147 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForImmutableArrayTests/WhenEqualsWithSimpleForImmutableArrayIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Records.Simple.SimpleForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithSimpleForImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForImmutableArray left = new(_sampleValue); + SimpleForImmutableArray right = new(_sampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + SimpleForImmutableArray left = new(_sampleValue); + SimpleForImmutableArray 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/SimpleForImmutableArrayTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForImmutableArrayTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..bef51d2 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForImmutableArrayTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,39 @@ +namespace Monify.Console.Records.Simple.SimpleForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenGetHashCodeIsCalled +{ + private static readonly ImmutableArray _firstValue = ["Eta", "Theta", "Iota"]; + private static readonly ImmutableArray _secondValue = ["Kappa", "Lambda", "Mu"]; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + SimpleForImmutableArray first = new(_firstValue); + SimpleForImmutableArray second = new(_firstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + SimpleForImmutableArray first = new(_firstValue); + SimpleForImmutableArray 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/SimpleForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs new file mode 100644 index 0000000..9f810df --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Records.Simple.SimpleForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenImplicitOperatorFromImmutableArrayIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + SimpleForImmutableArray result = _sampleValue; + + // Act + ImmutableArray actual = result; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Simple/SimpleForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs new file mode 100644 index 0000000..8fbe2d1 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Records.Simple.SimpleForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenImplicitOperatorToImmutableArrayIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenNullSubjectThenThrowsArgumentNullException() + { + // Arrange + SimpleForImmutableArray? subject = default; + + // Act + Action act = () => _ = (ImmutableArray)subject!; + + // Assert + ArgumentNullException exception = Should.Throw(act); + exception.ParamName.ShouldBe(nameof(subject)); + } + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + SimpleForImmutableArray subject = new(_sampleValue); + + // Act + ImmutableArray actual = subject; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Records/Simple/SimpleForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..01cef4d --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs @@ -0,0 +1,48 @@ +namespace Monify.Console.Records.Simple.SimpleForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenInequalityOperatorWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + SimpleForImmutableArray? subject = default; + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + SimpleForImmutableArray subject = new(_sampleValue); + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + SimpleForImmutableArray 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/SimpleForImmutableArrayTests/WhenInequalityOperatorWithSimpleForImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForImmutableArrayTests/WhenInequalityOperatorWithSimpleForImmutableArrayIsCalled.cs new file mode 100644 index 0000000..338d8cd --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForImmutableArrayTests/WhenInequalityOperatorWithSimpleForImmutableArrayIsCalled.cs @@ -0,0 +1,53 @@ +namespace Monify.Console.Records.Simple.SimpleForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenInequalityOperatorWithSimpleForImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + SimpleForImmutableArray left = new(_sampleValue); + SimpleForImmutableArray right = new(_sampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentValuesThenReturnTrue() + { + // Arrange + ImmutableArray leftValues = ["Alpha", "Beta", "Gamma"]; + ImmutableArray rightValues = ["Alpha", "Beta", "Gamma"]; + SimpleForImmutableArray left = new(leftValues); + SimpleForImmutableArray right = new(rightValues); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + SimpleForImmutableArray left = new(_sampleValue); + SimpleForImmutableArray 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/SimpleForImmutableArrayTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Records/Simple/SimpleForImmutableArrayTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..e26fc0c --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForImmutableArrayTests/WhenToStringIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Records.Simple.SimpleForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenToStringIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenReturnRecordDescription() + { + // Arrange + SimpleForImmutableArray subject = new(_sampleValue); + + // Act + string actual = subject.ToString(); + + // Assert + actual.ShouldBe("SimpleForImmutableArray { }"); + } +} \ 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..052c2a2 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForStringTests/WhenEqualityOperatorWithSimpleForStringIsCalled.cs @@ -0,0 +1,79 @@ +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 GivenEquivalentValuesThenReturnTrue() + { + // Arrange + string leftValue = new(SampleValue.ToCharArray()); + string rightValue = new(SampleValue.ToCharArray()); + SimpleForString left = new(leftValue); + SimpleForString right = new(rightValue); + + // 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..9280426 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForStringTests/WhenEqualityOperatorWithStringIsCalled.cs @@ -0,0 +1,61 @@ +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 GivenEquivalentValueThenReturnTrue() + { + // Arrange + string subjectValue = new(SampleValue.ToCharArray()); + string comparisonValue = new(SampleValue.ToCharArray()); + SimpleForString subject = new(subjectValue); + + // Act + bool actual = subject == comparisonValue; + + // 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..850447a --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForStringTests/WhenInequalityOperatorWithSimpleForStringIsCalled.cs @@ -0,0 +1,51 @@ +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 GivenEquivalentValuesThenReturnFalse() + { + // Arrange + string leftValue = new(SampleValue.ToCharArray()); + string rightValue = new(SampleValue.ToCharArray()); + SimpleForString left = new(leftValue); + SimpleForString right = new(rightValue); + + // 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..3b83ac4 --- /dev/null +++ b/src/Monify.Console.Tests/Records/Simple/SimpleForStringTests/WhenInequalityOperatorWithStringIsCalled.cs @@ -0,0 +1,61 @@ +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 GivenEquivalentValueThenReturnFalse() + { + // Arrange + string subjectValue = new(SampleValue.ToCharArray()); + string comparisonValue = new(SampleValue.ToCharArray()); + SimpleForString subject = new(subjectValue); + + // Act + bool actual = subject != comparisonValue; + + // 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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..7036c74 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForArrayTests; + +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/WhenEqualityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/WhenEqualityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..e265a08 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/WhenEqualityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForArrayTests; + +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/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..adca9fa --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,79 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForArrayTests; + +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 GivenEquivalentValuesThenReturnTrue() + { + // Arrange + int[] leftValues = [1, 2, 3]; + int[] rightValues = [1, 2, 3]; + OutterForArray.Inner left = new(leftValues); + OutterForArray.Inner right = new(rightValues); + + // 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/WhenEqualsWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/WhenEqualsWithIntArrayIsCalled.cs new file mode 100644 index 0000000..9088770 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/WhenEqualsWithIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForArrayTests; + +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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..d5b2799 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForArrayTests; + +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/WhenEqualsWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..bd7caae --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForArrayTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..d81a1ab --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForArrayTests; + +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/WhenImplicitOperatorFromIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/WhenImplicitOperatorFromIntArrayIsCalled.cs new file mode 100644 index 0000000..8f9a42e --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/WhenImplicitOperatorFromIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForArrayTests; + +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/WhenImplicitOperatorToIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/WhenImplicitOperatorToIntArrayIsCalled.cs new file mode 100644 index 0000000..6ce9f36 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/WhenImplicitOperatorToIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForArrayTests; + +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/WhenInequalityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/WhenInequalityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..af98cd8 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/WhenInequalityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForArrayTests; + +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/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..e074418 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,51 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForArrayTests; + +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 GivenEquivalentValuesThenReturnFalse() + { + // Arrange + int[] leftValues = [1, 2, 3]; + int[] rightValues = [1, 2, 3]; + OutterForArray.Inner left = new(leftValues); + OutterForArray.Inner right = new(rightValues); + + // 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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..142e7c3 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForArrayTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForArrayTests; + +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/OutterForImmutableArrayTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForImmutableArrayTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..62453dc --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForImmutableArrayTests/WhenConstructorIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenConstructorIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForImmutableArray.Inner instance = new(_sampleValue); + + // Act + ImmutableArray actual = instance; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..a576a79 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs @@ -0,0 +1,48 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualityOperatorWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner? subject = default; + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForImmutableArrayTests/WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..59942d8 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForImmutableArrayTests/WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,81 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner? left = default; + OutterForImmutableArray.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner? left = default; + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenEquivalentValuesThenReturnTrue() + { + // Arrange + ImmutableArray leftValues = ["Alpha", "Beta", "Gamma"]; + ImmutableArray rightValues = ["Alpha", "Beta", "Gamma"]; + OutterForImmutableArray.Inner left = new(leftValues); + OutterForImmutableArray.Inner right = new(rightValues); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..0ec3a20 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_sampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..2e00ee9 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,49 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithObjectIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenNullThenThrowNullReferenceException() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + Action act = () => subject.Equals((object?)default); + + // Assert + _ = Should.Throw(act); + } + + [Fact] + public static void GivenEquivalentOutterForImmutableArrayInnerThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + object other = new OutterForImmutableArray.Inner(_sampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualsWithOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForImmutableArrayTests/WhenEqualsWithOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..e847cfe --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForImmutableArrayTests/WhenEqualsWithOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..2c2738d --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,39 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenGetHashCodeIsCalled +{ + private static readonly ImmutableArray _firstValue = ["Eta", "Theta", "Iota"]; + private static readonly ImmutableArray _secondValue = ["Kappa", "Lambda", "Mu"]; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForImmutableArray.Inner first = new(_firstValue); + OutterForImmutableArray.Inner second = new(_firstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForImmutableArray.Inner first = new(_firstValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs new file mode 100644 index 0000000..7a9bffe --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenImplicitOperatorFromImmutableArrayIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForImmutableArray.Inner result = _sampleValue; + + // Act + ImmutableArray actual = result; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs new file mode 100644 index 0000000..64378ef --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenImplicitOperatorToImmutableArrayIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + ImmutableArray actual = subject; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..4ef8f4a --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs @@ -0,0 +1,48 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenInequalityOperatorWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner? subject = default; + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForImmutableArrayTests/WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..683e400 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForImmutableArrayTests/WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,53 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentValuesThenReturnFalse() + { + // Arrange + ImmutableArray leftValues = ["Alpha", "Beta", "Gamma"]; + ImmutableArray rightValues = ["Alpha", "Beta", "Gamma"]; + OutterForImmutableArray.Inner left = new(leftValues); + OutterForImmutableArray.Inner right = new(rightValues); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForImmutableArrayTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..9e02ccf --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForImmutableArrayTests/WhenToStringIsCalled.cs @@ -0,0 +1,22 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenToStringIsCalled +{ + private static readonly string Expected = $"Inner {{ {typeof(ImmutableArray)} }}"; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + OutterForImmutableArray.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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..4bc9368 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForIntTests; + +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/WhenEqualityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/WhenEqualityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..edadf9e --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/WhenEqualityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForIntTests; + +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/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..649262d --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForIntTests; + +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/WhenEqualsWithIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/WhenEqualsWithIntIsCalled.cs new file mode 100644 index 0000000..3682994 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/WhenEqualsWithIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForIntTests; + +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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..652bf4c --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForIntTests; + +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/WhenEqualsWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/WhenEqualsWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..6f7162a --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/WhenEqualsWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForIntTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..6a2d8ac --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForIntTests; + +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/WhenImplicitOperatorFromIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/WhenImplicitOperatorFromIntIsCalled.cs new file mode 100644 index 0000000..c5a64a1 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/WhenImplicitOperatorFromIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForIntTests; + +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/WhenImplicitOperatorToIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/WhenImplicitOperatorToIntIsCalled.cs new file mode 100644 index 0000000..0ce30f2 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/WhenImplicitOperatorToIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForIntTests; + +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/WhenInequalityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/WhenInequalityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..0508265 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/WhenInequalityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForIntTests; + +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/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..ad0ee27 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForIntTests; + +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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..0ef6b20 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForIntTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForIntTests; + +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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..101075f --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForStringTests; + +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/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..7ec3502 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,79 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForStringTests; + +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 GivenEquivalentValuesThenReturnTrue() + { + // Arrange + string leftValue = new(SampleValue.ToCharArray()); + string rightValue = new(SampleValue.ToCharArray()); + OutterForString.Inner left = new(leftValue); + OutterForString.Inner right = new(rightValue); + + // 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/WhenEqualityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/WhenEqualityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..6507a06 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/WhenEqualityOperatorWithStringIsCalled.cs @@ -0,0 +1,61 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForStringTests; + +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 GivenEquivalentValueThenReturnTrue() + { + // Arrange + string subjectValue = new(SampleValue.ToCharArray()); + string comparisonValue = new(SampleValue.ToCharArray()); + OutterForString.Inner subject = new(subjectValue); + + // Act + bool actual = subject == comparisonValue; + + // 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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..660610b --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForStringTests; + +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/WhenEqualsWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/WhenEqualsWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..b3a48dd --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/WhenEqualsWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForStringTests; + +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/WhenEqualsWithStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/WhenEqualsWithStringIsCalled.cs new file mode 100644 index 0000000..09c4da1 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/WhenEqualsWithStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForStringTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..c7fc878 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForStringTests; + +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/WhenImplicitOperatorFromStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/WhenImplicitOperatorFromStringIsCalled.cs new file mode 100644 index 0000000..6c0d559 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/WhenImplicitOperatorFromStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForStringTests; + +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/WhenImplicitOperatorToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/WhenImplicitOperatorToStringIsCalled.cs new file mode 100644 index 0000000..db65970 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/WhenImplicitOperatorToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForStringTests; + +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/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..1639f13 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,51 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForStringTests; + +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 GivenEquivalentValuesThenReturnFalse() + { + // Arrange + string leftValue = new(SampleValue.ToCharArray()); + string rightValue = new(SampleValue.ToCharArray()); + OutterForString.Inner left = new(leftValue); + OutterForString.Inner right = new(rightValue); + + // 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/WhenInequalityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/WhenInequalityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..090cdae --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/WhenInequalityOperatorWithStringIsCalled.cs @@ -0,0 +1,61 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForStringTests; + +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 GivenEquivalentValueThenReturnFalse() + { + // Arrange + string subjectValue = new(SampleValue.ToCharArray()); + string comparisonValue = new(SampleValue.ToCharArray()); + OutterForString.Inner subject = new(subjectValue); + + // Act + bool actual = subject != comparisonValue; + + // 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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..fb572ad --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InClass/OutterForStringTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Structs.Nested.InClass.OutterForStringTests; + +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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..9cc4f43 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForArrayTests; + +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/WhenEqualityOperatorWithIOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/WhenEqualityOperatorWithIOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..71fedb7 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/WhenEqualityOperatorWithIOutterForArrayInnerIsCalled.cs @@ -0,0 +1,79 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForArrayTests; + +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 GivenEquivalentValuesThenReturnTrue() + { + // Arrange + int[] leftValues = [1, 2, 3]; + int[] rightValues = [1, 2, 3]; + IOutterForArray.Inner left = new(leftValues); + IOutterForArray.Inner right = new(rightValues); + + // 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/WhenEqualityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/WhenEqualityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..fc99706 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/WhenEqualityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForArrayTests; + +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/WhenEqualsWithIOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/WhenEqualsWithIOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..1930e53 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/WhenEqualsWithIOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForArrayTests; + +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/WhenEqualsWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/WhenEqualsWithIntArrayIsCalled.cs new file mode 100644 index 0000000..79419bd --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/WhenEqualsWithIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForArrayTests; + +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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..d22b2c2 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForArrayTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..1d13a10 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForArrayTests; + +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/WhenImplicitOperatorFromIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/WhenImplicitOperatorFromIntArrayIsCalled.cs new file mode 100644 index 0000000..7c2d36b --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/WhenImplicitOperatorFromIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForArrayTests; + +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/WhenImplicitOperatorToIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/WhenImplicitOperatorToIntArrayIsCalled.cs new file mode 100644 index 0000000..aadebee --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/WhenImplicitOperatorToIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForArrayTests; + +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/WhenInequalityOperatorWithIOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/WhenInequalityOperatorWithIOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..3127692 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/WhenInequalityOperatorWithIOutterForArrayInnerIsCalled.cs @@ -0,0 +1,51 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForArrayTests; + +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 GivenEquivalentValuesThenReturnFalse() + { + // Arrange + int[] leftValues = [1, 2, 3]; + int[] rightValues = [1, 2, 3]; + IOutterForArray.Inner left = new(leftValues); + IOutterForArray.Inner right = new(rightValues); + + // 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/WhenInequalityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/WhenInequalityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..ebee1fc --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/WhenInequalityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForArrayTests; + +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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..1a30b78 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForArrayTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForArrayTests; + +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/IOutterForImmutableArrayTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForImmutableArrayTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..ec25ecd --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForImmutableArrayTests/WhenConstructorIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenConstructorIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + IOutterForImmutableArray.Inner instance = new(_sampleValue); + + // Act + ImmutableArray actual = instance; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForImmutableArrayTests/WhenEqualityOperatorWithIOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForImmutableArrayTests/WhenEqualityOperatorWithIOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..d58d223 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForImmutableArrayTests/WhenEqualityOperatorWithIOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,81 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualityOperatorWithIOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + IOutterForImmutableArray.Inner? left = default; + IOutterForImmutableArray.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + IOutterForImmutableArray.Inner? left = default; + IOutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForImmutableArray.Inner left = new(_sampleValue); + IOutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenEquivalentValuesThenReturnTrue() + { + // Arrange + ImmutableArray leftValues = ["Alpha", "Beta", "Gamma"]; + ImmutableArray rightValues = ["Alpha", "Beta", "Gamma"]; + IOutterForImmutableArray.Inner left = new(leftValues); + IOutterForImmutableArray.Inner right = new(rightValues); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + IOutterForImmutableArray.Inner left = new(_sampleValue); + IOutterForImmutableArray.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/IOutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..df0485b --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs @@ -0,0 +1,48 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualityOperatorWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + IOutterForImmutableArray.Inner? subject = default; + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + IOutterForImmutableArray.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/IOutterForImmutableArrayTests/WhenEqualsWithIOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForImmutableArrayTests/WhenEqualsWithIOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..b0a9926 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForImmutableArrayTests/WhenEqualsWithIOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithIOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForImmutableArray.Inner left = new(_sampleValue); + IOutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + IOutterForImmutableArray.Inner left = new(_sampleValue); + IOutterForImmutableArray.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/IOutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..b3db7ee --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + IOutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_sampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + IOutterForImmutableArray.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/IOutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..d0a0981 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,49 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithObjectIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenNullThenThrowNullReferenceException() + { + // Arrange + IOutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + Action act = () => subject.Equals((object?)default); + + // Assert + _ = Should.Throw(act); + } + + [Fact] + public static void GivenEquivalentIOutterForImmutableArrayInnerThenReturnTrue() + { + // Arrange + IOutterForImmutableArray.Inner subject = new(_sampleValue); + object other = new IOutterForImmutableArray.Inner(_sampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + IOutterForImmutableArray.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/IOutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..311eb59 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,39 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenGetHashCodeIsCalled +{ + private static readonly ImmutableArray _firstValue = ["Eta", "Theta", "Iota"]; + private static readonly ImmutableArray _secondValue = ["Kappa", "Lambda", "Mu"]; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + IOutterForImmutableArray.Inner first = new(_firstValue); + IOutterForImmutableArray.Inner second = new(_firstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + IOutterForImmutableArray.Inner first = new(_firstValue); + IOutterForImmutableArray.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/IOutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs new file mode 100644 index 0000000..d1ca3d2 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenImplicitOperatorFromImmutableArrayIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + IOutterForImmutableArray.Inner result = _sampleValue; + + // Act + ImmutableArray actual = result; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs new file mode 100644 index 0000000..eb2b035 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenImplicitOperatorToImmutableArrayIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + IOutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + ImmutableArray actual = subject; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForImmutableArrayTests/WhenInequalityOperatorWithIOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForImmutableArrayTests/WhenInequalityOperatorWithIOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..9c623c7 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForImmutableArrayTests/WhenInequalityOperatorWithIOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,53 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenInequalityOperatorWithIOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + IOutterForImmutableArray.Inner left = new(_sampleValue); + IOutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentValuesThenReturnFalse() + { + // Arrange + ImmutableArray leftValues = ["Alpha", "Beta", "Gamma"]; + ImmutableArray rightValues = ["Alpha", "Beta", "Gamma"]; + IOutterForImmutableArray.Inner left = new(leftValues); + IOutterForImmutableArray.Inner right = new(rightValues); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + IOutterForImmutableArray.Inner left = new(_sampleValue); + IOutterForImmutableArray.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/IOutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..efe480f --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs @@ -0,0 +1,48 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenInequalityOperatorWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + IOutterForImmutableArray.Inner? subject = default; + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + IOutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + IOutterForImmutableArray.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/IOutterForImmutableArrayTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForImmutableArrayTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..6b2fbc6 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForImmutableArrayTests/WhenToStringIsCalled.cs @@ -0,0 +1,22 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenToStringIsCalled +{ + private static readonly string Expected = $"Inner {{ {typeof(ImmutableArray)} }}"; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + IOutterForImmutableArray.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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..a063e56 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForIntTests; + +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/WhenEqualityOperatorWithIOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/WhenEqualityOperatorWithIOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..92e54e2 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/WhenEqualityOperatorWithIOutterForIntInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForIntTests; + +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/WhenEqualityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/WhenEqualityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..4e760d4 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/WhenEqualityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForIntTests; + +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/WhenEqualsWithIOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/WhenEqualsWithIOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..503cb2b --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/WhenEqualsWithIOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForIntTests; + +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/WhenEqualsWithIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/WhenEqualsWithIntIsCalled.cs new file mode 100644 index 0000000..a4b2a59 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/WhenEqualsWithIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForIntTests; + +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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..ac3064b --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForIntTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..2bc6196 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForIntTests; + +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/WhenImplicitOperatorFromIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/WhenImplicitOperatorFromIntIsCalled.cs new file mode 100644 index 0000000..6df9779 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/WhenImplicitOperatorFromIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForIntTests; + +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/WhenImplicitOperatorToIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/WhenImplicitOperatorToIntIsCalled.cs new file mode 100644 index 0000000..ec6fccc --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/WhenImplicitOperatorToIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForIntTests; + +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/WhenInequalityOperatorWithIOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/WhenInequalityOperatorWithIOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..b400708 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/WhenInequalityOperatorWithIOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForIntTests; + +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/WhenInequalityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/WhenInequalityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..f8ee492 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/WhenInequalityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForIntTests; + +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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..73ec601 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForIntTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForIntTests; + +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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..71e2dbd --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForStringTests; + +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/WhenEqualityOperatorWithIOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/WhenEqualityOperatorWithIOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..4c145b0 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/WhenEqualityOperatorWithIOutterForStringInnerIsCalled.cs @@ -0,0 +1,79 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForStringTests; + +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 GivenEquivalentValuesThenReturnTrue() + { + // Arrange + string leftValue = new(SampleValue.ToCharArray()); + string rightValue = new(SampleValue.ToCharArray()); + IOutterForString.Inner left = new(leftValue); + IOutterForString.Inner right = new(rightValue); + + // 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/WhenEqualityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/WhenEqualityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..001a79d --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/WhenEqualityOperatorWithStringIsCalled.cs @@ -0,0 +1,61 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForStringTests; + +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 GivenEquivalentValueThenReturnTrue() + { + // Arrange + string subjectValue = new(SampleValue.ToCharArray()); + string comparisonValue = new(SampleValue.ToCharArray()); + IOutterForString.Inner subject = new(subjectValue); + + // Act + bool actual = subject == comparisonValue; + + // 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/WhenEqualsWithIOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/WhenEqualsWithIOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..5c0893e --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/WhenEqualsWithIOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForStringTests; + +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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..4fa2c06 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForStringTests; + +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/WhenEqualsWithStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/WhenEqualsWithStringIsCalled.cs new file mode 100644 index 0000000..cd7dc93 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/WhenEqualsWithStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForStringTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..7cc86f7 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForStringTests; + +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/WhenImplicitOperatorFromStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/WhenImplicitOperatorFromStringIsCalled.cs new file mode 100644 index 0000000..e1326c2 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/WhenImplicitOperatorFromStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForStringTests; + +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/WhenImplicitOperatorToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/WhenImplicitOperatorToStringIsCalled.cs new file mode 100644 index 0000000..877b02b --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/WhenImplicitOperatorToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForStringTests; + +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/WhenInequalityOperatorWithIOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/WhenInequalityOperatorWithIOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..447aea9 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/WhenInequalityOperatorWithIOutterForStringInnerIsCalled.cs @@ -0,0 +1,51 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForStringTests; + +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 GivenEquivalentValuesThenReturnFalse() + { + // Arrange + string leftValue = new(SampleValue.ToCharArray()); + string rightValue = new(SampleValue.ToCharArray()); + IOutterForString.Inner left = new(leftValue); + IOutterForString.Inner right = new(rightValue); + + // 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/WhenInequalityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/WhenInequalityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..52c4b1b --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/WhenInequalityOperatorWithStringIsCalled.cs @@ -0,0 +1,61 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForStringTests; + +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 GivenEquivalentValueThenReturnFalse() + { + // Arrange + string subjectValue = new(SampleValue.ToCharArray()); + string comparisonValue = new(SampleValue.ToCharArray()); + IOutterForString.Inner subject = new(subjectValue); + + // Act + bool actual = subject != comparisonValue; + + // 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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..5392a1c --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InInterface/IOutterForStringTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Structs.Nested.InInterface.IOutterForStringTests; + +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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..25b770a --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForArrayTests; + +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/WhenEqualityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/WhenEqualityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..5b311d0 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/WhenEqualityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForArrayTests; + +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/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..98850b5 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,79 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForArrayTests; + +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 GivenEquivalentValuesThenReturnTrue() + { + // Arrange + int[] leftValues = [1, 2, 3]; + int[] rightValues = [1, 2, 3]; + OutterForArray.Inner left = new(leftValues); + OutterForArray.Inner right = new(rightValues); + + // 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/WhenEqualsWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/WhenEqualsWithIntArrayIsCalled.cs new file mode 100644 index 0000000..6b88ba1 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/WhenEqualsWithIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForArrayTests; + +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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..be6dbc2 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForArrayTests; + +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/WhenEqualsWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..f48163b --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForArrayTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..06c3b6d --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForArrayTests; + +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/WhenImplicitOperatorFromIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/WhenImplicitOperatorFromIntArrayIsCalled.cs new file mode 100644 index 0000000..6a41e99 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/WhenImplicitOperatorFromIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForArrayTests; + +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/WhenImplicitOperatorToIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/WhenImplicitOperatorToIntArrayIsCalled.cs new file mode 100644 index 0000000..f7c1d85 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/WhenImplicitOperatorToIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForArrayTests; + +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/WhenInequalityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/WhenInequalityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..923ff4a --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/WhenInequalityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForArrayTests; + +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/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..90c1061 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,51 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForArrayTests; + +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 GivenEquivalentValuesThenReturnFalse() + { + // Arrange + int[] leftValues = [1, 2, 3]; + int[] rightValues = [1, 2, 3]; + OutterForArray.Inner left = new(leftValues); + OutterForArray.Inner right = new(rightValues); + + // 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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..01eb80c --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForArrayTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForArrayTests; + +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/OutterForImmutableArrayTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForImmutableArrayTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..452ba4c --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForImmutableArrayTests/WhenConstructorIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenConstructorIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForImmutableArray.Inner instance = new(_sampleValue); + + // Act + ImmutableArray actual = instance; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..81808a4 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs @@ -0,0 +1,48 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualityOperatorWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner? subject = default; + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForImmutableArrayTests/WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..dadfa32 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForImmutableArrayTests/WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,81 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner? left = default; + OutterForImmutableArray.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner? left = default; + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenEquivalentValuesThenReturnTrue() + { + // Arrange + ImmutableArray leftValues = ["Alpha", "Beta", "Gamma"]; + ImmutableArray rightValues = ["Alpha", "Beta", "Gamma"]; + OutterForImmutableArray.Inner left = new(leftValues); + OutterForImmutableArray.Inner right = new(rightValues); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..cb8c436 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_sampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..b81d861 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,49 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithObjectIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenNullThenThrowNullReferenceException() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + Action act = () => subject.Equals((object?)default); + + // Assert + _ = Should.Throw(act); + } + + [Fact] + public static void GivenEquivalentOutterForImmutableArrayInnerThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + object other = new OutterForImmutableArray.Inner(_sampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualsWithOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForImmutableArrayTests/WhenEqualsWithOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..2b8d92e --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForImmutableArrayTests/WhenEqualsWithOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..f689dd0 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,39 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenGetHashCodeIsCalled +{ + private static readonly ImmutableArray _firstValue = ["Eta", "Theta", "Iota"]; + private static readonly ImmutableArray _secondValue = ["Kappa", "Lambda", "Mu"]; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForImmutableArray.Inner first = new(_firstValue); + OutterForImmutableArray.Inner second = new(_firstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForImmutableArray.Inner first = new(_firstValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs new file mode 100644 index 0000000..307c84c --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenImplicitOperatorFromImmutableArrayIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForImmutableArray.Inner result = _sampleValue; + + // Act + ImmutableArray actual = result; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs new file mode 100644 index 0000000..b7140e9 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenImplicitOperatorToImmutableArrayIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + ImmutableArray actual = subject; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..1d560e0 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs @@ -0,0 +1,48 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenInequalityOperatorWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner? subject = default; + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForImmutableArrayTests/WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..53ca4c7 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForImmutableArrayTests/WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,53 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentValuesThenReturnFalse() + { + // Arrange + ImmutableArray leftValues = ["Alpha", "Beta", "Gamma"]; + ImmutableArray rightValues = ["Alpha", "Beta", "Gamma"]; + OutterForImmutableArray.Inner left = new(leftValues); + OutterForImmutableArray.Inner right = new(rightValues); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForImmutableArrayTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..7c04009 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForImmutableArrayTests/WhenToStringIsCalled.cs @@ -0,0 +1,22 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenToStringIsCalled +{ + private static readonly string Expected = $"Inner {{ {typeof(ImmutableArray)} }}"; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + OutterForImmutableArray.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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..d1da605 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForIntTests; + +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/WhenEqualityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/WhenEqualityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..f655c01 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/WhenEqualityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForIntTests; + +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/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..becc2aa --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForIntTests; + +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/WhenEqualsWithIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/WhenEqualsWithIntIsCalled.cs new file mode 100644 index 0000000..f17fad5 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/WhenEqualsWithIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForIntTests; + +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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..d964d89 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForIntTests; + +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/WhenEqualsWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/WhenEqualsWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..a6a6c8a --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/WhenEqualsWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForIntTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..fc6d434 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForIntTests; + +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/WhenImplicitOperatorFromIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/WhenImplicitOperatorFromIntIsCalled.cs new file mode 100644 index 0000000..f24c74b --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/WhenImplicitOperatorFromIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForIntTests; + +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/WhenImplicitOperatorToIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/WhenImplicitOperatorToIntIsCalled.cs new file mode 100644 index 0000000..ca00686 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/WhenImplicitOperatorToIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForIntTests; + +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/WhenInequalityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/WhenInequalityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..56ce674 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/WhenInequalityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForIntTests; + +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/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..14e18cc --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForIntTests; + +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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..ce6a056 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForIntTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForIntTests; + +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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..c929bfa --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForStringTests; + +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/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..4aeb1bc --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,79 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForStringTests; + +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 GivenEquivalentValuesThenReturnTrue() + { + // Arrange + string leftValue = new(SampleValue.ToCharArray()); + string rightValue = new(SampleValue.ToCharArray()); + OutterForString.Inner left = new(leftValue); + OutterForString.Inner right = new(rightValue); + + // 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/WhenEqualityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/WhenEqualityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..82cc107 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/WhenEqualityOperatorWithStringIsCalled.cs @@ -0,0 +1,61 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForStringTests; + +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 GivenEquivalentValueThenReturnTrue() + { + // Arrange + string subjectValue = new(SampleValue.ToCharArray()); + string comparisonValue = new(SampleValue.ToCharArray()); + OutterForString.Inner subject = new(subjectValue); + + // Act + bool actual = subject == comparisonValue; + + // 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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..d14cbff --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForStringTests; + +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/WhenEqualsWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/WhenEqualsWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..d06b898 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/WhenEqualsWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForStringTests; + +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/WhenEqualsWithStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/WhenEqualsWithStringIsCalled.cs new file mode 100644 index 0000000..bead3ee --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/WhenEqualsWithStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForStringTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..565f75a --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForStringTests; + +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/WhenImplicitOperatorFromStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/WhenImplicitOperatorFromStringIsCalled.cs new file mode 100644 index 0000000..6f1bbd5 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/WhenImplicitOperatorFromStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForStringTests; + +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/WhenImplicitOperatorToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/WhenImplicitOperatorToStringIsCalled.cs new file mode 100644 index 0000000..c89aa23 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/WhenImplicitOperatorToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForStringTests; + +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/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..65235c7 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,51 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForStringTests; + +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 GivenEquivalentValuesThenReturnFalse() + { + // Arrange + string leftValue = new(SampleValue.ToCharArray()); + string rightValue = new(SampleValue.ToCharArray()); + OutterForString.Inner left = new(leftValue); + OutterForString.Inner right = new(rightValue); + + // 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/WhenInequalityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/WhenInequalityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..a54ce1d --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/WhenInequalityOperatorWithStringIsCalled.cs @@ -0,0 +1,61 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForStringTests; + +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 GivenEquivalentValueThenReturnFalse() + { + // Arrange + string subjectValue = new(SampleValue.ToCharArray()); + string comparisonValue = new(SampleValue.ToCharArray()); + OutterForString.Inner subject = new(subjectValue); + + // Act + bool actual = subject != comparisonValue; + + // 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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..34ca90a --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecord/OutterForStringTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Structs.Nested.InRecord.OutterForStringTests; + +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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..e42827d --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForArrayTests; + +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/WhenEqualityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/WhenEqualityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..730589c --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/WhenEqualityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForArrayTests; + +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/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..6699bd9 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,79 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForArrayTests; + +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 GivenEquivalentValuesThenReturnTrue() + { + // Arrange + int[] leftValues = [1, 2, 3]; + int[] rightValues = [1, 2, 3]; + OutterForArray.Inner left = new(leftValues); + OutterForArray.Inner right = new(rightValues); + + // 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/WhenEqualsWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/WhenEqualsWithIntArrayIsCalled.cs new file mode 100644 index 0000000..278b551 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/WhenEqualsWithIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForArrayTests; + +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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..2e89927 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForArrayTests; + +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/WhenEqualsWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..426a622 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForArrayTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..09ebc0f --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForArrayTests; + +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/WhenImplicitOperatorFromIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/WhenImplicitOperatorFromIntArrayIsCalled.cs new file mode 100644 index 0000000..ba69e98 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/WhenImplicitOperatorFromIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForArrayTests; + +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/WhenImplicitOperatorToIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/WhenImplicitOperatorToIntArrayIsCalled.cs new file mode 100644 index 0000000..db0362d --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/WhenImplicitOperatorToIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForArrayTests; + +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/WhenInequalityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/WhenInequalityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..98b8733 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/WhenInequalityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForArrayTests; + +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/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..2424036 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,51 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForArrayTests; + +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 GivenEquivalentValuesThenReturnFalse() + { + // Arrange + int[] leftValues = [1, 2, 3]; + int[] rightValues = [1, 2, 3]; + OutterForArray.Inner left = new(leftValues); + OutterForArray.Inner right = new(rightValues); + + // 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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..695ea11 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForArrayTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForArrayTests; + +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/OutterForImmutableArrayTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..75391b5 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenConstructorIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenConstructorIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForImmutableArray.Inner instance = new(_sampleValue); + + // Act + ImmutableArray actual = instance; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..ec42013 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs @@ -0,0 +1,48 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualityOperatorWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner? subject = default; + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..758e8a3 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,81 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner? left = default; + OutterForImmutableArray.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner? left = default; + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenEquivalentValuesThenReturnTrue() + { + // Arrange + ImmutableArray leftValues = ["Alpha", "Beta", "Gamma"]; + ImmutableArray rightValues = ["Alpha", "Beta", "Gamma"]; + OutterForImmutableArray.Inner left = new(leftValues); + OutterForImmutableArray.Inner right = new(rightValues); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..20a3e3e --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_sampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..66fb046 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,49 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithObjectIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenNullThenThrowNullReferenceException() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + Action act = () => subject.Equals((object?)default); + + // Assert + _ = Should.Throw(act); + } + + [Fact] + public static void GivenEquivalentOutterForImmutableArrayInnerThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + object other = new OutterForImmutableArray.Inner(_sampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualsWithOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenEqualsWithOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..8fbb353 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenEqualsWithOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..e36d33e --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,39 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenGetHashCodeIsCalled +{ + private static readonly ImmutableArray _firstValue = ["Eta", "Theta", "Iota"]; + private static readonly ImmutableArray _secondValue = ["Kappa", "Lambda", "Mu"]; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForImmutableArray.Inner first = new(_firstValue); + OutterForImmutableArray.Inner second = new(_firstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForImmutableArray.Inner first = new(_firstValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs new file mode 100644 index 0000000..f74b84e --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenImplicitOperatorFromImmutableArrayIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForImmutableArray.Inner result = _sampleValue; + + // Act + ImmutableArray actual = result; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs new file mode 100644 index 0000000..229bb36 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenImplicitOperatorToImmutableArrayIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + ImmutableArray actual = subject; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..b30cfa0 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs @@ -0,0 +1,48 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenInequalityOperatorWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner? subject = default; + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..6dbb068 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,53 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentValuesThenReturnFalse() + { + // Arrange + ImmutableArray leftValues = ["Alpha", "Beta", "Gamma"]; + ImmutableArray rightValues = ["Alpha", "Beta", "Gamma"]; + OutterForImmutableArray.Inner left = new(leftValues); + OutterForImmutableArray.Inner right = new(rightValues); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..fd51393 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForImmutableArrayTests/WhenToStringIsCalled.cs @@ -0,0 +1,22 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenToStringIsCalled +{ + private static readonly string Expected = $"Inner {{ {typeof(ImmutableArray)} }}"; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + OutterForImmutableArray.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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..da7eb32 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForIntTests; + +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/WhenEqualityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/WhenEqualityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..a2c5015 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/WhenEqualityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForIntTests; + +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/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..b3115b0 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForIntTests; + +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/WhenEqualsWithIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/WhenEqualsWithIntIsCalled.cs new file mode 100644 index 0000000..0dfbe13 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/WhenEqualsWithIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForIntTests; + +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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..e61a913 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForIntTests; + +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/WhenEqualsWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/WhenEqualsWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..d55c5e7 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/WhenEqualsWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForIntTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..685a967 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForIntTests; + +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/WhenImplicitOperatorFromIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/WhenImplicitOperatorFromIntIsCalled.cs new file mode 100644 index 0000000..0d05af0 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/WhenImplicitOperatorFromIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForIntTests; + +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/WhenImplicitOperatorToIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/WhenImplicitOperatorToIntIsCalled.cs new file mode 100644 index 0000000..7c6d8a1 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/WhenImplicitOperatorToIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForIntTests; + +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/WhenInequalityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/WhenInequalityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..ad93d51 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/WhenInequalityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForIntTests; + +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/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..dfafdfc --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForIntTests; + +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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..5335a21 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForIntTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForIntTests; + +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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..d0bbc39 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForStringTests; + +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/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..af59c5b --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,79 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForStringTests; + +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 GivenEquivalentValuesThenReturnTrue() + { + // Arrange + string leftValue = new(SampleValue.ToCharArray()); + string rightValue = new(SampleValue.ToCharArray()); + OutterForString.Inner left = new(leftValue); + OutterForString.Inner right = new(rightValue); + + // 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/WhenEqualityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/WhenEqualityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..c7e5f54 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/WhenEqualityOperatorWithStringIsCalled.cs @@ -0,0 +1,61 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForStringTests; + +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 GivenEquivalentValueThenReturnTrue() + { + // Arrange + string subjectValue = new(SampleValue.ToCharArray()); + string comparisonValue = new(SampleValue.ToCharArray()); + OutterForString.Inner subject = new(subjectValue); + + // Act + bool actual = subject == comparisonValue; + + // 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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..65de7fc --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForStringTests; + +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/WhenEqualsWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/WhenEqualsWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..b5fa84f --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/WhenEqualsWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForStringTests; + +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/WhenEqualsWithStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/WhenEqualsWithStringIsCalled.cs new file mode 100644 index 0000000..b10656c --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/WhenEqualsWithStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForStringTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..edff7b7 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForStringTests; + +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/WhenImplicitOperatorFromStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/WhenImplicitOperatorFromStringIsCalled.cs new file mode 100644 index 0000000..0392a56 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/WhenImplicitOperatorFromStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForStringTests; + +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/WhenImplicitOperatorToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/WhenImplicitOperatorToStringIsCalled.cs new file mode 100644 index 0000000..a234e80 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/WhenImplicitOperatorToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForStringTests; + +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/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..eb43ae1 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,51 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForStringTests; + +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 GivenEquivalentValuesThenReturnFalse() + { + // Arrange + string leftValue = new(SampleValue.ToCharArray()); + string rightValue = new(SampleValue.ToCharArray()); + OutterForString.Inner left = new(leftValue); + OutterForString.Inner right = new(rightValue); + + // 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/WhenInequalityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/WhenInequalityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..ff883e9 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/WhenInequalityOperatorWithStringIsCalled.cs @@ -0,0 +1,61 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForStringTests; + +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 GivenEquivalentValueThenReturnFalse() + { + // Arrange + string subjectValue = new(SampleValue.ToCharArray()); + string comparisonValue = new(SampleValue.ToCharArray()); + OutterForString.Inner subject = new(subjectValue); + + // Act + bool actual = subject != comparisonValue; + + // 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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..9aa23b3 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InRecordStruct/OutterForStringTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct.OutterForStringTests; + +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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..871477c --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForArrayTests; + +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/WhenEqualityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/WhenEqualityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..86b3186 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/WhenEqualityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForArrayTests; + +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/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..b9caf24 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/WhenEqualityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,79 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForArrayTests; + +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 GivenEquivalentValuesThenReturnTrue() + { + // Arrange + int[] leftValues = [1, 2, 3]; + int[] rightValues = [1, 2, 3]; + OutterForArray.Inner left = new(leftValues); + OutterForArray.Inner right = new(rightValues); + + // 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/WhenEqualsWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/WhenEqualsWithIntArrayIsCalled.cs new file mode 100644 index 0000000..8eca845 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/WhenEqualsWithIntArrayIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForArrayTests; + +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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..4408fd8 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForArrayTests; + +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/WhenEqualsWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..c1d2824 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/WhenEqualsWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForArrayTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..5f30fc1 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForArrayTests; + +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/WhenImplicitOperatorFromIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/WhenImplicitOperatorFromIntArrayIsCalled.cs new file mode 100644 index 0000000..be19f3a --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/WhenImplicitOperatorFromIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForArrayTests; + +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/WhenImplicitOperatorToIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/WhenImplicitOperatorToIntArrayIsCalled.cs new file mode 100644 index 0000000..f398173 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/WhenImplicitOperatorToIntArrayIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForArrayTests; + +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/WhenInequalityOperatorWithIntArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/WhenInequalityOperatorWithIntArrayIsCalled.cs new file mode 100644 index 0000000..0ea40fe --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/WhenInequalityOperatorWithIntArrayIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForArrayTests; + +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/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs new file mode 100644 index 0000000..0374089 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/WhenInequalityOperatorWithOutterForArrayInnerIsCalled.cs @@ -0,0 +1,51 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForArrayTests; + +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 GivenEquivalentValuesThenReturnFalse() + { + // Arrange + int[] leftValues = [1, 2, 3]; + int[] rightValues = [1, 2, 3]; + OutterForArray.Inner left = new(leftValues); + OutterForArray.Inner right = new(rightValues); + + // 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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..d365672 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForArrayTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForArrayTests; + +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/OutterForImmutableArrayTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForImmutableArrayTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..6f11b4d --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForImmutableArrayTests/WhenConstructorIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenConstructorIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + OutterForImmutableArray.Inner instance = new(_sampleValue); + + // Act + ImmutableArray actual = instance; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..9f33566 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs @@ -0,0 +1,48 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualityOperatorWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner? subject = default; + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForImmutableArrayTests/WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..6a8b56a --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForImmutableArrayTests/WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,81 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualityOperatorWithOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner? left = default; + OutterForImmutableArray.Inner? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner? left = default; + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenEquivalentValuesThenReturnTrue() + { + // Arrange + ImmutableArray leftValues = ["Alpha", "Beta", "Gamma"]; + ImmutableArray rightValues = ["Alpha", "Beta", "Gamma"]; + OutterForImmutableArray.Inner left = new(leftValues); + OutterForImmutableArray.Inner right = new(rightValues); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..0b5cb46 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_sampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..5a826df --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,49 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithObjectIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenNullThenThrowNullReferenceException() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + Action act = () => subject.Equals((object?)default); + + // Assert + _ = Should.Throw(act); + } + + [Fact] + public static void GivenEquivalentOutterForImmutableArrayInnerThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + object other = new OutterForImmutableArray.Inner(_sampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenEqualsWithOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForImmutableArrayTests/WhenEqualsWithOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..51da5f5 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForImmutableArrayTests/WhenEqualsWithOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..dd3b21e --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForImmutableArrayTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,39 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenGetHashCodeIsCalled +{ + private static readonly ImmutableArray _firstValue = ["Eta", "Theta", "Iota"]; + private static readonly ImmutableArray _secondValue = ["Kappa", "Lambda", "Mu"]; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + OutterForImmutableArray.Inner first = new(_firstValue); + OutterForImmutableArray.Inner second = new(_firstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + OutterForImmutableArray.Inner first = new(_firstValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs new file mode 100644 index 0000000..edc1f7e --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenImplicitOperatorFromImmutableArrayIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + OutterForImmutableArray.Inner result = _sampleValue; + + // Act + ImmutableArray actual = result; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs new file mode 100644 index 0000000..2da0e75 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenImplicitOperatorToImmutableArrayIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + ImmutableArray actual = subject; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..0e4fd8a --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs @@ -0,0 +1,48 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenInequalityOperatorWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner? subject = default; + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner subject = new(_sampleValue); + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForImmutableArrayTests/WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled.cs new file mode 100644 index 0000000..5c47b80 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForImmutableArrayTests/WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled.cs @@ -0,0 +1,53 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenInequalityOperatorWithOutterForImmutableArrayInnerIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.Inner right = new(_sampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentValuesThenReturnFalse() + { + // Arrange + ImmutableArray leftValues = ["Alpha", "Beta", "Gamma"]; + ImmutableArray rightValues = ["Alpha", "Beta", "Gamma"]; + OutterForImmutableArray.Inner left = new(leftValues); + OutterForImmutableArray.Inner right = new(rightValues); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + OutterForImmutableArray.Inner left = new(_sampleValue); + OutterForImmutableArray.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/OutterForImmutableArrayTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForImmutableArrayTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..25d4c1e --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForImmutableArrayTests/WhenToStringIsCalled.cs @@ -0,0 +1,22 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenToStringIsCalled +{ + private static readonly string Expected = $"Inner {{ {typeof(ImmutableArray)} }}"; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + OutterForImmutableArray.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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..2dedd44 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForIntTests; + +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/WhenEqualityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/WhenEqualityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..5b0a6fb --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/WhenEqualityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForIntTests; + +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/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..d212560 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/WhenEqualityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,63 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForIntTests; + +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/WhenEqualsWithIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/WhenEqualsWithIntIsCalled.cs new file mode 100644 index 0000000..7200d90 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/WhenEqualsWithIntIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForIntTests; + +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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..7a42732 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForIntTests; + +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/WhenEqualsWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/WhenEqualsWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..09d2426 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/WhenEqualsWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForIntTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..97078cc --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForIntTests; + +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/WhenImplicitOperatorFromIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/WhenImplicitOperatorFromIntIsCalled.cs new file mode 100644 index 0000000..5f38214 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/WhenImplicitOperatorFromIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForIntTests; + +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/WhenImplicitOperatorToIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/WhenImplicitOperatorToIntIsCalled.cs new file mode 100644 index 0000000..8768e8f --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/WhenImplicitOperatorToIntIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForIntTests; + +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/WhenInequalityOperatorWithIntIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/WhenInequalityOperatorWithIntIsCalled.cs new file mode 100644 index 0000000..c420828 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/WhenInequalityOperatorWithIntIsCalled.cs @@ -0,0 +1,46 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForIntTests; + +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/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs new file mode 100644 index 0000000..b1f9d25 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/WhenInequalityOperatorWithOutterForIntInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForIntTests; + +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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..695880c --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForIntTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForIntTests; + +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/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..546ba59 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/WhenConstructorIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForStringTests; + +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/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..dd41828 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/WhenEqualityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,79 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForStringTests; + +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 GivenEquivalentValuesThenReturnTrue() + { + // Arrange + string leftValue = new(SampleValue.ToCharArray()); + string rightValue = new(SampleValue.ToCharArray()); + OutterForString.Inner left = new(leftValue); + OutterForString.Inner right = new(rightValue); + + // 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/WhenEqualityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/WhenEqualityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..ce1994f --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/WhenEqualityOperatorWithStringIsCalled.cs @@ -0,0 +1,61 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForStringTests; + +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 GivenEquivalentValueThenReturnTrue() + { + // Arrange + string subjectValue = new(SampleValue.ToCharArray()); + string comparisonValue = new(SampleValue.ToCharArray()); + OutterForString.Inner subject = new(subjectValue); + + // Act + bool actual = subject == comparisonValue; + + // 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/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..99693b9 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,47 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForStringTests; + +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/WhenEqualsWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/WhenEqualsWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..ad4fec2 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/WhenEqualsWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForStringTests; + +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/WhenEqualsWithStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/WhenEqualsWithStringIsCalled.cs new file mode 100644 index 0000000..21fad2f --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/WhenEqualsWithStringIsCalled.cs @@ -0,0 +1,33 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForStringTests; + +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/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..7cc54a5 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForStringTests; + +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/WhenImplicitOperatorFromStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/WhenImplicitOperatorFromStringIsCalled.cs new file mode 100644 index 0000000..74ca011 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/WhenImplicitOperatorFromStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForStringTests; + +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/WhenImplicitOperatorToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/WhenImplicitOperatorToStringIsCalled.cs new file mode 100644 index 0000000..242d1b2 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/WhenImplicitOperatorToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForStringTests; + +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/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs new file mode 100644 index 0000000..60248d7 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/WhenInequalityOperatorWithOutterForStringInnerIsCalled.cs @@ -0,0 +1,51 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForStringTests; + +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 GivenEquivalentValuesThenReturnFalse() + { + // Arrange + string leftValue = new(SampleValue.ToCharArray()); + string rightValue = new(SampleValue.ToCharArray()); + OutterForString.Inner left = new(leftValue); + OutterForString.Inner right = new(rightValue); + + // 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/WhenInequalityOperatorWithStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/WhenInequalityOperatorWithStringIsCalled.cs new file mode 100644 index 0000000..7602b93 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/WhenInequalityOperatorWithStringIsCalled.cs @@ -0,0 +1,61 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForStringTests; + +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 GivenEquivalentValueThenReturnFalse() + { + // Arrange + string subjectValue = new(SampleValue.ToCharArray()); + string comparisonValue = new(SampleValue.ToCharArray()); + OutterForString.Inner subject = new(subjectValue); + + // Act + bool actual = subject != comparisonValue; + + // 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/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..2f37489 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Nested/InStruct/OutterForStringTests/WhenToStringIsCalled.cs @@ -0,0 +1,20 @@ +namespace Monify.Console.Structs.Nested.InStruct.OutterForStringTests; + +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..dd41b11 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForArrayTests/WhenEqualityOperatorWithSimpleForArrayIsCalled.cs @@ -0,0 +1,79 @@ +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 GivenEquivalentValuesThenReturnTrue() + { + // Arrange + int[] leftValues = [1, 2, 3]; + int[] rightValues = [1, 2, 3]; + SimpleForArray left = new(leftValues); + SimpleForArray right = new(rightValues); + + // 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..c32c75c --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForArrayTests/WhenInequalityOperatorWithSimpleForArrayIsCalled.cs @@ -0,0 +1,51 @@ +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 GivenEquivalentValuesThenReturnFalse() + { + // Arrange + int[] leftValues = [1, 2, 3]; + int[] rightValues = [1, 2, 3]; + SimpleForArray left = new(leftValues); + SimpleForArray right = new(rightValues); + + // 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/SimpleForImmutableArrayTests/WhenConstructorIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForImmutableArrayTests/WhenConstructorIsCalled.cs new file mode 100644 index 0000000..86b2d20 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForImmutableArrayTests/WhenConstructorIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Structs.Simple.SimpleForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenConstructorIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenValueIsStored() + { + // Arrange + SimpleForImmutableArray instance = new(_sampleValue); + + // Act + ImmutableArray actual = instance; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Simple/SimpleForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..54b25ed --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForImmutableArrayTests/WhenEqualityOperatorWithImmutableArrayIsCalled.cs @@ -0,0 +1,48 @@ +namespace Monify.Console.Structs.Simple.SimpleForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualityOperatorWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSubjectIsNullThenReturnFalse() + { + // Arrange + SimpleForImmutableArray? subject = default; + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForImmutableArray subject = new(_sampleValue); + + // Act + bool actual = subject == _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + SimpleForImmutableArray 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/SimpleForImmutableArrayTests/WhenEqualityOperatorWithSimpleForImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForImmutableArrayTests/WhenEqualityOperatorWithSimpleForImmutableArrayIsCalled.cs new file mode 100644 index 0000000..c759638 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForImmutableArrayTests/WhenEqualityOperatorWithSimpleForImmutableArrayIsCalled.cs @@ -0,0 +1,81 @@ +namespace Monify.Console.Structs.Simple.SimpleForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualityOperatorWithSimpleForImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenBothNullThenReturnTrue() + { + // Arrange + SimpleForImmutableArray? left = default; + SimpleForImmutableArray? right = default; + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenLeftIsNullThenReturnFalse() + { + // Arrange + SimpleForImmutableArray? left = default; + SimpleForImmutableArray right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForImmutableArray left = new(_sampleValue); + SimpleForImmutableArray right = new(_sampleValue); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenEquivalentValuesThenReturnTrue() + { + // Arrange + ImmutableArray leftValues = ["Alpha", "Beta", "Gamma"]; + ImmutableArray rightValues = ["Alpha", "Beta", "Gamma"]; + SimpleForImmutableArray left = new(leftValues); + SimpleForImmutableArray right = new(rightValues); + + // Act + bool actual = left == right; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnFalse() + { + // Arrange + SimpleForImmutableArray left = new(_sampleValue); + SimpleForImmutableArray 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/SimpleForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..c5834b4 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForImmutableArrayTests/WhenEqualsWithImmutableArrayIsCalled.cs @@ -0,0 +1,35 @@ +namespace Monify.Console.Structs.Simple.SimpleForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForImmutableArray subject = new(_sampleValue); + + // Act + bool actual = subject.Equals(_sampleValue); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + SimpleForImmutableArray 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/SimpleForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs new file mode 100644 index 0000000..bcc8ac6 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForImmutableArrayTests/WhenEqualsWithObjectIsCalled.cs @@ -0,0 +1,49 @@ +namespace Monify.Console.Structs.Simple.SimpleForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithObjectIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenNullThenThrowNullReferenceException() + { + // Arrange + SimpleForImmutableArray subject = new(_sampleValue); + + // Act + Action act = () => subject.Equals((object?)default); + + // Assert + _ = Should.Throw(act); + } + + [Fact] + public static void GivenEquivalentSimpleForImmutableArrayThenReturnTrue() + { + // Arrange + SimpleForImmutableArray subject = new(_sampleValue); + object other = new SimpleForImmutableArray(_sampleValue); + + // Act + bool actual = subject.Equals(other); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentTypeThenThrowInvalidCastException() + { + // Arrange + SimpleForImmutableArray 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/SimpleForImmutableArrayTests/WhenEqualsWithSimpleForImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForImmutableArrayTests/WhenEqualsWithSimpleForImmutableArrayIsCalled.cs new file mode 100644 index 0000000..2478fa6 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForImmutableArrayTests/WhenEqualsWithSimpleForImmutableArrayIsCalled.cs @@ -0,0 +1,37 @@ +namespace Monify.Console.Structs.Simple.SimpleForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenEqualsWithSimpleForImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnTrue() + { + // Arrange + SimpleForImmutableArray left = new(_sampleValue); + SimpleForImmutableArray right = new(_sampleValue); + + // Act + bool actual = left.Equals(right); + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenDifferentValueThenReturnFalse() + { + // Arrange + SimpleForImmutableArray left = new(_sampleValue); + SimpleForImmutableArray 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/SimpleForImmutableArrayTests/WhenGetHashCodeIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForImmutableArrayTests/WhenGetHashCodeIsCalled.cs new file mode 100644 index 0000000..20e0e7d --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForImmutableArrayTests/WhenGetHashCodeIsCalled.cs @@ -0,0 +1,39 @@ +namespace Monify.Console.Structs.Simple.SimpleForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenGetHashCodeIsCalled +{ + private static readonly ImmutableArray _firstValue = ["Eta", "Theta", "Iota"]; + private static readonly ImmutableArray _secondValue = ["Kappa", "Lambda", "Mu"]; + + [Fact] + public static void GivenSameValuesThenReturnSameHashCode() + { + // Arrange + SimpleForImmutableArray first = new(_firstValue); + SimpleForImmutableArray second = new(_firstValue); + + // Act + int firstHash = first.GetHashCode(); + int secondHash = second.GetHashCode(); + + // Assert + firstHash.ShouldBe(secondHash); + } + + [Fact] + public static void GivenDifferentValuesThenReturnDifferentHashCodes() + { + // Arrange + SimpleForImmutableArray first = new(_firstValue); + SimpleForImmutableArray 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/SimpleForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs new file mode 100644 index 0000000..d3fa855 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForImmutableArrayTests/WhenImplicitOperatorFromImmutableArrayIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Structs.Simple.SimpleForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenImplicitOperatorFromImmutableArrayIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueThenReturnsEquivalentInstance() + { + // Arrange + SimpleForImmutableArray result = _sampleValue; + + // Act + ImmutableArray actual = result; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Simple/SimpleForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs new file mode 100644 index 0000000..8adec7d --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForImmutableArrayTests/WhenImplicitOperatorToImmutableArrayIsCalled.cs @@ -0,0 +1,21 @@ +namespace Monify.Console.Structs.Simple.SimpleForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenImplicitOperatorToImmutableArrayIsCalled +{ + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValidSubjectThenReturnsValue() + { + // Arrange + SimpleForImmutableArray subject = new(_sampleValue); + + // Act + ImmutableArray actual = subject; + + // Assert + actual.ShouldBe(_sampleValue); + } +} \ No newline at end of file diff --git a/src/Monify.Console.Tests/Structs/Simple/SimpleForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs new file mode 100644 index 0000000..7474c80 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForImmutableArrayTests/WhenInequalityOperatorWithImmutableArrayIsCalled.cs @@ -0,0 +1,48 @@ +namespace Monify.Console.Structs.Simple.SimpleForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenInequalityOperatorWithImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSubjectIsNullThenReturnTrue() + { + // Arrange + SimpleForImmutableArray? subject = default; + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeTrue(); + } + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + SimpleForImmutableArray subject = new(_sampleValue); + + // Act + bool actual = subject != _sampleValue; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValueThenReturnTrue() + { + // Arrange + SimpleForImmutableArray 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/SimpleForImmutableArrayTests/WhenInequalityOperatorWithSimpleForImmutableArrayIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForImmutableArrayTests/WhenInequalityOperatorWithSimpleForImmutableArrayIsCalled.cs new file mode 100644 index 0000000..731065f --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForImmutableArrayTests/WhenInequalityOperatorWithSimpleForImmutableArrayIsCalled.cs @@ -0,0 +1,53 @@ +namespace Monify.Console.Structs.Simple.SimpleForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenInequalityOperatorWithSimpleForImmutableArrayIsCalled +{ + private static readonly ImmutableArray _differentValue = ["Delta", "Epsilon", "Zeta"]; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenSameValueThenReturnFalse() + { + // Arrange + SimpleForImmutableArray left = new(_sampleValue); + SimpleForImmutableArray right = new(_sampleValue); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenEquivalentValuesThenReturnFalse() + { + // Arrange + ImmutableArray leftValues = ["Alpha", "Beta", "Gamma"]; + ImmutableArray rightValues = ["Alpha", "Beta", "Gamma"]; + SimpleForImmutableArray left = new(leftValues); + SimpleForImmutableArray right = new(rightValues); + + // Act + bool actual = left != right; + + // Assert + actual.ShouldBeFalse(); + } + + [Fact] + public static void GivenDifferentValuesThenReturnTrue() + { + // Arrange + SimpleForImmutableArray left = new(_sampleValue); + SimpleForImmutableArray 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/SimpleForImmutableArrayTests/WhenToStringIsCalled.cs b/src/Monify.Console.Tests/Structs/Simple/SimpleForImmutableArrayTests/WhenToStringIsCalled.cs new file mode 100644 index 0000000..ee04e9f --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForImmutableArrayTests/WhenToStringIsCalled.cs @@ -0,0 +1,22 @@ +namespace Monify.Console.Structs.Simple.SimpleForImmutableArrayTests; + +using System.Collections.Immutable; + +public static class WhenToStringIsCalled +{ + private static readonly string Expected = $"SimpleForImmutableArray {{ {typeof(ImmutableArray)} }}"; + private static readonly ImmutableArray _sampleValue = ["Alpha", "Beta", "Gamma"]; + + [Fact] + public static void GivenValueTheExpectedStringIsReturned() + { + // Arrange + SimpleForImmutableArray 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..d1e4079 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForStringTests/WhenEqualityOperatorWithSimpleForStringIsCalled.cs @@ -0,0 +1,79 @@ +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 GivenEquivalentValuesThenReturnTrue() + { + // Arrange + string leftValue = new(SampleValue.ToCharArray()); + string rightValue = new(SampleValue.ToCharArray()); + SimpleForString left = new(leftValue); + SimpleForString right = new(rightValue); + + // 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..df85279 --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForStringTests/WhenEqualityOperatorWithStringIsCalled.cs @@ -0,0 +1,61 @@ +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 GivenEquivalentValueThenReturnTrue() + { + // Arrange + string subjectValue = new(SampleValue.ToCharArray()); + string comparisonValue = new(SampleValue.ToCharArray()); + SimpleForString subject = new(subjectValue); + + // Act + bool actual = subject == comparisonValue; + + // 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..b155cec --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForStringTests/WhenInequalityOperatorWithSimpleForStringIsCalled.cs @@ -0,0 +1,51 @@ +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 GivenEquivalentValuesThenReturnFalse() + { + // Arrange + string leftValue = new(SampleValue.ToCharArray()); + string rightValue = new(SampleValue.ToCharArray()); + SimpleForString left = new(leftValue); + SimpleForString right = new(rightValue); + + // 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..604d7ed --- /dev/null +++ b/src/Monify.Console.Tests/Structs/Simple/SimpleForStringTests/WhenInequalityOperatorWithStringIsCalled.cs @@ -0,0 +1,61 @@ +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 GivenEquivalentValueThenReturnFalse() + { + // Arrange + string subjectValue = new(SampleValue.ToCharArray()); + string comparisonValue = new(SampleValue.ToCharArray()); + SimpleForString subject = new(subjectValue); + + // Act + bool actual = subject != comparisonValue; + + // 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.Console/Classes/Nested/InClass/OutterForArray.{T}.cs b/src/Monify.Console/Classes/Nested/InClass/OutterForArray.{T}.cs new file mode 100644 index 0000000..5a7b00c --- /dev/null +++ b/src/Monify.Console/Classes/Nested/InClass/OutterForArray.{T}.cs @@ -0,0 +1,15 @@ +namespace Monify.Console.Classes.Nested.InClass; + +/// +/// Provides a nested class example that uses Monify with integer array types. +/// +/// The struct type that the outer class is parameterized with. +public sealed partial class OutterForArray + where T : struct +{ + /// + /// Represents the inner class decorated by Monify for integer array types. + /// + [Monify] + public sealed partial class Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Classes/Nested/InClass/OutterForImmutableArray.{T}.cs b/src/Monify.Console/Classes/Nested/InClass/OutterForImmutableArray.{T}.cs new file mode 100644 index 0000000..5782ed9 --- /dev/null +++ b/src/Monify.Console/Classes/Nested/InClass/OutterForImmutableArray.{T}.cs @@ -0,0 +1,16 @@ +namespace Monify.Console.Classes.Nested.InClass; + +using System.Collections.Immutable; + +/// +/// Provides a nested class example that uses Monify with immutable array of string types. +/// +/// The class type that the outer class is parameterized with. +public sealed partial class OutterForImmutableArray +{ + /// + /// Represents the inner class decorated by Monify for immutable array of string types. + /// + [Monify>] + public sealed partial class Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Classes/Nested/InClass/OutterForInt.{T}.cs b/src/Monify.Console/Classes/Nested/InClass/OutterForInt.{T}.cs new file mode 100644 index 0000000..24a9814 --- /dev/null +++ b/src/Monify.Console/Classes/Nested/InClass/OutterForInt.{T}.cs @@ -0,0 +1,15 @@ +namespace Monify.Console.Classes.Nested.InClass; + +/// +/// Provides a nested class example that uses Monify with integer types. +/// +/// The struct type that the outer class is parameterized with. +public sealed partial class OutterForInt + where T : struct +{ + /// + /// Represents the inner class decorated by Monify for integer types. + /// + [Monify] + public sealed partial class Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Classes/Nested/InClass/OutterForString.{T}.cs b/src/Monify.Console/Classes/Nested/InClass/OutterForString.{T}.cs new file mode 100644 index 0000000..4e88f77 --- /dev/null +++ b/src/Monify.Console/Classes/Nested/InClass/OutterForString.{T}.cs @@ -0,0 +1,15 @@ +namespace Monify.Console.Classes.Nested.InClass; + +/// +/// Provides a nested class example that uses Monify with string types. +/// +/// The struct type that the outer class is parameterized with. +public sealed partial class OutterForString + where T : struct +{ + /// + /// Represents the inner class decorated by Monify for string types. + /// + [Monify] + public sealed partial class Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Classes/Nested/InInterface/IOutterForArray.{T}.cs b/src/Monify.Console/Classes/Nested/InInterface/IOutterForArray.{T}.cs new file mode 100644 index 0000000..c9b6397 --- /dev/null +++ b/src/Monify.Console/Classes/Nested/InInterface/IOutterForArray.{T}.cs @@ -0,0 +1,15 @@ +namespace Monify.Console.Classes.Nested.InInterface; + +/// +/// Defines a nested interface example that uses Monify with integer array types. +/// +/// The struct type that the interface is parameterized with. +public partial interface IOutterForArray + where T : struct +{ + /// + /// Represents the inner class decorated by Monify for integer array types. + /// + [Monify] + public sealed partial class Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Classes/Nested/InInterface/IOutterForImmutableArray.{T}.cs b/src/Monify.Console/Classes/Nested/InInterface/IOutterForImmutableArray.{T}.cs new file mode 100644 index 0000000..4af2295 --- /dev/null +++ b/src/Monify.Console/Classes/Nested/InInterface/IOutterForImmutableArray.{T}.cs @@ -0,0 +1,17 @@ +namespace Monify.Console.Classes.Nested.InInterface; + +using System.Collections.Immutable; + +/// +/// Provides a nested interface example that uses Monify with immutable array of string types. +/// +/// The struct type that the interface is parameterized with. +public partial interface IOutterForImmutableArray + where T : struct +{ + /// + /// Represents the inner class decorated by Monify for immutable array of string types. + /// + [Monify>] + public sealed partial class Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Classes/Nested/InInterface/IOutterForInt.{T}.cs b/src/Monify.Console/Classes/Nested/InInterface/IOutterForInt.{T}.cs new file mode 100644 index 0000000..f962cf1 --- /dev/null +++ b/src/Monify.Console/Classes/Nested/InInterface/IOutterForInt.{T}.cs @@ -0,0 +1,15 @@ +namespace Monify.Console.Classes.Nested.InInterface; + +/// +/// Defines a nested interface example that uses Monify with integer types. +/// +/// The struct type that the interface is parameterized with. +public partial interface IOutterForInt + where T : struct +{ + /// + /// Represents the inner class decorated by Monify for integer types. + /// + [Monify] + public sealed partial class Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Classes/Nested/InInterface/IOutterForString.{T}.cs b/src/Monify.Console/Classes/Nested/InInterface/IOutterForString.{T}.cs new file mode 100644 index 0000000..31d21d0 --- /dev/null +++ b/src/Monify.Console/Classes/Nested/InInterface/IOutterForString.{T}.cs @@ -0,0 +1,15 @@ +namespace Monify.Console.Classes.Nested.InInterface; + +/// +/// Defines a nested interface example that uses Monify with string types. +/// +/// The struct type that the interface is parameterized with. +public partial interface IOutterForString + where T : struct +{ + /// + /// Represents the inner class decorated by Monify for string types. + /// + [Monify] + public sealed partial class Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Classes/Nested/InRecord/OutterForArray.{T}.cs b/src/Monify.Console/Classes/Nested/InRecord/OutterForArray.{T}.cs new file mode 100644 index 0000000..c9f7c15 --- /dev/null +++ b/src/Monify.Console/Classes/Nested/InRecord/OutterForArray.{T}.cs @@ -0,0 +1,15 @@ +namespace Monify.Console.Classes.Nested.InRecord; + +/// +/// Provides a nested record example that uses Monify with integer array types. +/// +/// The struct type that the outer record is parameterized with. +public sealed partial record OutterForArray + where T : struct +{ + /// + /// Represents the inner class decorated by Monify for integer array types. + /// + [Monify] + public sealed partial class Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Classes/Nested/InRecord/OutterForImmutableArray.{T}.cs b/src/Monify.Console/Classes/Nested/InRecord/OutterForImmutableArray.{T}.cs new file mode 100644 index 0000000..7ba534b --- /dev/null +++ b/src/Monify.Console/Classes/Nested/InRecord/OutterForImmutableArray.{T}.cs @@ -0,0 +1,16 @@ +namespace Monify.Console.Classes.Nested.InRecord; + +using System.Collections.Immutable; + +/// +/// Provides a nested record example that uses Monify with immutable array of string types. +/// +/// The record type that the outer record is parameterized with. +public sealed partial record OutterForImmutableArray +{ + /// + /// Represents the inner class decorated by Monify for immutable array of string types. + /// + [Monify>] + public sealed partial class Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Classes/Nested/InRecord/OutterForInt.{T}.cs b/src/Monify.Console/Classes/Nested/InRecord/OutterForInt.{T}.cs new file mode 100644 index 0000000..c710693 --- /dev/null +++ b/src/Monify.Console/Classes/Nested/InRecord/OutterForInt.{T}.cs @@ -0,0 +1,15 @@ +namespace Monify.Console.Classes.Nested.InRecord; + +/// +/// Provides a nested record example that uses Monify with integer types. +/// +/// The struct type that the outer record is parameterized with. +public sealed partial record OutterForInt + where T : struct +{ + /// + /// Represents the inner class decorated by Monify for integer types. + /// + [Monify] + public sealed partial class Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Classes/Nested/InRecord/OutterForString.{T}.cs b/src/Monify.Console/Classes/Nested/InRecord/OutterForString.{T}.cs new file mode 100644 index 0000000..a2c6deb --- /dev/null +++ b/src/Monify.Console/Classes/Nested/InRecord/OutterForString.{T}.cs @@ -0,0 +1,15 @@ +namespace Monify.Console.Classes.Nested.InRecord; + +/// +/// Provides a nested record example that uses Monify with string types. +/// +/// The struct type that the outer record is parameterized with. +public sealed partial record OutterForString + where T : struct +{ + /// + /// Represents the inner class decorated by Monify for string types. + /// + [Monify] + public sealed partial class Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Classes/Nested/InRecordStruct/OutterForArray.{T}.cs b/src/Monify.Console/Classes/Nested/InRecordStruct/OutterForArray.{T}.cs new file mode 100644 index 0000000..8885d1d --- /dev/null +++ b/src/Monify.Console/Classes/Nested/InRecordStruct/OutterForArray.{T}.cs @@ -0,0 +1,15 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct; + +/// +/// Provides a nested record struct example that uses Monify with integer array types. +/// +/// The struct type that the outer record struct is parameterized with. +public readonly partial record struct OutterForArray + where T : struct +{ + /// + /// Represents the inner class decorated by Monify for integer array types. + /// + [Monify] + public sealed partial class Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Classes/Nested/InRecordStruct/OutterForImmutableArray.{T}.cs b/src/Monify.Console/Classes/Nested/InRecordStruct/OutterForImmutableArray.{T}.cs new file mode 100644 index 0000000..6a85fb9 --- /dev/null +++ b/src/Monify.Console/Classes/Nested/InRecordStruct/OutterForImmutableArray.{T}.cs @@ -0,0 +1,16 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct; + +using System.Collections.Immutable; + +/// +/// Provides a nested record struct example that uses Monify with immutable array of string types. +/// +/// The record struct type that the outer record struct is parameterized with. +public readonly partial record struct OutterForImmutableArray +{ + /// + /// Represents the inner class decorated by Monify for immutable array of string types. + /// + [Monify>] + public sealed partial class Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Classes/Nested/InRecordStruct/OutterForInt.{T}.cs b/src/Monify.Console/Classes/Nested/InRecordStruct/OutterForInt.{T}.cs new file mode 100644 index 0000000..040be27 --- /dev/null +++ b/src/Monify.Console/Classes/Nested/InRecordStruct/OutterForInt.{T}.cs @@ -0,0 +1,15 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct; + +/// +/// Provides a nested record struct example that uses Monify with integer types. +/// +/// The struct type that the outer record struct is parameterized with. +public readonly partial record struct OutterForInt + where T : struct +{ + /// + /// Represents the inner class decorated by Monify for integer types. + /// + [Monify] + public sealed partial class Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Classes/Nested/InRecordStruct/OutterForString.{T}.cs b/src/Monify.Console/Classes/Nested/InRecordStruct/OutterForString.{T}.cs new file mode 100644 index 0000000..3599a63 --- /dev/null +++ b/src/Monify.Console/Classes/Nested/InRecordStruct/OutterForString.{T}.cs @@ -0,0 +1,15 @@ +namespace Monify.Console.Classes.Nested.InRecordStruct; + +/// +/// Provides a nested record struct example that uses Monify with string types. +/// +/// The struct type that the outer record struct is parameterized with. +public readonly partial record struct OutterForString + where T : struct +{ + /// + /// Represents the inner class decorated by Monify for string types. + /// + [Monify] + public sealed partial class Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Classes/Nested/InStruct/OutterForArray.{T}.cs b/src/Monify.Console/Classes/Nested/InStruct/OutterForArray.{T}.cs new file mode 100644 index 0000000..863f4c2 --- /dev/null +++ b/src/Monify.Console/Classes/Nested/InStruct/OutterForArray.{T}.cs @@ -0,0 +1,15 @@ +namespace Monify.Console.Classes.Nested.InStruct; + +/// +/// Provides a nested struct example that uses Monify with integer array types. +/// +/// The struct type that the outer struct is parameterized with. +public readonly ref partial struct OutterForArray + where T : struct +{ + /// + /// Represents the inner class decorated by Monify for integer array types. + /// + [Monify] + public sealed partial class Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Classes/Nested/InStruct/OutterForImmutableArray.{T}.cs b/src/Monify.Console/Classes/Nested/InStruct/OutterForImmutableArray.{T}.cs new file mode 100644 index 0000000..e81b65f --- /dev/null +++ b/src/Monify.Console/Classes/Nested/InStruct/OutterForImmutableArray.{T}.cs @@ -0,0 +1,17 @@ +namespace Monify.Console.Classes.Nested.InStruct; + +using System.Collections.Immutable; + +/// +/// Provides a nested struct example that uses Monify with immutable array of string types. +/// +/// The struct type that the outer struct is parameterized with. +public readonly ref partial struct OutterForImmutableArray + where T : struct +{ + /// + /// Represents the inner class decorated by Monify for immutable array of string types. + /// + [Monify>] + public sealed partial class Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Classes/Nested/InStruct/OutterForInt.{T}.cs b/src/Monify.Console/Classes/Nested/InStruct/OutterForInt.{T}.cs new file mode 100644 index 0000000..16531d1 --- /dev/null +++ b/src/Monify.Console/Classes/Nested/InStruct/OutterForInt.{T}.cs @@ -0,0 +1,15 @@ +namespace Monify.Console.Classes.Nested.InStruct; + +/// +/// Provides a nested struct example that uses Monify with integer types. +/// +/// The struct type that the outer struct is parameterized with. +public readonly ref partial struct OutterForInt + where T : struct +{ + /// + /// Represents the inner class decorated by Monify for integer types. + /// + [Monify] + public sealed partial class Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Classes/Nested/InStruct/OutterForString.{T}.cs b/src/Monify.Console/Classes/Nested/InStruct/OutterForString.{T}.cs new file mode 100644 index 0000000..c456727 --- /dev/null +++ b/src/Monify.Console/Classes/Nested/InStruct/OutterForString.{T}.cs @@ -0,0 +1,15 @@ +namespace Monify.Console.Classes.Nested.InStruct; + +/// +/// Provides a nested struct example that uses Monify with string types. +/// +/// The struct type that the outer struct is parameterized with. +public readonly ref partial struct OutterForString + where T : struct +{ + /// + /// Represents the inner class decorated by Monify for string types. + /// + [Monify] + public sealed partial class Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Classes/Simple/SimpleForArray.cs b/src/Monify.Console/Classes/Simple/SimpleForArray.cs new file mode 100644 index 0000000..99d12c1 --- /dev/null +++ b/src/Monify.Console/Classes/Simple/SimpleForArray.cs @@ -0,0 +1,7 @@ +namespace Monify.Console.Classes.Simple; + +/// +/// Represents a simple class decorated by Monify for integer array types. +/// +[Monify] +public partial class SimpleForArray; \ No newline at end of file diff --git a/src/Monify.Console/Classes/Simple/SimpleForImmutableArray.cs b/src/Monify.Console/Classes/Simple/SimpleForImmutableArray.cs new file mode 100644 index 0000000..8d4aae9 --- /dev/null +++ b/src/Monify.Console/Classes/Simple/SimpleForImmutableArray.cs @@ -0,0 +1,9 @@ +namespace Monify.Console.Classes.Simple; + +using System.Collections.Immutable; + +/// +/// Represents a simple class decorated by Monify for immutable array of string types. +/// +[Monify>] +public partial class SimpleForImmutableArray; \ No newline at end of file diff --git a/src/Monify.Console/Classes/Simple/SimpleForInt.cs b/src/Monify.Console/Classes/Simple/SimpleForInt.cs new file mode 100644 index 0000000..165e0d5 --- /dev/null +++ b/src/Monify.Console/Classes/Simple/SimpleForInt.cs @@ -0,0 +1,7 @@ +namespace Monify.Console.Classes.Simple; + +/// +/// Represents a simple class decorated by Monify for integer types. +/// +[Monify] +public partial class SimpleForInt; \ No newline at end of file diff --git a/src/Monify.Console/Classes/Simple/SimpleForString.cs b/src/Monify.Console/Classes/Simple/SimpleForString.cs new file mode 100644 index 0000000..13e2987 --- /dev/null +++ b/src/Monify.Console/Classes/Simple/SimpleForString.cs @@ -0,0 +1,7 @@ +namespace Monify.Console.Classes.Simple; + +/// +/// Represents a simple class decorated by Monify for string types. +/// +[Monify] +public partial class SimpleForString; \ No newline at end of file diff --git a/src/Monify.Console/Monify.Console.csproj b/src/Monify.Console/Monify.Console.csproj new file mode 100644 index 0000000..304cb80 --- /dev/null +++ b/src/Monify.Console/Monify.Console.csproj @@ -0,0 +1,17 @@ + + + false + Exe + S2326 + net9.0 + + + + + + + all + runtime; build; native; contentfiles; analyzers + + + \ No newline at end of file diff --git a/src/Monify.Console/Program.cs b/src/Monify.Console/Program.cs new file mode 100644 index 0000000..044ef8f --- /dev/null +++ b/src/Monify.Console/Program.cs @@ -0,0 +1,17 @@ +namespace Monify.Console; + +using static System.Console; + +/// +/// Entry point for the application, which is used to facilitate debugging of the Monify project. +/// +internal static class Program +{ + /// + /// Entry point for the application, which is used to facilitate debugging of the Monify project. + /// + public static void Main() + { + WriteLine("Test Application for Monify"); + } +} \ No newline at end of file diff --git a/src/Monify.Console/Records/Nested/InClass/OutterForArray.{T}.cs b/src/Monify.Console/Records/Nested/InClass/OutterForArray.{T}.cs new file mode 100644 index 0000000..36b45ec --- /dev/null +++ b/src/Monify.Console/Records/Nested/InClass/OutterForArray.{T}.cs @@ -0,0 +1,8 @@ +namespace Monify.Console.Records.Nested.InClass; + +public sealed partial class OutterForArray + where T : struct +{ + [Monify] + public sealed partial record Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Records/Nested/InClass/OutterForImmutableArray.{T}.cs b/src/Monify.Console/Records/Nested/InClass/OutterForImmutableArray.{T}.cs new file mode 100644 index 0000000..53e3b52 --- /dev/null +++ b/src/Monify.Console/Records/Nested/InClass/OutterForImmutableArray.{T}.cs @@ -0,0 +1,16 @@ +namespace Monify.Console.Records.Nested.InClass; + +using System.Collections.Immutable; + +/// +/// Provides a nested class example that uses Monify with immutable array of string types. +/// +/// The class type that the outer class is parameterized with. +public sealed partial class OutterForImmutableArray +{ + /// + /// Represents the inner record decorated by Monify for immutable array of string types. + /// + [Monify>] + public sealed partial record Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Records/Nested/InClass/OutterForInt.{T}.cs b/src/Monify.Console/Records/Nested/InClass/OutterForInt.{T}.cs new file mode 100644 index 0000000..dcbb8ea --- /dev/null +++ b/src/Monify.Console/Records/Nested/InClass/OutterForInt.{T}.cs @@ -0,0 +1,8 @@ +namespace Monify.Console.Records.Nested.InClass; + +public sealed partial class OutterForInt + where T : struct +{ + [Monify] + public sealed partial record Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Records/Nested/InClass/OutterForString.{T}.cs b/src/Monify.Console/Records/Nested/InClass/OutterForString.{T}.cs new file mode 100644 index 0000000..fa5946a --- /dev/null +++ b/src/Monify.Console/Records/Nested/InClass/OutterForString.{T}.cs @@ -0,0 +1,8 @@ +namespace Monify.Console.Records.Nested.InClass; + +public sealed partial class OutterForString + where T : struct +{ + [Monify] + public sealed partial record Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Records/Nested/InInterface/IOutterForArray.{T}.cs b/src/Monify.Console/Records/Nested/InInterface/IOutterForArray.{T}.cs new file mode 100644 index 0000000..46fb985 --- /dev/null +++ b/src/Monify.Console/Records/Nested/InInterface/IOutterForArray.{T}.cs @@ -0,0 +1,8 @@ +namespace Monify.Console.Records.Nested.InInterface; + +public partial interface IOutterForArray + where T : struct +{ + [Monify] + public sealed partial record Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Records/Nested/InInterface/IOutterForImmutableArray.{T}.cs b/src/Monify.Console/Records/Nested/InInterface/IOutterForImmutableArray.{T}.cs new file mode 100644 index 0000000..9b4d815 --- /dev/null +++ b/src/Monify.Console/Records/Nested/InInterface/IOutterForImmutableArray.{T}.cs @@ -0,0 +1,17 @@ +namespace Monify.Console.Records.Nested.InInterface; + +using System.Collections.Immutable; + +/// +/// Provides a nested interface example that uses Monify with immutable array of string types. +/// +/// The struct type that the interface is parameterized with. +public partial interface IOutterForImmutableArray + where T : struct +{ + /// + /// Represents the inner record decorated by Monify for immutable array of string types. + /// + [Monify>] + public sealed partial record Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Records/Nested/InInterface/IOutterForInt.{T}.cs b/src/Monify.Console/Records/Nested/InInterface/IOutterForInt.{T}.cs new file mode 100644 index 0000000..a32d3d8 --- /dev/null +++ b/src/Monify.Console/Records/Nested/InInterface/IOutterForInt.{T}.cs @@ -0,0 +1,8 @@ +namespace Monify.Console.Records.Nested.InInterface; + +public partial interface IOutterForInt + where T : struct +{ + [Monify] + public sealed partial record Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Records/Nested/InInterface/IOutterForString.{T}.cs b/src/Monify.Console/Records/Nested/InInterface/IOutterForString.{T}.cs new file mode 100644 index 0000000..f95e8d5 --- /dev/null +++ b/src/Monify.Console/Records/Nested/InInterface/IOutterForString.{T}.cs @@ -0,0 +1,8 @@ +namespace Monify.Console.Records.Nested.InInterface; + +public partial interface IOutterForString + where T : struct +{ + [Monify] + public sealed partial record Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Records/Nested/InRecord/OutterForArray.{T}.cs b/src/Monify.Console/Records/Nested/InRecord/OutterForArray.{T}.cs new file mode 100644 index 0000000..eb4314c --- /dev/null +++ b/src/Monify.Console/Records/Nested/InRecord/OutterForArray.{T}.cs @@ -0,0 +1,8 @@ +namespace Monify.Console.Records.Nested.InRecord; + +public sealed partial record OutterForArray + where T : struct +{ + [Monify] + public sealed partial record Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Records/Nested/InRecord/OutterForImmutableArray.{T}.cs b/src/Monify.Console/Records/Nested/InRecord/OutterForImmutableArray.{T}.cs new file mode 100644 index 0000000..c1d0cab --- /dev/null +++ b/src/Monify.Console/Records/Nested/InRecord/OutterForImmutableArray.{T}.cs @@ -0,0 +1,16 @@ +namespace Monify.Console.Records.Nested.InRecord; + +using System.Collections.Immutable; + +/// +/// Provides a nested record example that uses Monify with immutable array of string types. +/// +/// The record type that the outer record is parameterized with. +public sealed partial record OutterForImmutableArray +{ + /// + /// Represents the inner record decorated by Monify for immutable array of string types. + /// + [Monify>] + public sealed partial record Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Records/Nested/InRecord/OutterForInt.{T}.cs b/src/Monify.Console/Records/Nested/InRecord/OutterForInt.{T}.cs new file mode 100644 index 0000000..36f1586 --- /dev/null +++ b/src/Monify.Console/Records/Nested/InRecord/OutterForInt.{T}.cs @@ -0,0 +1,8 @@ +namespace Monify.Console.Records.Nested.InRecord; + +public sealed partial record OutterForInt + where T : struct +{ + [Monify] + public sealed partial record Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Records/Nested/InRecord/OutterForString.{T}.cs b/src/Monify.Console/Records/Nested/InRecord/OutterForString.{T}.cs new file mode 100644 index 0000000..5060f6d --- /dev/null +++ b/src/Monify.Console/Records/Nested/InRecord/OutterForString.{T}.cs @@ -0,0 +1,8 @@ +namespace Monify.Console.Records.Nested.InRecord; + +public sealed partial record OutterForString + where T : struct +{ + [Monify] + public sealed partial record Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Records/Nested/InRecordStruct/OutterForArray.{T}.cs b/src/Monify.Console/Records/Nested/InRecordStruct/OutterForArray.{T}.cs new file mode 100644 index 0000000..b78d294 --- /dev/null +++ b/src/Monify.Console/Records/Nested/InRecordStruct/OutterForArray.{T}.cs @@ -0,0 +1,8 @@ +namespace Monify.Console.Records.Nested.InRecordStruct; + +public readonly partial record struct OutterForArray + where T : struct +{ + [Monify] + public sealed partial record Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Records/Nested/InRecordStruct/OutterForImmutableArray.{T}.cs b/src/Monify.Console/Records/Nested/InRecordStruct/OutterForImmutableArray.{T}.cs new file mode 100644 index 0000000..3242027 --- /dev/null +++ b/src/Monify.Console/Records/Nested/InRecordStruct/OutterForImmutableArray.{T}.cs @@ -0,0 +1,16 @@ +namespace Monify.Console.Records.Nested.InRecordStruct; + +using System.Collections.Immutable; + +/// +/// Provides a nested record struct example that uses Monify with immutable array of string types. +/// +/// The record struct type that the outer record struct is parameterized with. +public readonly partial record struct OutterForImmutableArray +{ + /// + /// Represents the inner record decorated by Monify for immutable array of string types. + /// + [Monify>] + public sealed partial record Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Records/Nested/InRecordStruct/OutterForInt.{T}.cs b/src/Monify.Console/Records/Nested/InRecordStruct/OutterForInt.{T}.cs new file mode 100644 index 0000000..e96ea58 --- /dev/null +++ b/src/Monify.Console/Records/Nested/InRecordStruct/OutterForInt.{T}.cs @@ -0,0 +1,8 @@ +namespace Monify.Console.Records.Nested.InRecordStruct; + +public readonly partial record struct OutterForInt + where T : struct +{ + [Monify] + public sealed partial record Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Records/Nested/InRecordStruct/OutterForString.{T}.cs b/src/Monify.Console/Records/Nested/InRecordStruct/OutterForString.{T}.cs new file mode 100644 index 0000000..5a240f2 --- /dev/null +++ b/src/Monify.Console/Records/Nested/InRecordStruct/OutterForString.{T}.cs @@ -0,0 +1,8 @@ +namespace Monify.Console.Records.Nested.InRecordStruct; + +public readonly partial record struct OutterForString + where T : struct +{ + [Monify] + public sealed partial record Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Records/Nested/InStruct/OutterForArray.{T}.cs b/src/Monify.Console/Records/Nested/InStruct/OutterForArray.{T}.cs new file mode 100644 index 0000000..33c93a1 --- /dev/null +++ b/src/Monify.Console/Records/Nested/InStruct/OutterForArray.{T}.cs @@ -0,0 +1,8 @@ +namespace Monify.Console.Records.Nested.InStruct; + +public readonly ref partial struct OutterForArray + where T : struct +{ + [Monify] + public sealed partial record Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Records/Nested/InStruct/OutterForImmutableArray.{T}.cs b/src/Monify.Console/Records/Nested/InStruct/OutterForImmutableArray.{T}.cs new file mode 100644 index 0000000..d7514a4 --- /dev/null +++ b/src/Monify.Console/Records/Nested/InStruct/OutterForImmutableArray.{T}.cs @@ -0,0 +1,17 @@ +namespace Monify.Console.Records.Nested.InStruct; + +using System.Collections.Immutable; + +/// +/// Provides a nested struct example that uses Monify with immutable array of string types. +/// +/// The struct type that the outer struct is parameterized with. +public readonly ref partial struct OutterForImmutableArray + where T : struct +{ + /// + /// Represents the inner record decorated by Monify for immutable array of string types. + /// + [Monify>] + public sealed partial record Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Records/Nested/InStruct/OutterForInt.{T}.cs b/src/Monify.Console/Records/Nested/InStruct/OutterForInt.{T}.cs new file mode 100644 index 0000000..03d60d7 --- /dev/null +++ b/src/Monify.Console/Records/Nested/InStruct/OutterForInt.{T}.cs @@ -0,0 +1,8 @@ +namespace Monify.Console.Records.Nested.InStruct; + +public readonly ref partial struct OutterForInt + where T : struct +{ + [Monify] + public sealed partial record Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Records/Nested/InStruct/OutterForString.{T}.cs b/src/Monify.Console/Records/Nested/InStruct/OutterForString.{T}.cs new file mode 100644 index 0000000..0e33c75 --- /dev/null +++ b/src/Monify.Console/Records/Nested/InStruct/OutterForString.{T}.cs @@ -0,0 +1,8 @@ +namespace Monify.Console.Records.Nested.InStruct; + +public readonly ref partial struct OutterForString + where T : struct +{ + [Monify] + public sealed partial record Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Records/Simple/SimpleForArray.cs b/src/Monify.Console/Records/Simple/SimpleForArray.cs new file mode 100644 index 0000000..e1d3428 --- /dev/null +++ b/src/Monify.Console/Records/Simple/SimpleForArray.cs @@ -0,0 +1,7 @@ +namespace Monify.Console.Records.Simple; + +/// +/// Represents a simple record decorated by Monify for integer array types. +/// +[Monify] +public partial record SimpleForArray; \ No newline at end of file diff --git a/src/Monify.Console/Records/Simple/SimpleForImmutableArray.cs b/src/Monify.Console/Records/Simple/SimpleForImmutableArray.cs new file mode 100644 index 0000000..1dd50f0 --- /dev/null +++ b/src/Monify.Console/Records/Simple/SimpleForImmutableArray.cs @@ -0,0 +1,9 @@ +namespace Monify.Console.Records.Simple; + +using System.Collections.Immutable; + +/// +/// Represents a simple record decorated by Monify for immutable array of string types. +/// +[Monify>] +public partial record SimpleForImmutableArray; \ No newline at end of file diff --git a/src/Monify.Console/Records/Simple/SimpleForInt.cs b/src/Monify.Console/Records/Simple/SimpleForInt.cs new file mode 100644 index 0000000..09cc9e1 --- /dev/null +++ b/src/Monify.Console/Records/Simple/SimpleForInt.cs @@ -0,0 +1,7 @@ +namespace Monify.Console.Records.Simple; + +/// +/// Represents a simple record decorated by Monify for integer types. +/// +[Monify] +public partial record SimpleForInt; \ No newline at end of file diff --git a/src/Monify.Console/Records/Simple/SimpleForString.cs b/src/Monify.Console/Records/Simple/SimpleForString.cs new file mode 100644 index 0000000..54f9ff3 --- /dev/null +++ b/src/Monify.Console/Records/Simple/SimpleForString.cs @@ -0,0 +1,7 @@ +namespace Monify.Console.Records.Simple; + +/// +/// Represents a simple record decorated by Monify for string types. +/// +[Monify] +public partial record SimpleForString; \ No newline at end of file diff --git a/src/Monify.Console/Structs/Nested/InClass/OutterForArray.{T}.cs b/src/Monify.Console/Structs/Nested/InClass/OutterForArray.{T}.cs new file mode 100644 index 0000000..a2fa67a --- /dev/null +++ b/src/Monify.Console/Structs/Nested/InClass/OutterForArray.{T}.cs @@ -0,0 +1,8 @@ +namespace Monify.Console.Structs.Nested.InClass; + +public sealed partial class OutterForArray + where T : struct +{ + [Monify] + public readonly partial struct Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Structs/Nested/InClass/OutterForImmutableArray.{T}.cs b/src/Monify.Console/Structs/Nested/InClass/OutterForImmutableArray.{T}.cs new file mode 100644 index 0000000..6de1e13 --- /dev/null +++ b/src/Monify.Console/Structs/Nested/InClass/OutterForImmutableArray.{T}.cs @@ -0,0 +1,16 @@ +namespace Monify.Console.Structs.Nested.InClass; + +using System.Collections.Immutable; + +/// +/// Provides a nested class example that uses Monify with immutable array of string types. +/// +/// The class type that the outer class is parameterized with. +public sealed partial class OutterForImmutableArray +{ + /// + /// Represents the inner struct decorated by Monify for immutable array of string types. + /// + [Monify>] + public readonly partial struct Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Structs/Nested/InClass/OutterForInt.{T}.cs b/src/Monify.Console/Structs/Nested/InClass/OutterForInt.{T}.cs new file mode 100644 index 0000000..24d445c --- /dev/null +++ b/src/Monify.Console/Structs/Nested/InClass/OutterForInt.{T}.cs @@ -0,0 +1,8 @@ +namespace Monify.Console.Structs.Nested.InClass; + +public sealed partial class OutterForInt + where T : struct +{ + [Monify] + public readonly partial struct Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Structs/Nested/InClass/OutterForString.{T}.cs b/src/Monify.Console/Structs/Nested/InClass/OutterForString.{T}.cs new file mode 100644 index 0000000..cb7203a --- /dev/null +++ b/src/Monify.Console/Structs/Nested/InClass/OutterForString.{T}.cs @@ -0,0 +1,8 @@ +namespace Monify.Console.Structs.Nested.InClass; + +public sealed partial class OutterForString + where T : struct +{ + [Monify] + public readonly partial struct Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Structs/Nested/InInterface/IOutterForArray.{T}.cs b/src/Monify.Console/Structs/Nested/InInterface/IOutterForArray.{T}.cs new file mode 100644 index 0000000..5862e9a --- /dev/null +++ b/src/Monify.Console/Structs/Nested/InInterface/IOutterForArray.{T}.cs @@ -0,0 +1,8 @@ +namespace Monify.Console.Structs.Nested.InInterface; + +public partial interface IOutterForArray + where T : struct +{ + [Monify] + public readonly partial struct Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Structs/Nested/InInterface/IOutterForImmutableArray.{T}.cs b/src/Monify.Console/Structs/Nested/InInterface/IOutterForImmutableArray.{T}.cs new file mode 100644 index 0000000..dbd66eb --- /dev/null +++ b/src/Monify.Console/Structs/Nested/InInterface/IOutterForImmutableArray.{T}.cs @@ -0,0 +1,17 @@ +namespace Monify.Console.Structs.Nested.InInterface; + +using System.Collections.Immutable; + +/// +/// Provides a nested interface example that uses Monify with immutable array of string types. +/// +/// The struct type that the interface is parameterized with. +public partial interface IOutterForImmutableArray + where T : struct +{ + /// + /// Represents the inner struct decorated by Monify for immutable array of string types. + /// + [Monify>] + public readonly partial struct Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Structs/Nested/InInterface/IOutterForInt.{T}.cs b/src/Monify.Console/Structs/Nested/InInterface/IOutterForInt.{T}.cs new file mode 100644 index 0000000..9c534cd --- /dev/null +++ b/src/Monify.Console/Structs/Nested/InInterface/IOutterForInt.{T}.cs @@ -0,0 +1,8 @@ +namespace Monify.Console.Structs.Nested.InInterface; + +public partial interface IOutterForInt + where T : struct +{ + [Monify] + public readonly partial struct Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Structs/Nested/InInterface/IOutterForString.{T}.cs b/src/Monify.Console/Structs/Nested/InInterface/IOutterForString.{T}.cs new file mode 100644 index 0000000..6c6fd7b --- /dev/null +++ b/src/Monify.Console/Structs/Nested/InInterface/IOutterForString.{T}.cs @@ -0,0 +1,8 @@ +namespace Monify.Console.Structs.Nested.InInterface; + +public partial interface IOutterForString + where T : struct +{ + [Monify] + public readonly partial struct Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Structs/Nested/InRecord/OutterForArray.{T}.cs b/src/Monify.Console/Structs/Nested/InRecord/OutterForArray.{T}.cs new file mode 100644 index 0000000..b522b5a --- /dev/null +++ b/src/Monify.Console/Structs/Nested/InRecord/OutterForArray.{T}.cs @@ -0,0 +1,8 @@ +namespace Monify.Console.Structs.Nested.InRecord; + +public sealed partial record OutterForArray + where T : struct +{ + [Monify] + public readonly partial struct Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Structs/Nested/InRecord/OutterForImmutableArray.{T}.cs b/src/Monify.Console/Structs/Nested/InRecord/OutterForImmutableArray.{T}.cs new file mode 100644 index 0000000..1155352 --- /dev/null +++ b/src/Monify.Console/Structs/Nested/InRecord/OutterForImmutableArray.{T}.cs @@ -0,0 +1,16 @@ +namespace Monify.Console.Structs.Nested.InRecord; + +using System.Collections.Immutable; + +/// +/// Provides a nested record example that uses Monify with immutable array of string types. +/// +/// The record type that the outer record is parameterized with. +public sealed partial record OutterForImmutableArray +{ + /// + /// Represents the inner struct decorated by Monify for immutable array of string types. + /// + [Monify>] + public readonly partial struct Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Structs/Nested/InRecord/OutterForInt.{T}.cs b/src/Monify.Console/Structs/Nested/InRecord/OutterForInt.{T}.cs new file mode 100644 index 0000000..d72f4f7 --- /dev/null +++ b/src/Monify.Console/Structs/Nested/InRecord/OutterForInt.{T}.cs @@ -0,0 +1,8 @@ +namespace Monify.Console.Structs.Nested.InRecord; + +public sealed partial record OutterForInt + where T : struct +{ + [Monify] + public readonly partial struct Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Structs/Nested/InRecord/OutterForString.{T}.cs b/src/Monify.Console/Structs/Nested/InRecord/OutterForString.{T}.cs new file mode 100644 index 0000000..3927241 --- /dev/null +++ b/src/Monify.Console/Structs/Nested/InRecord/OutterForString.{T}.cs @@ -0,0 +1,8 @@ +namespace Monify.Console.Structs.Nested.InRecord; + +public sealed partial record OutterForString + where T : struct +{ + [Monify] + public readonly partial struct Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Structs/Nested/InRecordStruct/OutterForArray.{T}.cs b/src/Monify.Console/Structs/Nested/InRecordStruct/OutterForArray.{T}.cs new file mode 100644 index 0000000..7daba7a --- /dev/null +++ b/src/Monify.Console/Structs/Nested/InRecordStruct/OutterForArray.{T}.cs @@ -0,0 +1,8 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct; + +public readonly partial record struct OutterForArray + where T : struct +{ + [Monify] + public readonly partial struct Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Structs/Nested/InRecordStruct/OutterForImmutableArray.{T}.cs b/src/Monify.Console/Structs/Nested/InRecordStruct/OutterForImmutableArray.{T}.cs new file mode 100644 index 0000000..e17975c --- /dev/null +++ b/src/Monify.Console/Structs/Nested/InRecordStruct/OutterForImmutableArray.{T}.cs @@ -0,0 +1,16 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct; + +using System.Collections.Immutable; + +/// +/// Provides a nested record struct example that uses Monify with immutable array of string types. +/// +/// The record struct type that the outer record struct is parameterized with. +public readonly partial record struct OutterForImmutableArray +{ + /// + /// Represents the inner struct decorated by Monify for immutable array of string types. + /// + [Monify>] + public readonly partial struct Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Structs/Nested/InRecordStruct/OutterForInt.{T}.cs b/src/Monify.Console/Structs/Nested/InRecordStruct/OutterForInt.{T}.cs new file mode 100644 index 0000000..32a20ae --- /dev/null +++ b/src/Monify.Console/Structs/Nested/InRecordStruct/OutterForInt.{T}.cs @@ -0,0 +1,8 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct; + +public readonly partial record struct OutterForInt + where T : struct +{ + [Monify] + public readonly partial struct Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Structs/Nested/InRecordStruct/OutterForString.{T}.cs b/src/Monify.Console/Structs/Nested/InRecordStruct/OutterForString.{T}.cs new file mode 100644 index 0000000..cfb2522 --- /dev/null +++ b/src/Monify.Console/Structs/Nested/InRecordStruct/OutterForString.{T}.cs @@ -0,0 +1,8 @@ +namespace Monify.Console.Structs.Nested.InRecordStruct; + +public readonly partial record struct OutterForString + where T : struct +{ + [Monify] + public readonly partial struct Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Structs/Nested/InStruct/OutterForArray.{T}.cs b/src/Monify.Console/Structs/Nested/InStruct/OutterForArray.{T}.cs new file mode 100644 index 0000000..51b8a24 --- /dev/null +++ b/src/Monify.Console/Structs/Nested/InStruct/OutterForArray.{T}.cs @@ -0,0 +1,8 @@ +namespace Monify.Console.Structs.Nested.InStruct; + +public readonly ref partial struct OutterForArray + where T : struct +{ + [Monify] + public readonly partial struct Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Structs/Nested/InStruct/OutterForImmutableArray.{T}.cs b/src/Monify.Console/Structs/Nested/InStruct/OutterForImmutableArray.{T}.cs new file mode 100644 index 0000000..f7d274d --- /dev/null +++ b/src/Monify.Console/Structs/Nested/InStruct/OutterForImmutableArray.{T}.cs @@ -0,0 +1,17 @@ +namespace Monify.Console.Structs.Nested.InStruct; + +using System.Collections.Immutable; + +/// +/// Provides a nested struct example that uses Monify with immutable array of string types. +/// +/// The struct type that the outer struct is parameterized with. +public readonly ref partial struct OutterForImmutableArray + where T : struct +{ + /// + /// Represents the inner struct decorated by Monify for immutable array of string types. + /// + [Monify>] + public readonly partial struct Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Structs/Nested/InStruct/OutterForInt.{T}.cs b/src/Monify.Console/Structs/Nested/InStruct/OutterForInt.{T}.cs new file mode 100644 index 0000000..7d98f98 --- /dev/null +++ b/src/Monify.Console/Structs/Nested/InStruct/OutterForInt.{T}.cs @@ -0,0 +1,8 @@ +namespace Monify.Console.Structs.Nested.InStruct; + +public readonly ref partial struct OutterForInt + where T : struct +{ + [Monify] + public readonly partial struct Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Structs/Nested/InStruct/OutterForString.{T}.cs b/src/Monify.Console/Structs/Nested/InStruct/OutterForString.{T}.cs new file mode 100644 index 0000000..f433eda --- /dev/null +++ b/src/Monify.Console/Structs/Nested/InStruct/OutterForString.{T}.cs @@ -0,0 +1,8 @@ +namespace Monify.Console.Structs.Nested.InStruct; + +public readonly ref partial struct OutterForString + where T : struct +{ + [Monify] + public readonly partial struct Inner; +} \ No newline at end of file diff --git a/src/Monify.Console/Structs/Simple/SimpleForArray.cs b/src/Monify.Console/Structs/Simple/SimpleForArray.cs new file mode 100644 index 0000000..11fa258 --- /dev/null +++ b/src/Monify.Console/Structs/Simple/SimpleForArray.cs @@ -0,0 +1,7 @@ +namespace Monify.Console.Structs.Simple; + +/// +/// Represents a simple readonly struct decorated by Monify for integer array types. +/// +[Monify] +public readonly partial struct SimpleForArray; \ No newline at end of file diff --git a/src/Monify.Console/Structs/Simple/SimpleForImmutableArray.cs b/src/Monify.Console/Structs/Simple/SimpleForImmutableArray.cs new file mode 100644 index 0000000..0d77632 --- /dev/null +++ b/src/Monify.Console/Structs/Simple/SimpleForImmutableArray.cs @@ -0,0 +1,9 @@ +namespace Monify.Console.Structs.Simple; + +using System.Collections.Immutable; + +/// +/// Represents a simple struct decorated by Monify for immutable array of string types. +/// +[Monify>] +public readonly partial struct SimpleForImmutableArray; \ No newline at end of file diff --git a/src/Monify.Console/Structs/Simple/SimpleForInt.cs b/src/Monify.Console/Structs/Simple/SimpleForInt.cs new file mode 100644 index 0000000..93dcfaf --- /dev/null +++ b/src/Monify.Console/Structs/Simple/SimpleForInt.cs @@ -0,0 +1,7 @@ +namespace Monify.Console.Structs.Simple; + +/// +/// Represents a simple readonly struct decorated by Monify for integer types. +/// +[Monify] +public readonly partial struct SimpleForInt; \ No newline at end of file diff --git a/src/Monify.Console/Structs/Simple/SimpleForString.cs b/src/Monify.Console/Structs/Simple/SimpleForString.cs new file mode 100644 index 0000000..bc47d27 --- /dev/null +++ b/src/Monify.Console/Structs/Simple/SimpleForString.cs @@ -0,0 +1,7 @@ +namespace Monify.Console.Structs.Simple; + +/// +/// Represents a simple readonly struct decorated by Monify for string types. +/// +[Monify] +public readonly partial struct SimpleForString; \ No newline at end of file diff --git a/src/Monify.Tests/GeneratorTest.cs b/src/Monify.Tests/GeneratorTest.cs index 81e4adf..6de0753 100644 --- a/src/Monify.Tests/GeneratorTest.cs +++ b/src/Monify.Tests/GeneratorTest.cs @@ -9,26 +9,26 @@ public sealed class GeneratorTest : CSharpSourceGeneratorTest where TGenerator : new() { - private readonly Type[] generators; - private readonly LanguageVersion language; + private readonly Type[] _generators; + private readonly LanguageVersion _language; public GeneratorTest(ReferenceAssemblies assembly, LanguageVersion language, params Type[] generators) { - this.generators = generators.Length == 0 + _generators = generators.Length == 0 ? [typeof(TGenerator)] : generators; - this.language = language; + _language = language; ReferenceAssemblies = assembly; } protected sealed override ParseOptions CreateParseOptions() { - return new CSharpParseOptions(language); + return new CSharpParseOptions(_language); } protected sealed override IEnumerable GetSourceGenerators() { - return generators; + return _generators; } } \ No newline at end of file diff --git a/src/Monify.Tests/HashCodeGeneratorTests/WhenExecuted.cs b/src/Monify.Tests/HashCodeGeneratorTests/WhenExecuted.cs new file mode 100644 index 0000000..6ce4f47 --- /dev/null +++ b/src/Monify.Tests/HashCodeGeneratorTests/WhenExecuted.cs @@ -0,0 +1,24 @@ +namespace Monify.HashCodeGeneratorTests; + +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.Testing; +using Monify.Snippets.Declarations; + +public sealed class WhenExecuted +{ + [Theory] + [Frameworks] + public async Task GivenAnAssemblyThenTheClassIsGenerated(ReferenceAssemblies assemblies, LanguageVersion language) + { + // Arrange + var test = new GeneratorTest(assemblies, language); + + Internal.HashCode.IsExpectedIn(test.TestState); + + // Act + Func act = () => test.RunAsync(); + + // Assert + await act.ShouldNotThrowAsync(); + } +} \ No newline at end of file diff --git a/src/Monify.Tests/SequenceEqualityComparerGeneratorTests/WhenExecuted.cs b/src/Monify.Tests/SequenceEqualityComparerGeneratorTests/WhenExecuted.cs new file mode 100644 index 0000000..8ef507f --- /dev/null +++ b/src/Monify.Tests/SequenceEqualityComparerGeneratorTests/WhenExecuted.cs @@ -0,0 +1,31 @@ +namespace Monify.SequenceEqualityComparerGeneratorTests; + +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.Testing; +using Monify.Snippets.Declarations; + +public sealed class WhenExecuted +{ + private static readonly Type[] _generators = + [ + typeof(HashCodeGenerator), + typeof(SequenceEqualityComparerGenerator), + ]; + + [Theory] + [Frameworks] + public async Task GivenAnAssemblyThenTheClassIsGenerated(ReferenceAssemblies assemblies, LanguageVersion language) + { + // Arrange + var test = new GeneratorTest(assemblies, language, generators: _generators); + + Internal.HashCode.IsExpectedIn(test.TestState); + Internal.SequenceEqualityComparer.IsExpectedIn(test.TestState); + + // Act + Func act = () => test.RunAsync(); + + // Assert + await act.ShouldNotThrowAsync(); + } +} \ 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 07de484..0b3d504 100644 --- a/src/Monify.Tests/Snippets/Declarations/Classes/Nested.InClass.Expected.cs +++ b/src/Monify.Tests/Snippets/Declarations/Classes/Nested.InClass.Expected.cs @@ -307,7 +307,7 @@ sealed partial class Inner { public override int GetHashCode() { - return _value.GetHashCode(); + return global::Monify.Internal.HashCode.Combine(_value); } } } @@ -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 70ad150..25320d2 100644 --- a/src/Monify.Tests/Snippets/Declarations/Classes/Nested.InInterface.Expected.cs +++ b/src/Monify.Tests/Snippets/Declarations/Classes/Nested.InInterface.Expected.cs @@ -307,7 +307,7 @@ sealed partial class Inner { public override int GetHashCode() { - return _value.GetHashCode(); + return global::Monify.Internal.HashCode.Combine(_value); } } } @@ -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 a2be0c9..088b248 100644 --- a/src/Monify.Tests/Snippets/Declarations/Classes/Nested.InRecord.Expected.cs +++ b/src/Monify.Tests/Snippets/Declarations/Classes/Nested.InRecord.Expected.cs @@ -307,7 +307,7 @@ sealed partial class Inner { public override int GetHashCode() { - return _value.GetHashCode(); + return global::Monify.Internal.HashCode.Combine(_value); } } } @@ -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 ceee215..d0806ca 100644 --- a/src/Monify.Tests/Snippets/Declarations/Classes/Nested.InRecordStruct.Expected.cs +++ b/src/Monify.Tests/Snippets/Declarations/Classes/Nested.InRecordStruct.Expected.cs @@ -307,7 +307,7 @@ sealed partial class Inner { public override int GetHashCode() { - return _value.GetHashCode(); + return global::Monify.Internal.HashCode.Combine(_value); } } } @@ -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 016e6f8..e757d39 100644 --- a/src/Monify.Tests/Snippets/Declarations/Classes/Nested.InStruct.Expected.cs +++ b/src/Monify.Tests/Snippets/Declarations/Classes/Nested.InStruct.Expected.cs @@ -307,7 +307,7 @@ sealed partial class Inner { public override int GetHashCode() { - return _value.GetHashCode(); + return global::Monify.Internal.HashCode.Combine(_value); } } } @@ -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 4f4a074..69c4406 100644 --- a/src/Monify.Tests/Snippets/Declarations/Classes/Simple.Expected.cs +++ b/src/Monify.Tests/Snippets/Declarations/Classes/Simple.Expected.cs @@ -276,7 +276,7 @@ sealed partial class Simple { public override int GetHashCode() { - return _value.GetHashCode(); + return global::Monify.Internal.HashCode.Combine(_value); } } @@ -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/Internal.cs b/src/Monify.Tests/Snippets/Declarations/Internal.cs new file mode 100644 index 0000000..fddd13e --- /dev/null +++ b/src/Monify.Tests/Snippets/Declarations/Internal.cs @@ -0,0 +1,16 @@ +namespace Monify.Snippets.Declarations; + +public static class Internal +{ + public static readonly Generated HashCode = new( + HashCodeGenerator.Content, + Extensions.None, + "Monify.Internal.HashCode", + Generator: typeof(HashCodeGenerator)); + + public static readonly Generated SequenceEqualityComparer = new( + SequenceEqualityComparerGenerator.Content, + Extensions.None, + "Monify.Internal.SequenceEqualityComparer", + Generator: typeof(SequenceEqualityComparerGenerator)); +} \ No newline at end of file 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 022426a..60aa21d 100644 --- a/src/Monify.Tests/Snippets/Declarations/Records/Nested.InClass.Expected.cs +++ b/src/Monify.Tests/Snippets/Declarations/Records/Nested.InClass.Expected.cs @@ -307,7 +307,7 @@ sealed partial record Inner { public override int GetHashCode() { - return _value.GetHashCode(); + return global::Monify.Internal.HashCode.Combine(_value); } } } @@ -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 0f48a8d..e6ec599 100644 --- a/src/Monify.Tests/Snippets/Declarations/Records/Nested.InInterface.Expected.cs +++ b/src/Monify.Tests/Snippets/Declarations/Records/Nested.InInterface.Expected.cs @@ -307,7 +307,7 @@ sealed partial record Inner { public override int GetHashCode() { - return _value.GetHashCode(); + return global::Monify.Internal.HashCode.Combine(_value); } } } @@ -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 f1144f7..d462494 100644 --- a/src/Monify.Tests/Snippets/Declarations/Records/Nested.InRecord.Expected.cs +++ b/src/Monify.Tests/Snippets/Declarations/Records/Nested.InRecord.Expected.cs @@ -307,7 +307,7 @@ sealed partial record Inner { public override int GetHashCode() { - return _value.GetHashCode(); + return global::Monify.Internal.HashCode.Combine(_value); } } } @@ -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 d6660b2..355fbef 100644 --- a/src/Monify.Tests/Snippets/Declarations/Records/Nested.InRecordStruct.Expected.cs +++ b/src/Monify.Tests/Snippets/Declarations/Records/Nested.InRecordStruct.Expected.cs @@ -307,7 +307,7 @@ sealed partial record Inner { public override int GetHashCode() { - return _value.GetHashCode(); + return global::Monify.Internal.HashCode.Combine(_value); } } } @@ -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 1319a21..4ccce13 100644 --- a/src/Monify.Tests/Snippets/Declarations/Records/Nested.InStruct.Expected.cs +++ b/src/Monify.Tests/Snippets/Declarations/Records/Nested.InStruct.Expected.cs @@ -307,7 +307,7 @@ sealed partial record Inner { public override int GetHashCode() { - return _value.GetHashCode(); + return global::Monify.Internal.HashCode.Combine(_value); } } } @@ -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 1bf0f5b..5e80f4c 100644 --- a/src/Monify.Tests/Snippets/Declarations/Structs/Nested.InClass.Expected.cs +++ b/src/Monify.Tests/Snippets/Declarations/Structs/Nested.InClass.Expected.cs @@ -307,7 +307,7 @@ readonly partial struct Inner { public override int GetHashCode() { - return _value.GetHashCode(); + return global::Monify.Internal.HashCode.Combine(_value); } } } @@ -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 3bcaaf3..ac76da1 100644 --- a/src/Monify.Tests/Snippets/Declarations/Structs/Nested.InInterface.Expected.cs +++ b/src/Monify.Tests/Snippets/Declarations/Structs/Nested.InInterface.Expected.cs @@ -307,7 +307,7 @@ readonly partial struct Inner { public override int GetHashCode() { - return _value.GetHashCode(); + return global::Monify.Internal.HashCode.Combine(_value); } } } @@ -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 eb90491..3f3917c 100644 --- a/src/Monify.Tests/Snippets/Declarations/Structs/Nested.InRecord.Expected.cs +++ b/src/Monify.Tests/Snippets/Declarations/Structs/Nested.InRecord.Expected.cs @@ -307,7 +307,7 @@ readonly partial struct Inner { public override int GetHashCode() { - return _value.GetHashCode(); + return global::Monify.Internal.HashCode.Combine(_value); } } } @@ -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 b9caf75..1c9b501 100644 --- a/src/Monify.Tests/Snippets/Declarations/Structs/Nested.InRecordStruct.Expected.cs +++ b/src/Monify.Tests/Snippets/Declarations/Structs/Nested.InRecordStruct.Expected.cs @@ -307,7 +307,7 @@ readonly partial struct Inner { public override int GetHashCode() { - return _value.GetHashCode(); + return global::Monify.Internal.HashCode.Combine(_value); } } } @@ -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 05b396e..b943108 100644 --- a/src/Monify.Tests/Snippets/Declarations/Structs/Nested.InStruct.Expected.cs +++ b/src/Monify.Tests/Snippets/Declarations/Structs/Nested.InStruct.Expected.cs @@ -307,7 +307,7 @@ readonly partial struct Inner { public override int GetHashCode() { - return _value.GetHashCode(); + return global::Monify.Internal.HashCode.Combine(_value); } } } @@ -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 9893c43..5432154 100644 --- a/src/Monify.Tests/Snippets/Declarations/Structs/Simple.Expected.cs +++ b/src/Monify.Tests/Snippets/Declarations/Structs/Simple.Expected.cs @@ -276,7 +276,7 @@ partial struct Simple { public override int GetHashCode() { - return _value.GetHashCode(); + return global::Monify.Internal.HashCode.Combine(_value); } } @@ -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.Tests/TypeGeneratorTests/WhenExecuted.cs b/src/Monify.Tests/TypeGeneratorTests/WhenExecuted.cs index 51f7d6e..46053f6 100644 --- a/src/Monify.Tests/TypeGeneratorTests/WhenExecuted.cs +++ b/src/Monify.Tests/TypeGeneratorTests/WhenExecuted.cs @@ -7,9 +7,11 @@ public sealed class WhenExecuted { - private static readonly Type[] generators = + private static readonly Type[] _generators = [ typeof(AttributeGenerator), + typeof(HashCodeGenerator), + typeof(SequenceEqualityComparerGenerator), typeof(TypeGenerator), ]; @@ -18,10 +20,12 @@ public sealed class WhenExecuted public async Task GivenATypeTheExpectedSourceIsGenerated(ReferenceAssemblies assembly, Expectations expectations, LanguageVersion language) { // Arrange - var test = new GeneratorTest(assembly, language, generators); + var test = new GeneratorTest(assembly, language, _generators); Attributes.IsExpectedIn(test.TestState, language); expectations.IsDeclaredIn(test.TestState); + Internal.HashCode.IsExpectedIn(test.TestState); + Internal.SequenceEqualityComparer.IsExpectedIn(test.TestState); // Act Func act = () => test.RunAsync(); diff --git a/src/Monify/AttributeAnalyzer.cs b/src/Monify/AttributeAnalyzer.cs index 9530e34..498dc4d 100644 --- a/src/Monify/AttributeAnalyzer.cs +++ b/src/Monify/AttributeAnalyzer.cs @@ -216,7 +216,7 @@ private static bool IsViolatingSelfReferenceRule( private static bool IsViolatingCapturesStateRule(INamedTypeSymbol? symbol, ITypeSymbol? value) { - return symbol is null || value is null || !symbol.IsStateless(value, out _); + return symbol is null || !symbol.IsStateless(value, out _); } private static bool IsViolatingCompatibleTargetTypeRule(AttributeSyntax attribute, out TypeDeclarationSyntax? type) diff --git a/src/Monify/HashCodeGenerator.cs b/src/Monify/HashCodeGenerator.cs new file mode 100644 index 0000000..5a17af4 --- /dev/null +++ b/src/Monify/HashCodeGenerator.cs @@ -0,0 +1,80 @@ +namespace Monify; + +using Microsoft.CodeAnalysis; + +/// +/// Generates an internal HashCode static class that is used to support hash code generation. +/// +[Generator(LanguageNames.CSharp)] +public sealed class HashCodeGenerator + : IIncrementalGenerator +{ + /// + /// The source code that will be output by the generator. + /// + public const string Content = $$""" + namespace Monify.Internal + { + using System; + using System.Collections; + + internal static class HashCode + { + private const int HashSeed = 0x1505; + private const int HashPrime = -1521134295; + + public static int Combine(params object[] values) + { + int hash = HashSeed; + + foreach (object value in values) + { + if (value is IEnumerable && !(value is string)) + { + IEnumerable enumerable = (IEnumerable)value; + + foreach (object element in enumerable) + { + hash = PerformCombine(hash, element); + } + } + else + { + hash = PerformCombine(hash, value); + } + } + + return hash; + } + + private static int PerformCombine(int hash, object value) + { + int other = GetHashCode(value); + + unchecked + { + return (other * HashPrime) + hash; + } + } + + private static int GetHashCode(object value) + { + int code = 0; + + if (value != null) + { + code = value.GetHashCode(); + } + + return code; + } + } + } + """; + + /// + public void Initialize(IncrementalGeneratorInitializationContext context) + { + context.RegisterPostInitializationOutput(context => context.AddSource("Monify.Internal.HashCode.g.cs", Content)); + } +} \ No newline at end of file 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.IsStateless.cs b/src/Monify/Semantics/INamedTypeSymbolExtensions.IsStateless.cs index 4b484aa..5b1f569 100644 --- a/src/Monify/Semantics/INamedTypeSymbolExtensions.IsStateless.cs +++ b/src/Monify/Semantics/INamedTypeSymbolExtensions.IsStateless.cs @@ -29,7 +29,7 @@ internal static partial class INamedTypeSymbolExtensions /// /// If the class holds state, then it points to a design issue, as the class is intended to represent a single state. /// - public static bool IsStateless(this INamedTypeSymbol subject, ITypeSymbol value, out bool hasFieldForEncapsulatedValue) + public static bool IsStateless(this INamedTypeSymbol subject, ITypeSymbol? value, out bool hasFieldForEncapsulatedValue) { IFieldSymbol[] fields = subject .GetMembers() @@ -44,7 +44,7 @@ public static bool IsStateless(this INamedTypeSymbol subject, ITypeSymbol value, return true; } - if (fields.Length == ExpectedFieldsWhenFieldIsAlreadyDefined) + if (value is not null && fields.Length == ExpectedFieldsWhenFieldIsAlreadyDefined) { IFieldSymbol field = fields[OffsetForFieldWhenAlreadyDefined]; 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/SequenceEqualityComparerGenerator.cs b/src/Monify/SequenceEqualityComparerGenerator.cs new file mode 100644 index 0000000..e4279dd --- /dev/null +++ b/src/Monify/SequenceEqualityComparerGenerator.cs @@ -0,0 +1,71 @@ +namespace Monify; + +using Microsoft.CodeAnalysis; + +/// +/// Generates an internal SequenceEqualityComparer static class that is used to support enumerable enumerable checks. +/// +[Generator(LanguageNames.CSharp)] +public sealed class SequenceEqualityComparerGenerator + : IIncrementalGenerator +{ + /// + /// The source code that will be output by the generator. + /// + public const string Content = $$""" + namespace Monify.Internal + { + using System; + using System.Collections; + + internal sealed class SequenceEqualityComparer + { + public static readonly SequenceEqualityComparer Default = new SequenceEqualityComparer(); + + public bool Equals(IEnumerable left, IEnumerable right) + { + if (ReferenceEquals(left, right)) + { + return true; + } + + if (ReferenceEquals(left, null) || ReferenceEquals(null, right)) + { + return false; + } + + return Equals(left.GetEnumerator(), right.GetEnumerator()); + } + + public int GetHashCode(IEnumerable enumerable) + { + return HashCode.Combine(enumerable); + } + + private static bool Equals(IEnumerator left, IEnumerator right) + { + while (left.MoveNext()) + { + if (!right.MoveNext()) + { + return false; + } + + if (!Equals(left.Current, right.Current)) + { + return false; + } + } + + return !right.MoveNext(); + } + } + } + """; + + /// + public void Initialize(IncrementalGeneratorInitializationContext context) + { + context.RegisterPostInitializationOutput(context => context.AddSource("Monify.Internal.SequenceEqualityComparer.g.cs", Content)); + } +} \ No newline at end of file diff --git a/src/Monify/Strategies/GetHashCodeStrategy.cs b/src/Monify/Strategies/GetHashCodeStrategy.cs index ad4b53e..2126114 100644 --- a/src/Monify/Strategies/GetHashCodeStrategy.cs +++ b/src/Monify/Strategies/GetHashCodeStrategy.cs @@ -21,7 +21,7 @@ public IEnumerable Generate(Subject subject) { public override int GetHashCode() { - return {{FieldStrategy.Name}}.GetHashCode(); + return global::Monify.Internal.HashCode.Combine({{FieldStrategy.Name}}); } } """; 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;