コード例 #1
0
ファイル: New.cs プロジェクト: sunxiaotianmg/CoreWF
        public void ConstructAnObjectWithTypeWhichTakesAnOutParameterInConstructor()
        {
            Variable <int> outVariable = new Variable <int>()
            {
                Name = "OutVar"
            };

            TestNew <TypeWithOutParameterInConstructor> mine = new TestNew <TypeWithOutParameterInConstructor>();

            mine.Arguments.Add(new TestArgument <int>(Direction.Out, "OutArg", outVariable));

            TestSequence seq = new TestSequence
            {
                Variables  = { outVariable },
                Activities =
                {
                    mine,
                    new TestWriteLine {
                        MessageExpression = e => outVariable.Get(e).ToString(),HintMessage                                                        = "10"
                    }
                }
            };

            TestRuntime.RunAndValidateWorkflow(seq);
        }
コード例 #2
0
ファイル: gtest-166.cs プロジェクト: andyhebear/Csharp-Parser
	unsafe static int Test () {
		TestNew tt = new TestNew ();
		tt.SetTest ();
		tt.test2 [2] = false;
		tt.T [1] = 5544;
		if (tt.T [1] != 5544)
			return 2;
	
		ExternalStruct es = new ExternalStruct ();
		es.double_buffer [1] = 999999.8888;
		es.double_buffer [0] = es.double_buffer [1];

		// Attributes test
		if (Attribute.GetCustomAttribute (typeof (TestNew).GetField ("test2"), typeof (System.Runtime.CompilerServices.FixedBufferAttribute)) == null)
			return 3;

		
		if (typeof (TestNew).GetNestedTypes ().Length != 5)
			return 5;

		foreach (Type t in typeof (TestNew).GetNestedTypes ()) {
			if (Attribute.GetCustomAttribute (t, typeof (System.Runtime.CompilerServices.CompilerGeneratedAttribute)) == null)
				return 4;
		}

		Console.WriteLine ("OK");
		return 0;
	}
コード例 #3
0
ファイル: New.cs プロジェクト: sunxiaotianmg/CoreWF
        public void ConstructAnObjectWithTypeWhoseConstructorHasInOutRefInterlacedParams()
        {
            Variable <int> inVariable1 = new Variable <int>()
            {
                Name = "InVar1"
            };
            Variable <int> inVariable2 = new Variable <int>()
            {
                Name = "InVar2"
            };
            Variable <int> outVariable1 = new Variable <int>()
            {
                Name = "OutVar1"
            };
            Variable <int> outVariable2 = new Variable <int>()
            {
                Name = "OutVar2"
            };
            Variable <int> refVariable1 = new Variable <int>()
            {
                Name = "RefVar1"
            };
            Variable <int> refVariable2 = new Variable <int>()
            {
                Name = "RefVar2"
            };

            TestNew <TypeWithRefAndOutParametersinConstructor> mine = new TestNew <TypeWithRefAndOutParametersinConstructor>();

            mine.Arguments.Add(new TestArgument <int>(Direction.In, "InArg1", inVariable1));
            mine.Arguments.Add(new TestArgument <int>(Direction.Out, "OutArg1", outVariable1));
            mine.Arguments.Add(new TestArgument <int>(Direction.In, "InArg2", inVariable1));
            mine.Arguments.Add(new TestArgument <int>(Direction.InOut, "RefArg1", refVariable1));
            mine.Arguments.Add(new TestArgument <int>(Direction.InOut, "RefArg2", refVariable2));
            mine.Arguments.Add(new TestArgument <int>(Direction.Out, "OutArg2", outVariable2));

            TestSequence seq = new TestSequence
            {
                Variables  = { inVariable1, inVariable2, outVariable1, outVariable2, refVariable1, refVariable2 },
                Activities =
                {
                    mine,
                    new TestWriteLine {
                        MessageExpression = e => outVariable1.Get(e).ToString(),HintMessage                                                         = "13"
                    },
                    new TestWriteLine {
                        MessageExpression = e => outVariable2.Get(e).ToString(),HintMessage                                                         = "13"
                    },
                    new TestWriteLine {
                        MessageExpression = e => refVariable1.Get(e).ToString(),HintMessage                                                         = "13"
                    },
                    new TestWriteLine {
                        MessageExpression = e => refVariable2.Get(e).ToString(),HintMessage                                                         = "13"
                    }
                }
            };

            TestRuntime.RunAndValidateWorkflow(seq);
        }
コード例 #4
0
ファイル: New.cs プロジェクト: sunxiaotianmg/CoreWF
        public void ConstructAnObjectWithParameterLessConstructor()
        {
            TestNew <ParameterLessConstructorType> myNew = new TestNew <ParameterLessConstructorType>();

            TestSequence seq = GetTraceableTestNew <ParameterLessConstructorType>(myNew, new ParameterLessConstructorType().ToString());

            TestRuntime.RunAndValidateWorkflow(seq);
        }
コード例 #5
0
ファイル: New.cs プロジェクト: sunxiaotianmg/CoreWF
        public void ConstructAnObjectOfValueType()
        {
            TestNew <WeekDay> myNew = new TestNew <WeekDay>();

            TestSequence seq = GetTraceableTestNew <WeekDay>(myNew, new WeekDay().ToString());

            TestRuntime.RunAndValidateWorkflow(seq);
        }
