Beispiel #1
0
 public static Outcome <T> TranslateToOutcome <T>(
     this PossibleBe <T> possibleBe,
     string errorMessageOnTranslation)
 {
     return(possibleBe.HasNoValue ?
            Outcome.Failed <T>(errorMessageOnTranslation) :
            Outcome.Successfully(possibleBe.Value));
 }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
 private Outcome <decimal> Test3(PossibleBe <int> number)
 {
     return(Outcome.Failed <decimal>("Error in Test 2"));
 }
Beispiel #5
0
 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));
 }
Beispiel #6
0
 private Outcome <int> Test(PossibleBe <CustomerTest> customer)
 {
     return(customer.HasNoValue ?
            Outcome.Failed <int>("There was an error in Test") :
            Outcome.Successfully <int>(10));
 }