public void Try_ShouldReturnAnExceptionalPopulatedWithAnExceptionOrACorrectValueIfNoneOcurred() { // Note: new List<int>()[4] will always throw System.ArgumentOutOfRangeException //Act var result = FunctionalErrorHandling.Try(() => new List <int>()[4]); //Assert Assert.True(result.Exception); }
public void Safely_ShouldReturnAnEitherPopulatedWithALeftValueIfAnExceptionOcurredOrARightValueOtherwise() { // Note: new List<int>()[4] will always throw System.ArgumentOutOfRangeException //Act var result = FunctionalErrorHandling.Safely(() => new List <int>()[4], e => "An exception ocurred"); //Assert Assert.Equal(expected: Left("An exception ocurred"), actual: result); }