コード例 #1
0
        public void Variable_T_ShouldRegisterExpression()
        {
            var comp = new SubExpressionCompiler <Action>();

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

            Assert.Equal(0, comp.ContentCount);
            Assert.Equal(1, comp.VariablesCount);
            Assert.Equal(0, comp.ParametersCount);
            Assert.Equal(1, comp.ExpressionsCount);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }