当前位置: 首页>>代码示例>>C#>>正文


C# IConstraint.Eval方法代码示例

本文整理汇总了C#中IConstraint.Eval方法的典型用法代码示例。如果您正苦于以下问题:C# IConstraint.Eval方法的具体用法?C# IConstraint.Eval怎么用?C# IConstraint.Eval使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IConstraint的用法示例。


在下文中一共展示了IConstraint.Eval方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IsNull

		public void IsNull()
		{
			c = new IsNull();
			Assertion.Assert(c.Eval(null));
			Assertion.Assert(!c.Eval(new object()));
			Assertion.Assert(!c.Eval(1));
			Assertion.Assert(!c.Eval(true));
			Assertion.Assert(!c.Eval(false));
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:9,代码来源:ConstraintsTest.cs

示例2: IsEqualWhenArray

		public void IsEqualWhenArray()
		{
			object[] o1 = new object[] { 1, 2, 3 };
			object[] o2 = new object[] { 1, 2, 4 };

			c = new IsEqual(new object[] { 1, 2, 3 });
			Assertion.Assert("should be equal", c.Eval(o1));
			Assertion.Assert("shouldn't be equal", !c.Eval(o2));
			Assertion.Assert("it ain't null", !c.Eval(null));
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:10,代码来源:ConstraintsTest.cs

示例3: NotEqual

		public void NotEqual()
		{
			object o1 = new object();
			object o2 = new object();
			c = new NotEqual(o1);
			Assertion.Assert(!c.Eval(o1));
			Assertion.Assert(c.Eval(o2));
			Assertion.Assert(c.Eval(null));

			int i1 = 1;
			int i2 = 2;
			c = new NotEqual(i1);
			Assertion.Assert(!c.Eval(i1));
			Assertion.Assert(!c.Eval(1));
			Assertion.Assert(c.Eval(i2));
			Assertion.Assert(c.Eval(2));
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:17,代码来源:ConstraintsTest.cs

示例4: IsAnything

		public void IsAnything()
		{
			c = new IsAnything();
			Assertion.Assert(c.Eval(null));
			Assertion.Assert(c.Eval(0));
			Assertion.Assert(c.Eval(99));
			Assertion.Assert(c.Eval(-2));
			Assertion.Assert(c.Eval(true));
			Assertion.Assert(c.Eval(false));
			Assertion.Assert(c.Eval(""));
			Assertion.Assert(c.Eval("hello"));
			Assertion.Assert(c.Eval(new object()));
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:13,代码来源:ConstraintsTest.cs

示例5: IsType

		public void IsType()
		{
			c = new IsTypeOf(typeof(System.IO.TextReader));
			Assertion.Assert(!c.Eval(null));
			Assertion.Assert(c.Eval(new System.IO.StringReader("")));
			Assertion.Assert(!c.Eval(new System.IO.StringWriter()));
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:7,代码来源:ConstraintsTest.cs

示例6: Delegate

		public void Delegate()
		{
			c = new Constraint(new Constraint.Method(myEval));
			myFlag = false;
			Assertion.Assert(c.Eval(null));
			Assertion.Assert(!c.Eval(null));
			Assertion.Assert(c.Eval(null));
			Assertion.Assert(!c.Eval(null));
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:9,代码来源:ConstraintsTest.cs

示例7: NotNull

		public void NotNull()
		{
			c = new NotNull();
			Assertion.Assert(!c.Eval(null));
			Assertion.Assert(c.Eval(new object()));
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:6,代码来源:ConstraintsTest.cs

示例8: IsCloseTo

		public void IsCloseTo()
		{
			c = new IsCloseTo(1.0, 0.5);

			Assertion.Assert(c.Eval(1.0));
			Assertion.Assert(c.Eval(0.5));
			Assertion.Assert(c.Eval(1.5));

			Assertion.Assert(c.Eval(1));
			Assertion.Assert(c.Eval(0.5f));
			Assertion.Assert(c.Eval(new decimal(1.5)));

			Assertion.Assert(!c.Eval(0.49));
			Assertion.Assert(!c.Eval(1.51));
			Assertion.Assert(!c.Eval(-1.0));

			Assertion.Assert(c.Eval("1.2"));
			Assertion.Assert(!c.Eval("0.2"));
			Assertion.Assert(!c.Eval("hello"));

			Assertion.Assert(!c.Eval(null));
			Assertion.Assert(!c.Eval(0));
			Assertion.Assert(!c.Eval(0.0));
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:24,代码来源:ConstraintsTest.cs

示例9: IsMatch

		public void IsMatch()
		{
			c = new IsMatch(new Regex(@"^th[aeiou]\w* .*$"));
			Assertion.Assert(c.Eval("the world"));
			Assertion.Assert(!c.Eval("theworld"));
			Assertion.Assert(!c.Eval("ThE world"));
			Assertion.Assert(!c.Eval(" the world"));
			Assertion.Assert(c.Eval("thats nice"));
			Assertion.Assert(!c.Eval(new object()));
			Assertion.Assert(!c.Eval(null));

			c = new IsMatch(@"^th[aeiou]\w* .*$");
			Assertion.Assert(c.Eval("the world"));
			Assertion.Assert(!c.Eval("theworld"));
			Assertion.Assert(!c.Eval("ThE world"));

			c = new IsMatch(@"^th[aeiou]\w* .*$", false);
			Assertion.Assert(c.Eval("the world"));
			Assertion.Assert(!c.Eval("theworld"));
			Assertion.Assert(!c.Eval("ThE world"));

			c = new IsMatch(@"^th[aeiou]\w* .*$", true);
			Assertion.Assert(c.Eval("the world"));
			Assertion.Assert(!c.Eval("theworld"));
			Assertion.Assert(c.Eval("ThE world"));

		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:27,代码来源:ConstraintsTest.cs

示例10: TestIsEqualIgnoreWhiteSpace

		public void TestIsEqualIgnoreWhiteSpace()
		{
			c = new IsEqualIgnoreWhiteSpace("Hello World   how\n are we?");
			Assertion.Assert(c.Eval("Hello World how are we?"));
			Assertion.Assert(c.Eval("   Hello World   how are \n\n\twe?"));
			Assertion.Assert(!c.Eval("HelloWorld how are we?"));
			Assertion.Assert(!c.Eval("Hello World how are we"));
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:8,代码来源:ConstraintsTest.cs

示例11: IsEqualIgnoreCase

		public void IsEqualIgnoreCase()
		{
			c = new IsEqualIgnoreCase("heLLo");
			Assertion.Assert(c.Eval("HELLO"));
			Assertion.Assert(c.Eval("hello"));
			Assertion.Assert(c.Eval("HelLo"));
			Assertion.Assert(!c.Eval("abcde"));
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:8,代码来源:ConstraintsTest.cs

示例12: NotIn

		public void NotIn()
		{
			c = new NotIn(1, 2);
			Assertion.Assert(!c.Eval(1));
			Assertion.Assert(!c.Eval(2));
			Assertion.Assert(c.Eval(3));

			int[] array = {1, 2};
			c = new NotIn(array);
			Assertion.Assert(!c.Eval(1));
			Assertion.Assert(!c.Eval(2));
			Assertion.Assert(c.Eval(3));
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:13,代码来源:ConstraintsTest.cs

示例13: IsIn

		public void IsIn()
		{
			c = new IsIn(2, 3, 5);
			Assertion.Assert(!c.Eval(1));
			Assertion.Assert(c.Eval(2));
			Assertion.Assert(c.Eval(3));
			Assertion.Assert(!c.Eval(4));
			Assertion.Assert(c.Eval(5));
			Assertion.Assert(!c.Eval(6));
			Assertion.Assert(!c.Eval(null));

			int[] array = {1, 2};
			c = new IsIn(array);
			Assertion.Assert(c.Eval(1));
			Assertion.Assert(c.Eval(2));
			Assertion.Assert(!c.Eval(3));
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:17,代码来源:ConstraintsTest.cs

示例14: checkConstraint

		private void checkConstraint(string methodName, IConstraint expected, object actual, int index)
		{
			if (!expected.Eval(actual))
			{
				String messageFormat = "{0}() called with incorrect parameter ({1})";
				String message = String.Format(messageFormat, methodName, index + 1);
				throw new VerifyException(message, expected.Message, actual);
			}
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:9,代码来源:MockCall.cs


注:本文中的IConstraint.Eval方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。