本文整理汇总了C#中ExpressionSpecification.Or方法的典型用法代码示例。如果您正苦于以下问题:C# ExpressionSpecification.Or方法的具体用法?C# ExpressionSpecification.Or怎么用?C# ExpressionSpecification.Or使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExpressionSpecification
的用法示例。
在下文中一共展示了ExpressionSpecification.Or方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OrTestCase3
public void OrTestCase3()
{
var left = new ExpressionSpecification<String>( x => false );
var target = left.Or( 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: OrTestCase10
public void OrTestCase10()
{
var left = new ExpressionSpecification<String>( x => false, "msgLeft" );
var target = left.Or( x => true, "msgRight" );
var actual = target.IsSatisfiedByWithMessages( String.Empty )
.ToList();
Assert.AreEqual( 0, actual.Count() );
}
示例4: 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);
}
示例5: Main
public static void Main()
{
var someBookstore = new Bookstore("Shakespeare and Company");
var witchesAbroad = new Book("Witches abroad", Genre.Fantasy, 301);
someBookstore.Add(witchesAbroad);
var hatFullOfSky = new Book("Hat full of sky", Genre.Fantasy, 310);
someBookstore.Add(hatFullOfSky);
var gameOfThrones = new Book("Game of thrones", Genre.Fantasy, 900);
someBookstore.Add(gameOfThrones);
var deathOnTheNile = new Book("Death on the Nile", Genre.Crime, 400);
someBookstore.Add(deathOnTheNile);
var historyOfTheBalkans = new Book("History of the Balkans", Genre.History, 1120);
someBookstore.Add(historyOfTheBalkans);
Console.WriteLine(someBookstore);
var ruleOnlyFantasy = new ExpressionSpecification<Book>(b => b.Genre == Genre.Fantasy);
var ruleLargeBooks = new ExpressionSpecification<Book>(b => b.Pages > 1000);
var rulePagesBelow500 = new ExpressionSpecification<Book>(b => b.Pages < 500);
var ruleFantasyOrLargeBooks = ruleOnlyFantasy.Or(ruleLargeBooks);
var allBooks = someBookstore.All();
var largeBooks = allBooks.FindAll(b => ruleLargeBooks.IsSatisfiedBy(b));
Console.WriteLine("Large books:");
foreach (var book in largeBooks)
{
Console.WriteLine(book);
}
Console.WriteLine();
var fantasyAndLargeBooks = allBooks.FindAll(b => ruleFantasyOrLargeBooks.IsSatisfiedBy(b));
Console.WriteLine("Fantasy and large books:");
foreach (var book in fantasyAndLargeBooks)
{
Console.WriteLine(book);
}
Console.WriteLine();
}
示例6: OrTestCaseNullCheck1
public void OrTestCaseNullCheck1()
{
var left = new ExpressionSpecification<String>( x => true );
Func<String, Boolean> expression = null;
Action test = () => left.Or( expression );
test.ShouldThrow<ArgumentNullException>();
}
示例7: OrTestCase7
public void OrTestCase7()
{
var left = new ExpressionSpecification<String>( x => false );
var target = left.Or( x => false );
var actual = target.IsSatisfiedByWithMessages( String.Empty )
.ToList();
Assert.AreEqual( 2, actual.Count() );
Assert.IsNull( actual[0] );
Assert.IsNull( actual[1] );
}
示例8: OrTestCaseNullCheck
public void OrTestCaseNullCheck()
{
var target = new ExpressionSpecification<String>( x => false );
ExpressionSpecification<String> other = null;
Action test = () => target.Or( other );
test.ShouldThrow<ArgumentNullException>();
}
示例9: OrTestCase3
public void OrTestCase3()
{
var target = new ExpressionSpecification<String>( x => false );
var other = new ExpressionSpecification<String>( x => false );
var actual = target.Or( other );
var result = actual.IsSatisfiedBy( String.Empty );
Assert.IsFalse( result );
}