本文整理汇总了C#中ExpressionSpecification类的典型用法代码示例。如果您正苦于以下问题:C# ExpressionSpecification类的具体用法?C# ExpressionSpecification怎么用?C# ExpressionSpecification使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ExpressionSpecification类属于命名空间,在下文中一共展示了ExpressionSpecification类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: XOrTestCase3
public void XOrTestCase3()
{
var left = new ExpressionSpecification<String>( x => false );
var target = left.XOr( x => false );
var actual = target.IsSatisfiedBy( String.Empty );
Assert.IsFalse( actual );
}
示例2: OrTestCase4
public void OrTestCase4()
{
var left = new ExpressionSpecification<String>( x => true );
var target = left.Or( x => true );
var actual = target.IsSatisfiedByWithMessages( String.Empty );
Assert.AreEqual( 0, actual.Count() );
}
示例3: OrTestCase
public void OrTestCase()
{
var left = new ExpressionSpecification<String>( x => true );
var target = left.Or( x => true );
var actual = target.IsSatisfiedBy( String.Empty );
Assert.IsTrue( actual );
}
示例4: QueryItemById
// Methods
public Item QueryItemById(int id)
{
var itemIdSpec = new ExpressionSpecification<Item>(i => i.Id == id);
var items = _itemRepository
.Select(itemIdSpec, _includedProperties)
.SingleOrDefault();
return items;
}
示例5: AndTestCaseNullCheck
public void AndTestCaseNullCheck()
{
var target = new ExpressionSpecification<String>( x => false );
ExpressionSpecification<String> other = null;
Action test = () => target.And( other );
test.ShouldThrow<ArgumentNullException>();
}
示例6: AndTestCase3
public void AndTestCase3()
{
var target = new ExpressionSpecification<String>( x => false );
var other = new ExpressionSpecification<String>( x => false );
var actual = target.And( other );
var result = actual.IsSatisfiedBy( String.Empty );
Assert.IsFalse( result );
}
示例7: AndTestCase1
public void AndTestCase1()
{
var left = new ExpressionSpecification<String>( x => true );
var target = left.And( x => false );
var actual = target.IsSatisfiedBy( String.Empty );
actual.Should()
.BeFalse();
}
示例8: SatisfiesWithMessagesTestCase
public void SatisfiesWithMessagesTestCase()
{
var specification = new ExpressionSpecification<String>( x => x.Length > 3 )
.And( x => x.StartsWith( "1" ) );
var actual = "1234".SatisfiesWithMessages( specification )
.ToList();
Assert.AreEqual( 0, actual.Count );
}
示例9: XOrTestCase10
public void XOrTestCase10()
{
var left = new ExpressionSpecification<String>( x => false, "msgLeft" );
var target = left.XOr( x => true, "msgRight" );
var actual = target.IsSatisfiedByWithMessages( String.Empty )
.ToList();
Assert.AreEqual( 0, actual.Count() );
}
示例10: AndTestCase3
public void AndTestCase3()
{
var left = new ExpressionSpecification<String>( x => false );
var right = new ExpressionSpecification<String>( x => true );
var target = new AndSpecification<String>( left, right );
var actual = target.And( new ExpressionSpecification<String>( x => false ) );
var result = actual.IsSatisfiedBy( String.Empty );
Assert.IsFalse( result );
}
示例11: XOrTestCase4
public void XOrTestCase4()
{
var left = new ExpressionSpecification<String>( x => true );
var target = left.XOr( x => true );
var actual = target.IsSatisfiedByWithMessages( String.Empty )
.ToList();
Assert.AreEqual( 1, actual.Count );
Assert.AreEqual( "The given object matches both specifications.", actual[0] );
}
示例12: WhereNotTestCase
public void WhereNotTestCase()
{
var target = new List<Int32> { 1, 10, 100, 1000 };
var specification = new ExpressionSpecification<Int32>( x => x >= 100 );
var actual = target.WhereNot( specification )
.ToList();
Assert.AreEqual( 2, actual.Count );
Assert.AreEqual( 1, actual.Count( x => x == 1 ) );
Assert.AreEqual( 1, actual.Count( x => x == 10 ) );
}
示例13: Test_And_Specification
public void Test_And_Specification()
{
ISpecification<int> rule1 = new ExpressionSpecification<int>(x => x == 1, "rule1 failed");
ISpecification<int> rule2 = new ExpressionSpecification<int>(x => x == 2, "rule2 failed");
ISpecification<int> rule3 = new ExpressionSpecification<int>(x => x == 3, "rule3 failed");
ISpecification<int> rule4 = rule1.Or(rule2).Or(rule3);
var result = rule4.ValidateWithMessages(4);
Assert.IsTrue(result.Count > 0);
}
示例14: SatisfiesWithMessagesTestCase2
public void SatisfiesWithMessagesTestCase2()
{
var specification = new ExpressionSpecification<String>( x => x.Length > 3, "msg1" )
.And( x => x.StartsWith( "1" ), "msg2" );
var actual = "234".SatisfiesWithMessages( specification )
.ToList();
Assert.AreEqual( 2, actual.Count );
Assert.AreEqual( 1, actual.Count( x => x == "msg1" ) );
Assert.AreEqual( 1, actual.Count( x => x == "msg2" ) );
}
示例15: AndTestCase11
public void AndTestCase11()
{
var left = new ExpressionSpecification<String>( x => false, "msgLeft" );
var target = left.And( x => false, "msgRight" );
var actual = target.IsSatisfiedByWithMessages( String.Empty )
.ToList();
actual.Should()
.HaveCount( 2 );
actual.Should()
.Contain( "msgLeft", "msgRight" );
}