public static Outcome <T> TranslateToOutcome <T>( this PossibleBe <T> possibleBe, string errorMessageOnTranslation) { return(possibleBe.HasNoValue ? Outcome.Failed <T>(errorMessageOnTranslation) : Outcome.Successfully(possibleBe.Value)); }
public void TranslatePossibleBe_T_ToOutcome_T_ShouldBeResultFailure() { PossibleBe <CustomerTest> possibleBeCustomer = null; Outcome <CustomerTest> outcomeCustomer = possibleBeCustomer.TranslateToOutcome("error"); outcomeCustomer.Failure .Should() .BeTrue(); outcomeCustomer.Value .Should() .BeNull(); outcomeCustomer.ErrorMessages .Should() .HaveCount(1); }
public void ValidateThat_IsCanAccess_Value_InPossibleBe() { // Arrange var expectedInstance = new object(); // Act PossibleBe <object> possibleBe = expectedInstance; // Assert possibleBe.HasValue .Should() .BeTrue(); possibleBe.HasNoValue .Should() .BeFalse(); possibleBe.Value .Should() .Be(expectedInstance); }
private Outcome <decimal> Test3(PossibleBe <int> number) { return(Outcome.Failed <decimal>("Error in Test 2")); }
private Outcome <decimal> Test2(PossibleBe <int> number) { return(number.HasNoValue ? Outcome.Failed <decimal>("There was an error in Test 2") : Outcome.Successfully <decimal>(10.00m)); }
private Outcome <int> Test(PossibleBe <CustomerTest> customer) { return(customer.HasNoValue ? Outcome.Failed <int>("There was an error in Test") : Outcome.Successfully <int>(10)); }