Exemple #1
0
        public void Apply_Rows_Success(object[] values, ColumnType columnType, int index)
        {
            var i    = 0;
            var objs = values.Select(x => new object[] { ++i, x }).ToArray();

            var args     = new ObjectsResultSetResolverArgs(objs);
            var resolver = new ObjectsResultSetResolver(args);
            var rs       = resolver.Execute();

            var ranking    = new TopRanking(new ColumnOrdinalIdentifier(1), columnType, null, null);
            var filteredRs = ranking.Apply(rs);

            Assert.That(filteredRs.Rows.Count, Is.EqualTo(1));
            Assert.That(filteredRs.Rows[0].ItemArray[0], Is.EqualTo(index));
            Assert.That(filteredRs.Rows[0].ItemArray[1], Is.EqualTo(values.Max()));
        }
Exemple #2
0
        public void Apply_Alias_Success(object[] values, ColumnType columnType, int index)
        {
            var i    = 0;
            var objs = values.Select(x => new object[] { ++i, x }).ToArray();

            var args     = new ObjectsResultSetResolverArgs(objs);
            var resolver = new ObjectsResultSetResolver(args);
            var rs       = resolver.Execute();

            var alias = Mock.Of <IColumnAlias>(x => x.Column == 1 && x.Name == "myValue");

            var ranking    = new TopRanking(new ColumnNameIdentifier("myValue"), columnType, Enumerable.Repeat(alias, 1), null);
            var filteredRs = ranking.Apply(rs);

            Assert.That(filteredRs.Rows.Count, Is.EqualTo(1));
            Assert.That(filteredRs.Rows[0].ItemArray[0], Is.EqualTo(index));
            Assert.That(filteredRs.Rows[0].ItemArray[1], Is.EqualTo(values.Max()));
        }
Exemple #3
0
        public void Apply_Larger_Success(object[] values, ColumnType columnType, int[] index)
        {
            var i    = 0;
            var objs = values.Select(x => new object[] { ++i, x }).ToArray();

            var args     = new ObjectsResultSetResolverArgs(objs);
            var resolver = new ObjectsResultSetResolver(args);
            var rs       = resolver.Execute();

            var ranking    = new TopRanking(10, new ColumnOrdinalIdentifier(1), columnType, null, null);
            var filteredRs = ranking.Apply(rs);

            Assert.That(filteredRs.Rows.Count, Is.EqualTo(values.Count()));
            Assert.That(filteredRs.Rows[0].ItemArray[0], Is.EqualTo(index[0].ToString()));
            Assert.That(filteredRs.Rows[0].ItemArray[1], Is.EqualTo(values.Max()));
            Assert.That(filteredRs.Rows[1].ItemArray[0], Is.EqualTo(index[1].ToString()));
            Assert.That(filteredRs.Rows[1].ItemArray[1], Is.EqualTo(values.Except(Enumerable.Repeat(values.Max(), 1)).Max()));
            Assert.That(filteredRs.Rows[values.Count() - 1].ItemArray[0], Is.EqualTo(index[2].ToString()));
            Assert.That(filteredRs.Rows[values.Count() - 1].ItemArray[1], Is.EqualTo(values.Min()));
        }