예제 #1
0
        private static bool _Run()
        {
            bool result = true;

            result = result.And(F.equ_string("test", F.add_string("", "test"))); // p + p
            result = result.And(F.equ_string("test", F.add_string("t", "est"))); // n + n
            result = result.And(F.equ_string("test", F.add_string("te", "st"))); // p + n
            result = result.And(F.equ_string("test", F.add_string("tes", "t"))); // n + p
            result = result.And(F.equ_string("test", F.add_string("test", ""))); // 0 + p
            return(result);
        }
예제 #2
0
        private static bool _Run()
        {
            bool result = true;
            bool _true  = true;
            bool _false = false;

            result = result && (true == _true.And(true));
            result = result && (false == _true.And(false));
            result = result && (false == _false.And(true));
            result = result && (false == _false.And(false));
            return(result);
        }
        public void And_Should_Return_False_When_One_Value_Is_False(bool bValueA, bool bValueB, bool bExpectedResult)
        {
            // Arrange

            // Act & Assert
            bValueA.And(bValueB).Should().Be(bExpectedResult);
        }
예제 #4
0
        private static bool _Run()
        {
            bool        result = true;
            Func <bool> fn     = F.always(false);

            result = result.And(F.equ_bool(false, fn.Invoke()));
            return(result);
        }
예제 #5
0
        private static bool _Run()
        {
            bool        result = true;
            Func <bool> b      = F.alwaysFalse.Invoke();

            result = result.And(F.equ_bool(false, b.Invoke()));
            return(result);
        }
예제 #6
0
        public void op_And_bool_bool(bool expected,
                                     bool value,
                                     bool comparand)
        {
            var actual = value.And(comparand);

            Assert.Equal(expected, actual);
        }
예제 #7
0
        public Property Creating_Person_Only_Works_If_Every_Prop_Is_Valid(
            Result <NonEmptyString, NonEmptyString> nameResult,
            Result <PositiveInt, NonEmptyString> ageResult,
            Result <NonEmptySeq <string>, NonEmptyString> addressesResult)
        {
            var personResult = Result
                               .Ok(Person.Ctor().Curry())
                               .CastError <NonEmptyString>()
                               .Apply(nameResult)
                               .Apply(ageResult)
                               .Apply(addressesResult);

            bool allGood = personResult.IsOk == (nameResult.IsOk && ageResult.IsOk && addressesResult.IsOk);
            bool allFail = personResult.IsError == (nameResult.IsError || ageResult.IsError || addressesResult.IsError);

            return(allGood.And(right: allFail));
        }
예제 #8
0
        public static void Test1()
        {
            IEnumerable <int> xs = Enumerable.Range(1, 10);

            //fold
            int a = xs.Aggregate((acc, x) => acc + x);

            //foldBack
            int b = xs.Reverse().Aggregate((acc, x) => acc + x);

            IEnumerable <bool> ys = new bool[] { true, false, true, false };

            bool c = ys.Aggregate((acc, y) => acc && y); //non-short-circuit
            bool d = ys.And();

            Console.WriteLine(a);
            Console.WriteLine(b);
            Console.WriteLine(c);
            Console.WriteLine(d);
        }
예제 #9
0
        private static bool _Run()
        {
            bool result  = true;
            int  current = 0;
            int  last    = 0;
            IStatelessChain <int> statelessChain = StatelessChain <int> .Create((x) => x < 3, F.DoNothing <int>);

            while (null != statelessChain)
            {
                last = current;
                current++;
                statelessChain = statelessChain.Run(current);
            }
            result = result.And(F.equ_int(last, 2));
            int count = 0;
            IStatefulChain <int> statefulChain = StatefulChain <int> .Create((x) => x < 3, (y) => { count++; }, (v) => v + 1, 0);

            while (null != statefulChain)
            {
                statefulChain = statefulChain.Run();
            }
            result = result && (count == 3);
            return(result);
        }
예제 #10
0
 public static bool Multiply(this bool x, bool y) => x.And(y);
예제 #11
0
        public void AndFalseTest()
        {
            var xs = new bool[] { true, false };

            Assert.That(xs.And(), Is.False);
        }
예제 #12
0
        public void AndTrueTest()
        {
            var xs = new bool[] { true };

            Assert.That(xs.And(), Is.True);
        }
        void And_applies_logical_AND_operator_on_arguments(bool arg1, bool arg2, bool expected)
        {
            var actual = arg1.And(arg2);

            actual.Should().Be(expected);
        }
예제 #14
0
 public void And_ShouldRepresentCorrectTruthTable(bool a, bool b, bool expected) =>
 Assert.Equal(expected, a.And(b));
예제 #15
0
 public void Should_Be_False_When_Both_Values_Are_Not_True_At_Same_Time(bool firstValue, bool secondValue)
 => Assert.False(firstValue.And(secondValue));