コード例 #1
0
        public void AndAlso_NotConcatingNull()
        {
            var records = new[]
            {
                new MyClass {
                    Id = "1", Value = 1, Name = "name-1"
                },
                new MyClass {
                    Id = "2", Value = 2
                },
                new MyClass {
                    Id = "3", Value = 3, Name = "name-3"
                },
            };
            var func1 = new Func <MyClass, bool>(x => x.Id != null);
            var func3 = new Func <MyClass, bool>(x => x.Name != null);
            var f     = FuncExtensions.AndAlso(func1, func3);

            var res = records.Where(f);

            res.Count().ShouldBe(2);
            res.ShouldAllBe(x => new[] { records[0], records[2] }.Contains(x));
        }
コード例 #2
0
        public void AndAlso_MultipleResult()
        {
            var records = new[]
            {
                new MyClass {
                    Id = "1", Value = 1, Name = "name-1"
                },
                new MyClass {
                    Id = "2", Value = 2, Name = "name-2"
                },
                new MyClass {
                    Id = "3", Value = 3, Name = "name-3"
                },
            };
            var func1 = new Func <MyClass, bool>(x => x.Id != null);
            var func2 = new Func <MyClass, bool>(x => x.Value > 0);
            var func3 = new Func <MyClass, bool>(x => x.Name != null);
            var f     = FuncExtensions.AndAlso(func1, func2, func3);
            var res   = records.Where(f);

            res.Count().ShouldBe(records.Length);
            res.ShouldAllBe(x => records.Contains(x));
        }