本文整理汇总了C#中Specification.And方法的典型用法代码示例。如果您正苦于以下问题:C# Specification.And方法的具体用法?C# Specification.And怎么用?C# Specification.And使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Specification
的用法示例。
在下文中一共展示了Specification.And方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AndShouldNotAllowNull
public void AndShouldNotAllowNull()
{
// arrange
ISpecification<string> other = null;
var target = new Specification<string>( s => true );
// act
var ex = Assert.Throws<ArgumentNullException>( () => target.And( other ) );
// assert
Assert.Equal( "other", ex.ParamName );
}
示例2: AndShouldReturnCombinedSpecification
public void AndShouldReturnCombinedSpecification()
{
// arrange
var s1 = new Specification<string>( s => true );
var s2 = new Specification<string>( s => false );
// act
var actual = s1.And( s2 );
// assert
Assert.NotNull( actual );
}
示例3: It_should_return_zero_entities_not_matching_any_specifications
public void It_should_return_zero_entities_not_matching_any_specifications()
{
// ARRANGE
var repository = Fixture.CreateRepository();
var nonExistingAge = -999;
var existingLastName = "Tran";
// ACT
var over30Match = new Specification<Customer>(p => p.Age == nonExistingAge);
var lastNameMatch = new Specification<Customer>(p => p.LastName == existingLastName);
var entities = repository.FindAll<Customer>(over30Match.And(lastNameMatch)).ToList();
// ASSERT
Assert.AreEqual(0, entities.Count);
}
开发者ID:ptran123,项目名称:Conceptual,代码行数:15,代码来源:When_using_Specification_chaining_with_AndMethod_noMatch.cs
示例4: It_should_return_entities_matching_all_specifications
public void It_should_return_entities_matching_all_specifications()
{
// ARRANGE
var repository = Fixture.CreateRepository();
var existingAge = 40;
var existingLastName = "Tran";
// ACT
var over30Match = new Specification<Customer>(p => p.Age > existingAge);
var lastNameMatch = new Specification<Customer>(p => p.LastName == existingLastName);
var entities = repository.FindAll<Customer>(over30Match.And(lastNameMatch)).ToList();
// ASSERT
Assert.AreEqual(1, entities.Count);
Assert.AreEqual("Peter Tran", entities[0].GetFullName());
}
开发者ID:ptran123,项目名称:Conceptual,代码行数:16,代码来源:When_using_Specification_chaining_with_AndMethod_match.cs
示例5: Should_return_itself_on_adding_and_operator_when_other_specification_is_null
public void Should_return_itself_on_adding_and_operator_when_other_specification_is_null()
{
var expected = new Specification<string>(s => s.Contains("a"));
var target = expected.And(null);
Assert.That(target, Is.SameAs(expected));
}