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..884a359 --- /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 SampleValue = 101; + private const int DifferentValue = 202; + + [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..848eb15 --- /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 SampleValue = 14; + private const int DifferentValue = 17; + + [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..bfa1059 --- /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 SampleValue = 36; + private const int DifferentValue = 12; + + [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..5200bcc --- /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 SampleValue = 51; + private const int DifferentValue = 5; + + [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..42906e9 --- /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("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..59868ec --- /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 SampleValue = 7; + private const int DifferentValue = 9; + + [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..7d17868 --- /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 SampleValue = 63; + private const int DifferentValue = 64; + + [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..6a42a34 --- /dev/null +++ b/src/Monify.Console.Tests/Classes/Simple/SimpleForIntTests/WhenToStringIsCalled.cs @@ -0,0 +1,19 @@ +namespace Monify.Console.Classes.Simple.SimpleForIntTests; + +public static class WhenToStringIsCalled +{ + private const int SampleValue = 91; + + [Fact] + public static void GivenValueThenThrowFormatException() + { + // Arrange + SimpleForInt subject = new(SampleValue); + + // Act + Action act = () => subject.ToString(); + + // Assert + _ = Should.Throw(act); + } +} \ No newline at end of file