示例#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 BottomRanking(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.ToString()));
            Assert.That(filteredRs.Rows[0].ItemArray[1], Is.EqualTo(values.Min()));
        }
示例#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 BottomRanking(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.ToString()));
            Assert.That(filteredRs.Rows[0].ItemArray[1], Is.EqualTo(values.Min()));
        }
示例#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 BottomRanking(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]));
            Assert.That(filteredRs.Rows[0].ItemArray[1], Is.EqualTo(values.Min()));
            Assert.That(filteredRs.Rows[1].ItemArray[0], Is.EqualTo(index[1]));
            Assert.That(filteredRs.Rows[1].ItemArray[1], Is.EqualTo(values.Except(Enumerable.Repeat(values.Min(), 1)).Min()));
            Assert.That(filteredRs.Rows[values.Count() - 1].ItemArray[0], Is.EqualTo(index[2]));
            Assert.That(filteredRs.Rows[values.Count() - 1].ItemArray[1], Is.EqualTo(values.Max()));
        }