本文整理汇总了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));
}
示例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));
}
示例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));
}
示例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()));
}
示例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()));
}
示例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));
}
示例7: NotNull
public void NotNull()
{
c = new NotNull();
Assertion.Assert(!c.Eval(null));
Assertion.Assert(c.Eval(new object()));
}
示例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));
}
示例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"));
}
示例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"));
}
示例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"));
}
示例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));
}
示例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));
}
示例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);
}
}