public void TestSingletonAllFilter()
        {
            using (var env = new MethodEnvironment(classEnv))
            {
                //SETUP
                var linq = env.Db.EfParents.All(x => x.ParentInt == 123);

                //ATTEMPT
                env.AboutToUseDelegateDecompiler();
                var dd = env.Db.EfParents.Decompile().All(x => x.IntEqualsConstant);

                //VERIFY
                env.CompareAndLogSingleton(linq, dd);
            }
        }
        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 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);
            }
        }
        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 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);
            }
        }
        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);
            }
        }
        public void TestNullableInit()
        {
            using (var env = new MethodEnvironment(classEnv))
            {
                //SETUP
                var linq = env.Db.EfParents.Select(x => new Nullable<int>()).ToList();

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

                //VERIFY
                env.CompareAndLogList(linq, dd);
            }
        }
        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 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);
            }
        }
        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);
            }
        }
        public void TestSingletonSumChildren()
        {
            using (var env = new MethodEnvironment(classEnv))
            {
                //SETUP

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

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

                //VERIFY
                env.CompareAndLogSingleton(linq, dd);
            }
        }
        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);
            }
        }
        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);
            }
        }
        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);
            }
        }
        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);
            }
        }
        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);
            }
        }
        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);
            }
        }
        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);
            }
        }
        public void TestDelegateDEcompilerExceptionOk()
        {
            try
            {
                using (var env = new MethodEnvironment(classEnv))
                {
                    //SETUP

                    //ATTEMPT
                    env.AboutToUseDelegateDecompiler();
                    throw new Exception("Failed");
                }

            }
            catch
            {
                //VERIFY
                classEnv.GetLastMethodLog().State.ShouldEqual(LogStates.NotSupported);
            }
        }
        public void TestSingleIntEqualsUniqueValue()
        {
            using (var env = new MethodEnvironment(classEnv))
            {
                //SETUP
                var linq =
                    env.Db.EfParents.Select(x => new {x.EfParentId, x.ParentInt})
                        .Single(x => x.ParentInt == DatabaseHelpers.ParentIntUniqueValue).EfParentId;

                //ATTEMPT
                env.AboutToUseDelegateDecompiler();
                var dd =
                    env.Db.EfParents.Select(x => new {x.EfParentId, x.IntEqualsUniqueValue})
                        .Decompile()
                        .Single(x => x.IntEqualsUniqueValue)
                        .EfParentId;

                //VERIFY
                env.CompareAndLogSingleton(linq, dd);
            }
        }
        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);
            }
        }