Example #1
0
 public void TestDefaultIfLeft()
 {
     {
         var instance = new Either <string, int>(1);
         var result   = instance.DefaultIfLeft();
         result.AssertRight(1);
     }
     {
         var instance = new Either <string, int>("test");
         var result   = instance.DefaultIfLeft();
         result.AssertRight(default(int));
     }
     {
         var instance = default(Either <string, int>);
         Assert.Throws <ArgumentNullException>(() => instance.DefaultIfLeft());
     }
     {
         var instance = new Either <int, string>(1);
         var result   = instance.DefaultIfLeft("test");
         result.AssertRight("test");
     }
     {
         var instance = new Either <int, string>("test");
         var result   = instance.DefaultIfLeft("testing");
         result.AssertRight("test");
     }
     {
         var instance = default(Either <int, string>);
         Assert.Throws <ArgumentNullException>(() => instance.DefaultIfLeft("test"));
         Assert.Throws <ArgumentNullException>(() => instance.DefaultIfLeft(null));
         Assert.Throws <ArgumentNullException>(() => new Either <int, string>("test").DefaultIfLeft(null));
     }
 }