当前位置: 首页>>代码示例>>C#>>正文


C# Specification.IsSatisfiedBy方法代码示例

本文整理汇总了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 );
        }
开发者ID:WaffleSquirrel,项目名称:More,代码行数:13,代码来源:ISpecificationExtensionsTest.cs

示例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 );
        }
开发者ID:WaffleSquirrel,项目名称:More,代码行数:13,代码来源:ISpecificationExtensionsTest.cs

示例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));
 }
开发者ID:jordanyaker,项目名称:ncommon,代码行数:7,代码来源:SpecificationTests.cs

示例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);
        }
开发者ID:KevM,项目名称:Magnum,代码行数:9,代码来源:Specification_Specs.cs

示例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);
        }
开发者ID:KevM,项目名称:Magnum,代码行数:9,代码来源:Specification_Specs.cs

示例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);
        }
开发者ID:KevM,项目名称:Magnum,代码行数:9,代码来源:Specification_Specs.cs

示例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 );
        }
开发者ID:WaffleSquirrel,项目名称:More,代码行数:11,代码来源:SpecificationTTest.cs

示例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);
                }
开发者ID:CHECK24,项目名称:c24.Specifications,代码行数:13,代码来源:SpecificationTests.cs

示例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);
        }
开发者ID:KevM,项目名称:Magnum,代码行数:13,代码来源:Specification_Specs.cs

示例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);
            }
        }
开发者ID:marektihkan,项目名称:Arc,代码行数:14,代码来源:SpecificationTests.cs

示例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));
            }
        }
开发者ID:marektihkan,项目名称:Arc,代码行数:15,代码来源:SpecificationTests.cs

示例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));
 }
开发者ID:jordanyaker,项目名称:ncommon,代码行数:6,代码来源:SpecificationTests.cs

示例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);
        }
开发者ID:KevM,项目名称:Magnum,代码行数:13,代码来源:Specification_Specs.cs

示例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);
        }
开发者ID:KevM,项目名称:Magnum,代码行数:13,代码来源:Specification_Specs.cs

示例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);
        }
开发者ID:KevM,项目名称:Magnum,代码行数:13,代码来源:Specification_Specs.cs


注:本文中的Specification.IsSatisfiedBy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。