public void New_Type_ShouldRegisterExpression()
        {
            var comp   = new SubExpressionCompiler <Func <Obj> >();
            var newObj = comp.New(typeof(Obj));

            Assert.Equal(0, comp.ContentCount);
            Assert.Equal(0, comp.VariablesCount);
            Assert.Equal(0, comp.ParametersCount);
            Assert.Equal(1, comp.ExpressionsCount);
        }
        public void Constant_ShouldRegisterExpression()
        {
            var comp = new SubExpressionCompiler <Action>();

            comp.Constant(5);

            Assert.Equal(0, comp.ContentCount);
            Assert.Equal(0, comp.VariablesCount);
            Assert.Equal(0, comp.ParametersCount);
            Assert.Equal(1, comp.ExpressionsCount);
        }
        public void Parameter_T_ShouldRegisterExpression()
        {
            var comp = new SubExpressionCompiler <Action <int> >();

            comp.Parameter <int>("i");

            Assert.Equal(0, comp.ContentCount);
            Assert.Equal(0, comp.VariablesCount);
            Assert.Equal(1, comp.ParametersCount);
            Assert.Equal(1, comp.ExpressionsCount);
        }
        public void CastOrUnbox_ShouldRegisterExpression()
        {
            var comp   = new SubExpressionCompiler <Func <Obj> >();
            var objVar = comp.Variable <Obj>("obj");
            var newObj = comp.CastOrUnbox(objVar, typeof(object));

            Assert.Equal(0, comp.ContentCount);
            Assert.Equal(1, comp.VariablesCount);
            Assert.Equal(0, comp.ParametersCount);
            Assert.Equal(2, comp.ExpressionsCount);
        }
        public void Convert_T_ShouldRegisterExpression()
        {
            var comp   = new SubExpressionCompiler <Func <Obj> >();
            var objVar = comp.Variable <Obj>("obj");
            var newObj = comp.Convert <object>(objVar);

            Assert.Equal(0, comp.ContentCount);
            Assert.Equal(1, comp.VariablesCount);
            Assert.Equal(0, comp.ParametersCount);
            Assert.Equal(2, comp.ExpressionsCount);
        }
        public void StaticField_ShouldRegisterExpression()
        {
            var comp     = new SubExpressionCompiler <Action>();
            var emptyFi  = typeof(string).GetField("Empty");
            var emptyStr = comp.StaticField(emptyFi);

            Assert.Equal(0, comp.ContentCount);
            Assert.Equal(0, comp.VariablesCount);
            Assert.Equal(0, comp.ParametersCount);
            Assert.Equal(1, comp.ExpressionsCount);
        }
        public void StaticProperty_ShouldRegisterExpression()
        {
            var comp     = new SubExpressionCompiler <Action>();
            var lengthPi = typeof(Static).GetProperty("Prop");

            var strLength = comp.StaticProperty(lengthPi);

            Assert.Equal(0, comp.ContentCount);
            Assert.Equal(0, comp.VariablesCount);
            Assert.Equal(0, comp.ParametersCount);
            Assert.Equal(1, comp.ExpressionsCount);
        }
        public void EmitStaticCall_ShouldRegisterContent()
        {
            var comp     = new SubExpressionCompiler <Func <Obj> >();
            var methodMi = typeof(Math).GetMethod("Acos");
            var arg      = comp.Constant((double)5);

            comp.EmitStaticCall(methodMi, arg);
            Assert.Equal(1, comp.ContentCount);
            Assert.Equal(0, comp.VariablesCount);
            Assert.Equal(0, comp.ParametersCount);
            Assert.Equal(1, comp.ExpressionsCount);
        }
        public void EmitCall_ShouldRegisterContent()
        {
            var comp     = new SubExpressionCompiler <Func <Obj> >();
            var methodMi = typeof(Obj).GetMethod("Method");
            var objVar   = comp.Variable <Obj>("obj");

            comp.EmitCall(methodMi, objVar);
            Assert.Equal(1, comp.ContentCount);
            Assert.Equal(1, comp.VariablesCount);
            Assert.Equal(0, comp.ParametersCount);
            Assert.Equal(1, comp.ExpressionsCount);
        }
        public void EmitAssign_ShouldRegisterContent()
        {
            var comp   = new SubExpressionCompiler <Func <Obj> >();
            var objVar = comp.Variable <Obj>("obj");
            var newObj = comp.New <Obj>();

            comp.EmitAssign(objVar, newObj);
            Assert.Equal(1, comp.ContentCount);
            Assert.Equal(1, comp.VariablesCount);
            Assert.Equal(0, comp.ParametersCount);
            Assert.Equal(2, comp.ExpressionsCount);
        }
        public void Property_ShouldRegisterExpression()
        {
            var comp     = new SubExpressionCompiler <Action>();
            var lengthPi = typeof(string).GetProperty("Length");

            var str       = comp.Variable <string>("str");
            var strLength = comp.Property(str, lengthPi);

            Assert.Equal(0, comp.ContentCount);
            Assert.Equal(1, comp.VariablesCount);
            Assert.Equal(0, comp.ParametersCount);
            Assert.Equal(2, comp.ExpressionsCount);
        }
        public void Field_ShouldRegisterExpression()
        {
            var comp    = new SubExpressionCompiler <Action>();
            var fieldFi = typeof(Obj).GetField("Field");

            var objVar = comp.Variable <Obj>("obj");
            var field  = comp.Field(objVar, fieldFi);

            Assert.Equal(0, comp.ContentCount);
            Assert.Equal(1, comp.VariablesCount);
            Assert.Equal(0, comp.ParametersCount);
            Assert.Equal(2, comp.ExpressionsCount);
        }