public void TestEmptListThrowsExceptionOk()
        {
            using (var env = new MethodEnvironment(classEnv))
            {
                //SETUP             

                //ATTEMPT
                Assert.Throws<ArgumentException>( () =>  env.CompareAndLogList(new String[] { }, new String[] {}));

                //VERIFY
            }
        }
        public void TestNoSupportedListResultsWrongOk()
        {
            using (var env = new MethodEnvironment(classEnv))
            {
                //SETUP

                //ATTEMPT
                Assert.Throws<AssertionException>(() => env.CompareAndLogList(new String[] { "fred" }, new String[] { }));

                //VERIFY
                classEnv.GetLastMethodLog().State.ShouldEqual(LogStates.NotSupported);
            }
        }
        public void TestSupportedListOk()
        {
            using (var env = new MethodEnvironment(classEnv))
            {
                //SETUP             

                //ATTEMPT
                env.CompareAndLogList(new String[] { "fred" }, new String[] { "fred" });

                //VERIFY
                classEnv.GetLastMethodLog().State.ShouldEqual(LogStates.Supported);
            }
        }
        public async Task TestIntEqualsConstant()
        {
            using (var env = new MethodEnvironment(classEnv))
            {
                //SETUP
                var linq = await env.Db.EfParents.Select(x => x.ParentInt == 123).ToListAsync();

                //ATTEMPT
                env.AboutToUseDelegateDecompiler();
                var dd = await env.Db.EfParents.Select(x => x.IntEqualsConstant).DecompileAsync().ToListAsync();

                //VERIFY
                env.CompareAndLogList(linq, dd);
            }
        }
        public async Task TestBoolEqualsStaticVariableToArrayAsync()
        {
            using (var env = new MethodEnvironment(classEnv))
            {
                //SETUP
                var linq = await env.Db.EfParents.Select(x => x.ParentBool == staticBool).ToListAsync();

                //ATTEMPT
                env.AboutToUseDelegateDecompiler();
                var dd = await env.Db.EfParents.Select(x => x.BoolEqualsStaticVariable).DecompileAsync().ToListAsync();

                //VERIFY
                env.CompareAndLogList(linq, dd);
            }
        }
示例#6
0
        public void TestWhereBoolEqualsStaticVariable()
        {
            using (var env = new MethodEnvironment(classEnv))
            {
                //SETUP
                var linq = env.Db.EfParents.Where(x => x.ParentBool == staticBool).Select(x => x.EfParentId).ToList();

                //ATTEMPT
                env.AboutToUseDelegateDecompiler();
                var dd = env.Db.EfParents.Where(x => x.BoolEqualsStaticVariable).Select(x => x.EfParentId).Decompile().ToList();

                //VERIFY
                env.CompareAndLogList(linq, dd);
            }
        }
示例#7
0
        public void TestAnyChildrenWithFilter()
        {
            using (var env = new MethodEnvironment(classEnv))
            {
                //SETUP
                var linq = env.Db.EfParents.Select(x => x.Children.Any( y => y.ChildInt == 123)).ToList();

                //ATTEMPT
                env.AboutToUseDelegateDecompiler();
                var dd = env.Db.EfParents.Select(x => x.AnyChildrenWithFilter).Decompile().ToList();

                //VERIFY
                env.CompareAndLogList(linq, dd);
            }
        }
        public void TestConcatenatePersonNotHandleNull()
        {
            using (var env = new MethodEnvironment(classEnv))
            {
                //SETUP
                var linq = env.Db.EfPersons.Select(x => x.FirstName + " " + x.MiddleName + " " + x.LastName).ToList();

                //ATTEMPT
                env.AboutToUseDelegateDecompiler();
                var dd = env.Db.EfPersons.Select(x => x.FullNameNoNull).Decompile().ToList();

                //VERIFY
                env.CompareAndLogList(linq, dd);
            }
        }
        public void TestIntEqualsStringLength()
        {
            using (var env = new MethodEnvironment(classEnv))
            {
                //SETUP
                var linq = env.Db.EfParents.Select(x => x.ParentInt == x.ParentString.Length).ToList();

                //ATTEMPT
                env.AboutToUseDelegateDecompiler();
                var dd = env.Db.EfParents.Select(x => x.IntEqualsStringLength).Decompile().ToList();

                //VERIFY
                env.CompareAndLogList(linq, dd);
            }
        }
示例#10
0
        public void TestWhereIntEqualsConstant()
        {
            using (var env = new MethodEnvironment(classEnv))
            {
                //SETUP
                var linq = env.Db.EfParents.Where(x => x.ParentInt == 123).Select(x => x.EfParentId).ToList();

                //ATTEMPT
                env.AboutToUseDelegateDecompiler();
                var dd = env.Db.EfParents.Where(x => x.IntEqualsConstant).Select(x => x.EfParentId).Decompile().ToList();

                //VERIFY
                env.CompareAndLogList(linq, dd);
            }
        }
示例#11
0
        public void TestPropertyIsNull()
        {
            using (var env = new MethodEnvironment(classEnv))
            {
                //SETUP
                var linq = env.Db.EfParents.Select(x => x.ParentNullableInt == null).ToList();

                //ATTEMPT
                env.AboutToUseDelegateDecompiler();
                var dd = env.Db.EfParents.Select(x => x.ParentNullableIntIsNull).Decompile().ToList();

                //VERIFY
                env.CompareAndLogList(linq, dd);
            }
        }
