예제 #1
0
        public void SecondFunctorLawHoldsForSelectLeft(IEither <string, int> e)
        {
            bool f(int x) => x % 2 == 0;
            int g(string s) => s.Length;

            Assert.Equal(
                e.SelectLeft(x => f(g(x))),
                e.SelectLeft(g).SelectLeft(f));
        }
예제 #2
0
        public void ConsistencyLawHolds(IEither <string, int> e)
        {
            bool f(string s) => string.IsNullOrWhiteSpace(s);
            DateTime g(int i) => new DateTime(i);

            Assert.Equal(e.SelectBoth(f, g), e.SelectRight(g).SelectLeft(f));
            Assert.Equal(
                e.SelectLeft(f).SelectRight(g),
                e.SelectRight(g).SelectLeft(f));
        }
예제 #3
0
 public void SelectLeftObeysFirstFunctorLaw(IEither <string, int> e)
 {
     Assert.Equal(e, e.SelectLeft(Id));
 }