コード例 #1
0
 public void HandleShouldNotCallIfSecondWhenEitherHasAFirstValue()
 {
     var called = false;
     var target = new Either<int, string>(1);
     target.Handle(_ => true, _ => called = true);
     Assert.That(!called);
 }
コード例 #2
0
 public void HandleShouldPassThroughFirstValueToIfFirst()
 {
     const uint value = 0x6a09e667;
     var target = new Either<uint, string>(value);
     target.Handle(f =>
     {
         Assert.That(f, Is.EqualTo(value));
         return true;
     },
                                 _ => true);
 }
コード例 #3
0
 public void HandleShouldPassThroughIfSecondResult()
 {
     var target = new Either<uint, string>("1");
     const decimal expected = 5m;
     Assert.That(target.Handle(_ => 0m, _ => expected), Is.EqualTo(expected));
 }
コード例 #4
0
 public void HandleShouldPassThroughIfFirstResult()
 {
     var target = new Either<uint, string>(0x6a09e667);
     const decimal expected = 5m;
     Assert.That(target.Handle(_ => expected, _ => 0m), Is.EqualTo(expected));
 }
コード例 #5
0
 public void HandleShouldPassThroughSecondValueToIfSecond()
 {
     const string value = "6a09e667";
     var target = new Either<uint, string>(value);
     target.Handle(_ => true,
                                 s =>
                                 {
                                     Assert.That(s, Is.EqualTo(value));
                                     return true;
                                 });
 }