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


C# ExpressionSpecification类代码示例

本文整理汇总了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 );
        }
开发者ID:MannusEtten,项目名称:Extend,代码行数:8,代码来源:ISpecification.XOr.Test.cs

示例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() );
        }
开发者ID:MannusEtten,项目名称:Extend,代码行数:8,代码来源:ISpecification.Or.Test.cs

示例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 );
        }
开发者ID:MannusEtten,项目名称:Extend,代码行数:8,代码来源:ISpecification.Or.Test.cs

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

示例5: AndTestCaseNullCheck

        public void AndTestCaseNullCheck()
        {
            var target = new ExpressionSpecification<String>( x => false );
            ExpressionSpecification<String> other = null;

            Action test = () => target.And( other );

            test.ShouldThrow<ArgumentNullException>();
        }
开发者ID:MannusEtten,项目名称:Extend,代码行数:9,代码来源:ExpressionSpecification.Test.cs

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

示例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();
        }
开发者ID:MannusEtten,项目名称:Extend,代码行数:9,代码来源:ISpecification.And.Test.cs

示例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 );
        }
开发者ID:MannusEtten,项目名称:Extend,代码行数:9,代码来源:Object.Generic.SatisfiesWithMessages.Test.cs

示例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() );
        }
开发者ID:MannusEtten,项目名称:Extend,代码行数:9,代码来源:ISpecification.XOr.Test.cs

示例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 );
        }
开发者ID:MannusEtten,项目名称:Extend,代码行数:10,代码来源:AndSpecification.Test.cs

示例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] );
        }
开发者ID:MannusEtten,项目名称:Extend,代码行数:10,代码来源:ISpecification.XOr.Test.cs

示例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 ) );
        }
开发者ID:MannusEtten,项目名称:Extend,代码行数:11,代码来源:IEnumerable[T].WhereNot.Test.cs

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

示例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" ) );
        }
开发者ID:MannusEtten,项目名称:Extend,代码行数:11,代码来源:Object.Generic.SatisfiesWithMessages.Test.cs

示例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" );
        }
开发者ID:MannusEtten,项目名称:Extend,代码行数:13,代码来源:ISpecification.And.Test.cs


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