本文整理汇总了C#中Specification.IsSatisfiedBy方法的典型用法代码示例。如果您正苦于以下问题:C# Specification.IsSatisfiedBy方法的具体用法?C# Specification.IsSatisfiedBy怎么用?C# Specification.IsSatisfiedBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Specification
的用法示例。
在下文中一共展示了Specification.IsSatisfiedBy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AndShouldPerformLogicalAndOnSpecification
public void AndShouldPerformLogicalAndOnSpecification()
{
// arrange
var target = new Specification<int>( x => x >= 0 ).And( x => x <= 100 );
// act
var satisfied = target.IsSatisfiedBy( 1 );
var unsatisfied = target.IsSatisfiedBy( -1 );
// assert
Assert.True( satisfied );
Assert.False( unsatisfied );
}
示例2: OrShouldPerformLogicalOrOnSpecification
public void OrShouldPerformLogicalOrOnSpecification()
{
// arrange
var target = new Specification<int>( x => x < 0 ).Or( x => x > 0 );
// act
var satisfied = target.IsSatisfiedBy( 1 );
var unsatisfied = target.IsSatisfiedBy( 0 );
// assert
Assert.True( satisfied );
Assert.False( unsatisfied );
}
示例3: Complex_Specification_Should_Eval_ToTrue
public void Complex_Specification_Should_Eval_ToTrue()
{
var testObject = new TestObject { FirstName = "John", LastName = "Doe", Age = 20 };
var testSpec = new Specification<TestObject>(x => x.Age < 30) &
new Specification<TestObject>(x => x.FirstName.StartsWith("J"));
Assert.That(testSpec.IsSatisfiedBy(testObject));
}
示例4: Not_a_match
public void Not_a_match()
{
Member member = new Member();
member.Username = "jimbo";
ISpecification<Member> specification = new Specification<Member>().Equal("Username", "joey");
Assert.That(specification.IsSatisfiedBy(member), Is.False);
}
示例5: Specify_a_fluent_speficiation
public void Specify_a_fluent_speficiation()
{
Member member = new Member();
member.Username = "joey";
ISpecification<Member> specification = new Specification<Member>().Equal("Username", "joey");
Assert.That(specification.IsSatisfiedBy(member), Is.True);
}
示例6: Compare_a_number_goodly
public void Compare_a_number_goodly()
{
Member member = new Member();
member.Attempts = 7;
ISpecification<Member> specification = new Specification<Member>().Equal("Attempts", 7);
Assert.That(specification.IsSatisfiedBy(member), Is.True);
}
示例7: IsSatisfiedByShouldExecuteCallback
public void IsSatisfiedByShouldExecuteCallback( string item, bool expected )
{
// arrange
var target = new Specification<string>( s => s == "unit test" );
// act
var actual = target.IsSatisfiedBy( item );
// assert
Assert.Equal( expected, actual );
}
示例8: When_Invoked_With_A_Func
public When_Invoked_With_A_Func()
{
subject = new object();
option = new Specification(
s => {
funcSubject = s;
funcIsCalled = true;
return true;
}
);
result = option.IsSatisfiedBy(subject);
}
示例9: Compare_two_values
public void Compare_two_values()
{
Member member = new Member();
member.Username = "joey";
member.Attempts = 7;
ISpecification<Member> specification = new Specification<Member>()
.Equal("Username", "joey")
.And
.Equal("Attempts", 7);
Assert.That(specification.IsSatisfiedBy(member), Is.True);
}
示例10: Should_add_or_operator_to_specification
public void Should_add_or_operator_to_specification()
{
var target = new Specification<string>(s => s.Contains("a")).Or(new Specification<string>(s => s.Length > 3));
var items = new[] { "a", "bb", "bbbb", "bbbb" };
var result = (from item in items
where target.IsSatisfiedBy(item)
select item).ToList();
foreach (var value in result)
{
Assert.That(value.Length > 3 || value.Contains("a"), Is.True);
}
}
示例11: Should_add_and_operator_to_specification
public void Should_add_and_operator_to_specification()
{
var target = new Specification<string>(x => x.Contains("a")).And(new Specification<string>(y => y.Length > 3));
var items = new[] { "a", "aa", "aaa", "aaaa" };
var result = (from item in items
where target.IsSatisfiedBy(item)
select item).ToList();
foreach (var value in result)
{
Assert.That(value, Text.Contains("a"));
Assert.That(value.Length, Is.GreaterThan(3));
}
}
示例12: Simple_Specification_Should_Eval_ToFalse
public void Simple_Specification_Should_Eval_ToFalse()
{
var testObject = new TestObject {FirstName = "John", LastName = "Doe", Age = 20};
var testSpec = new Specification<TestObject>(x => x.Age > 30);
Assert.That(!testSpec.IsSatisfiedBy(testObject));
}
示例13: Both_the_left_and_right_specification_should_match
public void Both_the_left_and_right_specification_should_match()
{
Member member = new Member();
member.Username = "joey";
member.Attempts = 7;
ISpecification<Member> specification = new Specification<Member>()
.Equal("Username", "joey")
.And
.Equal("Attempts", 7);
Assert.That(specification.IsSatisfiedBy(member), Is.True);
}
示例14: An_different_left_specification_should_not_match
public void An_different_left_specification_should_not_match()
{
Member member = new Member();
member.Username = "joey";
member.Attempts = 7;
ISpecification<Member> specification = new Specification<Member>()
.Equal("Username", "jimmy")
.And
.Equal("Attempts", 7);
Assert.That(specification.IsSatisfiedBy(member), Is.False);
}
示例15: The_expression_should_match
public void The_expression_should_match()
{
Member member = new Member();
member.Username = "joey";
member.Attempts = 7;
ISpecification<Member> specification = new Specification<Member>()
.Equal("Username", "joey")
.Or
.Equal("Attempts", 9);
Assert.That(specification.IsSatisfiedBy(member), Is.True);
}