public static void CheckEitherLeft <TLeft>(EitherLeft <TLeft> either, [NotNull] TLeft expectedValue) { Assert.IsTrue(either.IsLeft); Assert.IsFalse(either.IsRight); CheckLeftEither <TLeft, int>(either, expectedValue); // Use int as fallback for right value, but it's not relevant }
public void EitherLeftSerialization() { EitherLeft <int> either = new EitherLeft <int>(42); EitherLeft <int> deserializedEither = SerializeAndDeserialize(either); CheckEitherLeft(deserializedEither, 42); }
public void LeftShouldSucceed() { // Arrange var value = "value"; // Act EitherLeft <string> left = Left <string>(value); // Assert left.ToString().Should().Be("Left(value)"); }
public void EqualsObjectShouldReturnFalseWhenFirstValueNull() { // Arrange var first = new EitherLeft <string>(null); var second = new EitherLeft <string>("value"); // Act var result = Equals(first, second); // Assert result.Should().BeFalse(); }
public void EqualsObjectShouldReturnFalseWhenDifferentTypes() { // Arrange var first = new EitherLeft <string>("1"); var second = new EitherLeft <int>(1); // Act var result = Equals(first, second); // Assert result.Should().BeFalse(); }
public void EqualsObjectShouldReturnFalseWhenSameTypeAndDifferentValues() { // Arrange var first = new EitherLeft <string>("value1"); var second = new EitherLeft <string>("value2"); // Act var result = Equals(first, second); // Assert result.Should().BeFalse(); }
public void EqualsObjectShouldReturnTrueWhenBothValueSameNotNull() { // Arrange var first = new EitherLeft <string>("value"); var second = new EitherLeft <string>("value"); // Act var result = Equals(first, second); // Assert result.Should().BeTrue(); }
public void CtorShouldSetCorrectValue() { // Arrange var value = "left"; var eitherLeft = new EitherLeft <string>(value); // Act var result = eitherLeft.Value; // Assert result.Should().Be(value); }
public void EqualsEitherLeftShouldReturnFalse() { // Arrange var first = new EitherLeft <string>("value1"); var second = new EitherLeft <string>("value2"); // Act var result = first.Equals(second); // Assert result.Should().BeFalse(); }
public void EqualsEitherLeftShouldReturnTrueWhenBothValueNull() { // Arrange var first = new EitherLeft <string>(null); var second = new EitherLeft <string>(null); // Act var result = first.Equals(second); // Assert result.Should().BeTrue(); }
public void ToStringShouldProvideExpectedRepresentation() { // Arrange var value = "left"; var expectedResult = $"Left({value})"; var eitherLeft = new EitherLeft <string>(value); // Act var result = eitherLeft.ToString(); // Assert result.Should().Be(expectedResult); }
public void ImplicitOperatorOverloadingShouldSucceedWithEitherLeft() { // Arrange var value = "value"; var eitherLeft = new EitherLeft <string>(value); // Act Either <string, int> either = eitherLeft; var result = either.ToString(); // Assert result.Should().Be("Left(value)"); }