CK.Core.Tests.EnumerableExtensionTests.test_MaxBy_extension_method C# (CSharp) Method

test_MaxBy_extension_method() private method

private test_MaxBy_extension_method ( ) : void
return void
        public void test_MaxBy_extension_method()
        {
            int[] t = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };

            Assert.That( t.MaxBy( Util.FuncIdentity ), Is.EqualTo( 12 ) );
            Assert.That( t.MaxBy( i => -i ), Is.EqualTo( 0 ) );
            Assert.That( t.MaxBy( i => (i + 1) % 6 == 0 ), Is.EqualTo( 5 ) );
            Assert.That( t.MaxBy( i => i.ToString() ), Is.EqualTo( 9 ), "Lexicographical ordering." );

            Assert.That( t.MaxBy( i => i, ( x, y ) => x - y ), Is.EqualTo( 12 ) );

            Assert.Throws<ArgumentNullException>( () => t.MaxBy<int, int>( null ) );
            t = null;
            Assert.Throws<NullReferenceException>( () => t.MaxBy( Util.FuncIdentity ) );
        }
    }