Beispiel #1
0
        public static void Map_right_either_returns_either_with_new_type_and_value()
        {
            const int mappedValue = 42;

            TestMonads.Right("Test").Map(_ => mappedValue)
            .Match(Assert.Fail, i => Assert.AreEqual(mappedValue, i));
        }
Beispiel #2
0
        public static void Match_right_either_returns_right_value()
        {
            const string value  = "Test";
            var          result = TestMonads.Right(value).Match(_ => "Left", s => s);

            Assert.AreEqual(value, result);
        }
Beispiel #3
0
        public static void BindLeft_right_either_to_method_returns_same_right_either()
        {
            const string value = "Test";

            TestMonads.Right(value).BindLeft(_ => 42.Left < int, string > ())
            .Match(_ => Assert.Fail(), s => Assert.AreEqual(value, s));
        }
Beispiel #4
0
        public static void Bind_right_either_to_method_returns_either_with_new_type_and_value()
        {
            const int bindValue = 42;

            TestMonads.Right("Test").Bind(_ => bindValue.Right <string, int>())
            .Match(Assert.Fail, i => Assert.AreEqual(bindValue, i));
        }
Beispiel #5
0
        public static void MapLeft_right_either_returns_same_right_either()
        {
            const string value = "Test";

            TestMonads.Right(value).MapLeft(_ => 42).Match(_ => Assert.Fail(), s => Assert.AreEqual(value, s));
        }
Beispiel #6
0
        public static void Right_creates_either_with_right_value()
        {
            const string input = "Test";

            TestMonads.Right(input).Match(Assert.Fail, s => Assert.AreEqual(input, s));
        }
Beispiel #7
0
 public static void Map_right_either_with_null_mapping_throws_exception() =>
 Assert.Throws <ArgumentNullException>(() => TestMonads.Right("Test").Map((Func <string, string>)null));
Beispiel #8
0
        public static void Right_to_maybe_returns_maybe_with_value()
        {
            const string value = "Test";

            TestMonads.Right(value).ToMaybe().Match(s => Assert.AreEqual(value, s), Assert.Fail);
        }