コード例 #6
0
ファイル: New.cs プロジェクト: sunxiaotianmg/CoreWF
        public void ConstructAnObjectOfStruct()
        {
            TestNew <TheStruct> myNew = new TestNew <TheStruct>();

            myNew.Arguments.Add(new TestArgument <int>(Direction.In, "Number", 4));

            TestSequence seq = GetTraceableTestNew <TheStruct>(myNew, new TheStruct(4).ToString());

            TestRuntime.RunAndValidateWorkflow(seq);
        }
コード例 #7
0
ファイル: New.cs プロジェクト: sunxiaotianmg/CoreWF
        public void ConstructAnObjectOfCustomTypeHavingCustomTypeParameters()
        {
            TestNew <ParameteredConstructorType> myNew = new TestNew <ParameteredConstructorType>();

            myNew.Arguments.Add(new TestArgument <Complex>(Direction.In, "Parameter", context => new Complex(1, 2)));

            TestSequence seq = GetTraceableTestNew <ParameteredConstructorType>(myNew, new Complex(1, 2).ToString());

            TestRuntime.RunAndValidateWorkflow(seq);
        }
コード例 #8
0
ファイル: New.cs プロジェクト: sunxiaotianmg/CoreWF
        public void ConstraintErrorForInvalidArguments()
        {
            TestNew <Complex> myNew = new TestNew <Complex>();

            myNew.Arguments.Add(new TestArgument <int>(Direction.In, "Real", 1));

            string error = string.Format(ErrorStrings.ConstructorInfoNotFound, typeof(Complex).Name);

            TestExpressionTracer.Validate(myNew, new List <string> {
                error
            });
        }
コード例 #9
0
    unsafe static int Test()
    {
        TestNew tt = new TestNew();

        tt.SetTest();
        tt.test2 [2] = false;
        tt.T [1]     = 5544;
        if (tt.T [1] != 5544)
        {
            return(2);
        }

        ExternalStruct es = new ExternalStruct();

        es.double_buffer [1] = 999999.8888;
        es.double_buffer [0] = es.double_buffer [1];

        // Attributes test
        if (Attribute.GetCustomAttribute(typeof(TestNew).GetField("test2"), typeof(System.Runtime.CompilerServices.FixedBufferAttribute)) == null)
        {
            return(3);
        }


        if (typeof(TestNew).GetNestedTypes().Length != 5)
        {
            return(5);
        }

        foreach (Type t in typeof(TestNew).GetNestedTypes())
        {
            if (Attribute.GetCustomAttribute(t, typeof(System.Runtime.CompilerServices.CompilerGeneratedAttribute)) == null)
            {
                return(40);
            }

            if (Attribute.GetCustomAttribute(t, typeof(System.Runtime.CompilerServices.UnsafeValueTypeAttribute)) == null)
            {
                return(41);
            }

            if (!t.IsUnicodeClass)
            {
                return(42);
            }
        }

        Console.WriteLine("OK");
        return(0);
    }
コード例 #10
0
ファイル: New.cs プロジェクト: sunxiaotianmg/CoreWF
        public void ConstructAnObjectWithTypeHavingNoParameterLessConstructorWithoutProvidingTypes()
        {
            TestNew <ParameteredConstructorType> myNew = new TestNew <ParameteredConstructorType>();

            TestSequence seq = GetTraceableTestNew <ParameteredConstructorType>(myNew, "null");

            string error = string.Format(ErrorStrings.ConstructorInfoNotFound, typeof(ParameteredConstructorType).Name);

            List <TestConstraintViolation> constraints = new List <TestConstraintViolation>
            {
                new TestConstraintViolation(error, myNew.ProductActivity)
            };

            TestRuntime.ValidateWorkflowErrors(seq, constraints, error);
        }
コード例 #11
0
ファイル: New.cs プロジェクト: sunxiaotianmg/CoreWF
        public void ConstructObjectByProvidingLessParameters()
        {
            TestNew <Complex> myNew = new TestNew <Complex>();

            myNew.Arguments.Add(new TestArgument <int>(Direction.In, "Real", 1));

            string error = string.Format(ErrorStrings.ConstructorInfoNotFound, typeof(Complex).Name);

            List <TestConstraintViolation> constraints = new List <TestConstraintViolation>
            {
                new TestConstraintViolation(error, myNew.ProductActivity)
            };

            TestRuntime.ValidateWorkflowErrors(myNew, constraints, error);
        }
コード例 #12
0
ファイル: New.cs プロジェクト: sunxiaotianmg/CoreWF
        private TestSequence GetTraceableTestNew <T>(TestNew <T> testNew, string expectedResult)
        {
            Variable <T> result = new Variable <T>()
            {
                Name = "Result"
            };

            testNew.Result = result;

            return(new TestSequence
            {
                Variables = { result },
                Activities =
                {
                    testNew,
                    new TestWriteLine {
                        MessageExpression = e => result.Get(e).ToString(),HintMessage                                                = expectedResult
                    }
                }
            });
        }