示例#12
0
        public void TestDateTimeWhereCompareWithStaticVariable()
        {
            using (var env = new MethodEnvironment(classEnv))
            {
                //SETUP
                var linq = env.Db.EfParents.Where(x => x.StartDate > dateConst).Select( x => x.StartDate).ToList();

                //ATTEMPT
                env.AboutToUseDelegateDecompiler();
                var dd = env.Db.EfParents.Where(x => x.StartDateGreaterThanStaticVar).Select( x => x.StartDate).Decompile().ToList();

                //VERIFY
                env.CompareAndLogList(linq, dd);
            }
        }
示例#13
0
        public void TestWhereAnyChildrenThenOrderByThenSkipTake()
        {
            using (var env = new MethodEnvironment(classEnv))
            {
                //SETUP

                var linq = env.Db.EfParents.Where(x => x.Children.Any()).OrderBy(x => x.Children.Count).Select(x => x.EfParentId).Skip(1).Take(1).ToList();

                //ATTEMPT
                env.AboutToUseDelegateDecompiler();
                var dd = env.Db.EfParents.Where(x => x.AnyChildren).OrderBy(x => x.CountChildren).Select(x => x.EfParentId).Decompile().Skip(1).Take(1).ToList();

                //VERIFY
                env.CompareAndLogList(linq, dd);
            }
        }
示例#14
0
        public void TestOrderByChildrenCountThenByStringLength()
        {
            using (var env = new MethodEnvironment(classEnv))
            {
                //SETUP

                var linq = env.Db.EfParents.OrderBy(x => x.Children.Count).ThenBy( x => x.ParentString.Length).Select(x => x.EfParentId).ToList();

                //ATTEMPT
                env.AboutToUseDelegateDecompiler();
                var dd = env.Db.EfParents.OrderBy(x => x.CountChildren).ThenBy( x => x.GetStringLength).Select(x => x.EfParentId).Decompile().ToList();

                //VERIFY
                env.CompareAndLogList(linq, dd);
            }
        }
示例#15
0
        public void TestStringContainsConstantStringWithFilter()
        {
            using (var env = new MethodEnvironment(classEnv))
            {
                //SETUP
                var linq =
                    env.Db.EfParents.Where(x => x.ParentString.Contains("2")).Select(x => x.ParentString).ToList();

                //ATTEMPT
                env.AboutToUseDelegateDecompiler();
                var dd = env.Db.EfParents.Where(x => x.StringContainsConstantString).Select(x => x.ParentString).Decompile().ToList();

                //VERIFY
                env.CompareAndLogList(linq, dd);
            }
        }
示例#16
0
        public void TestCountChildren()
        {
            using (var env = new MethodEnvironment(classEnv))
            {
                //SETUP

                var linq = env.Db.EfParents.Select(x => x.Children.Count).ToList();

                //ATTEMPT
                env.AboutToUseDelegateDecompiler();
                var dd = env.Db.EfParents.Select(x => x.CountChildren).Decompile().ToList();

                //VERIFY
                env.CompareAndLogList(linq, dd);
            }
        }
示例#17
0
        public void TestSumCountInChildrenWhereChildrenCanBeNone()
        {
            using (var env = new MethodEnvironment(classEnv))
            {
                //SETUP

                var linq = env.Db.EfParents.Select(x => x.Children.Sum( y => (int?)y.ChildInt) ?? 0).ToList();

                //ATTEMPT
                env.AboutToUseDelegateDecompiler();
                var dd = env.Db.EfParents.Select(x => x.SumIntInChildrenWhereChildrenCanBeNone).Decompile().ToList();

                //VERIFY
                env.CompareAndLogList(linq, dd);
            }
        }
示例#18
0
        public void TestConcatenatePersonHandleNameOrder()
        {
            using (var env = new MethodEnvironment(classEnv))
            {
                //SETUP
                var linq = env.Db.EfPersons.Select(x => x.NameOrder
                    ? x.LastName +", " + x.FirstName + (x.MiddleName == null ? "" : " ")
                    : x.FirstName + (x.MiddleName == null ? "" : " ") + x.MiddleName + " " + x.LastName).ToList();

                //ATTEMPT
                env.AboutToUseDelegateDecompiler();
                var dd = env.Db.EfPersons.Select(x => x.UseOrderToFormatNameStyle).Decompile().ToList();

                //VERIFY
                env.CompareAndLogList(linq, dd);
            }
        }
示例#19
0
        public void TestSelectMethodWithoutComputedAttribute()
        {
            using (var env = new MethodEnvironment(classEnv))
            {
                //SETUP
                var linq = env.Db.EfPersons.Select(x => x.FirstName + " " + x.MiddleName + " " + x.LastName).ToList();

                //ATTEMPT
                env.AboutToUseDelegateDecompiler();
                var dd = env.Db.EfPersons.Select(x => x.GetFullNameNoAttibute()).Decompile().ToList();

                //VERIFY
                env.CompareAndLogList(linq, dd);
            }
        }
示例#20
0
        public void TestCountChildrenWithFilterByExternalClosure()
        {
            using (var env = new MethodEnvironment(classEnv))
            {
                //SETUP

                var i = 123;
                var linq = env.Db.EfParents.Select(x => x.Children.Count(y => y.ChildInt == i)).ToList();

                //ATTEMPT
                env.AboutToUseDelegateDecompiler();
                var dd = env.Db.EfParents.Select(x => x.GetCountChildrenWithFilterByExternalClosure(i)).Decompile().ToList();

                //VERIFY
                env.CompareAndLogList(linq, dd);
            }
        }