コード例 #1
0
ファイル: TestTypes.cs プロジェクト: jonimoreira/TestTFS
		public ExpressionOwner()
		{
			this.InstanceB = new ArrayList();
			this.InstanceA = this.InstanceB;
			this.NullField = null;
			this.DecimalA = 100;
			this.DecimalB = 0.25M;
			this.KeyboardA = new Keyboard();
			this.KeyboardA.StructA = new Mouse("mouse", 123);
			this.KeyboardA.ClassA = new Monitor();
			this.EncodingA = System.Text.Encoding.ASCII;
			this.DelegateA = DoAction;
			this.ICloneableArray = new string[] {};
			this.ArrayA = new string[] {};
			this.DelegateANull = null;
			this.IComparableNull = null;
			this.IComparableString = "string";
			this.ExceptionA = new ArgumentException();
			this.ExceptionNull = null;
			this.ValueTypeStructA = new TestStruct();
			this.ObjectStringA = "string";
			this.ObjectIntA = 100;
			this.IComparableA = 100.25;
			this.StructA = new TestStruct();
			this.VersionA = new System.Version(1, 1, 1, 1);
			this.ICloneableA = "abc";
			this.GuidA = Guid.NewGuid();
			this.List = new ArrayList();
			this.List.Add("a");
			this.List.Add(100);
			this.StringDict = new System.Collections.Specialized.StringDictionary();
			this.StringDict.Add("key", "value");
			this.DoubleA = 100.25;
			this.SingleA = 100.25f;
			this.Int32A = 100000;
			this.StringA = "string";
			this.BoolA = true;
			this.TypeA = typeof(string);
			this.ByteA = 50;
			this.ByteB = 2;
			this.SByteA = -10;
			this.Int16A = -10;
			this.UInt16A = 100;
			this.DateTimeA = new DateTime(2007, 7, 1);
			this.GenericDict = new Dictionary<string, int>();
			this.GenericDict.Add("a", 100);
			this.GenericDict.Add("b", 100);

			this.Dict = new Hashtable();
			this.Dict.Add(100, null);
			this.Dict.Add("abc", null);

			DataTable dt = new DataTable();
			dt.Columns.Add("ColumnA", typeof(int));

			dt.Rows.Add(100);

			this.Row = dt.Rows[0];
		}
コード例 #2
0
        public void TestValueTypeOwner()
        {
            TestStruct owner = new TestStruct(100);
            ExpressionContext context = this.CreateGenericContext(owner);

            IGenericExpression<int> e = this.CreateGenericExpression<int>("myA", context);
            int result = e.Evaluate();
            Assert.AreEqual(100, result);

            e = this.CreateGenericExpression<int>("mya.compareto(100)", context);
            result = e.Evaluate();
            Assert.AreEqual(0, result);

            e = this.CreateGenericExpression<int>("DoStuff()", context);
            result = e.Evaluate();
            Assert.AreEqual(100, result);

            DateTime dt = DateTime.Now;
            context = this.CreateGenericContext(dt);

            e = this.CreateGenericExpression<int>("Month", context);
            result = e.Evaluate();
            Assert.AreEqual(dt.Month, result);

            IGenericExpression<string> e2 = this.CreateGenericExpression<string>("tolongdatestring()", context);
            Assert.AreEqual(dt.ToLongDateString(), e2.Evaluate());
        }