Ejemplo n.º 1
0
        public void LambdaContextObject_ElseIf_Test()
        {
            var lambda = new LambdaContextObject <MockPerson>(person);

            bool thenResult  = false;
            bool elseResult  = false;
            bool elseResult1 = false;
            bool elseResult2 = false;
            bool elseResult3 = false;

            lambda.If(o => o.Name == TestOwner.Junil_Um)
            .AndIf(o => o.Age == 2)
            .Then(o => thenResult = true)
            .ElseIf(o => o.Age == 3, o => { Console.WriteLine("ELSEIF1"); elseResult1 = true; })
            .ElseIf(o => o.Age == 1, o => { Console.WriteLine("ELSEIF2"); elseResult2 = true; })
            .ElseIf(o => o.Age == 4, o => { Console.WriteLine("ELSEIF3"); elseResult3 = true; })
            .Else(o => { Console.WriteLine("ELSE"); elseResult = true; })
            .Invoke();

            Assert.IsFalse(thenResult);
            Assert.IsFalse(elseResult1);
            Assert.IsTrue(elseResult2);
            Assert.IsFalse(elseResult3);
            Assert.IsFalse(elseResult);
        }
Ejemplo n.º 2
0
        public void LambdaContextObject_If_Test()
        {
            var lambda = new LambdaContextObject <MockPerson>(person);

            // 기본 조건 테스트
            Assert.IsTrue(lambda.If(o => o.Name == TestOwner.Junil_Um).Value);
            Assert.IsFalse(lambda.If(o => o.Name == TestOwner.Junil_Um + "A").Value);


            // And 조건 테스트
            Assert.IsTrue(lambda.If(o => o.Name == TestOwner.Junil_Um)
                          .AndIf(o => o.Age == 1).Value);
            Assert.IsFalse(lambda.If(o => o.Name == TestOwner.Junil_Um)
                           .AndIf(o => o.Age == 2).Value);

            // Or 조건 테스트
            Assert.IsTrue(lambda.If(o => o.Name == TestOwner.Junil_Um)
                          .OrIf(o => o.Age == 2).Value);
        }
Ejemplo n.º 3
0
        public void LambdaContextObject_Then_Test()
        {
            var lambda = new LambdaContextObject <MockPerson>(person);

            bool thenResult = false;

            lambda.If(o => o.Name == TestOwner.Junil_Um)
            .AndIf(o => o.Age == 1)
            .Then(o => thenResult = true)
            .Invoke();

            Assert.IsTrue(thenResult);
        }