public void It_can_match_complex_types() { var given = new WhenClauseTester { TestValue = 100 }; var seq = Outcome.Of(given) .Switch( c => c.When(new WhenClauseTester { TestValue = 10 }, x => x .Map(s => 10) .Catch(f => - 100)), c => c.When(new WhenClauseTester { TestValue = 100 }, x => x .Map(s => 100) .Catch(f => - 100)), c => c.Otherwise(x => x .Map(s => 50) .Catch(f => - 50)) ); seq.IsSuccessful.Should().BeTrue(); seq.ResultOrDefault().Should().Be(100); }
public async Task It_can_match_complex_types_Async() { var given = new WhenClauseTester { TestValue = 100 }; var seq = await Outcome.Of(given).ForAsync() .Switch( c => c.When(new WhenClauseTester { TestValue = 10 }, x => x .Map(s => Task.FromResult(100)) .Catch(f => - 100)), c => c.When(new WhenClauseTester { TestValue = 100 }, x => x .Map(s => Task.FromResult(100)) .Catch(f => - 100)), c => c.Otherwise(x => x .Map(s => Task.FromResult(50)) .Catch(f => - 50)) ); seq.IsSuccessful.Should().BeTrue(); seq.ResultOrDefault().Should().Be(100); }