Пример #1
0
        public void Should_return_nested_group()
        {
            var dataSource = ArrangeCustomers().GroupBy(new[]
            {
                new GroupDescriptor
                {
                    Member = "Gender"
                },
                new GroupDescriptor
                {
                    Member = "IsActive"
                }
            });

            enumerator = new GridDataSourceEnumerator(dataSource, factory.Object);

            var all    = enumerator.ToArray();
            var second = all[1];

            second.Type.ShouldEqual(GridItemType.GroupRow);

            var group = second.DataItem as IGroup;

            group.Key.ShouldEqual(true);
        }
        public void Should_return_data_items_after_nested_group()
        {
            var customers = ArrangeCustomers();

            var dataSource = customers.GroupBy(new[]
            {
                new GroupDescriptor
                {
                    Member = "Gender"
                },
                new GroupDescriptor
                {
                    Member = "IsActive"
                }
            });

            enumerator = new GridDataSourceEnumerator(dataSource, factory.Object, default(GridInsertRowPosition));

            var all = enumerator.ToArray();
            var third = all[2];

            third.Type.ShouldEqual(GridItemType.DataRow);

            var customer = third.DataItem as Customer;
            customer.ShouldBeSameAs(customers.First());
        }
Пример #3
0
        public void Should_return_data_items_after_nested_group()
        {
            var customers = ArrangeCustomers();

            var dataSource = customers.GroupBy(new[]
            {
                new GroupDescriptor
                {
                    Member = "Gender"
                },
                new GroupDescriptor
                {
                    Member = "IsActive"
                }
            });

            enumerator = new GridDataSourceEnumerator(dataSource, factory.Object);

            var all   = enumerator.ToArray();
            var third = all[2];

            third.Type.ShouldEqual(GridItemType.DataRow);

            var customer = third.DataItem as Customer;

            customer.ShouldBeSameAs(customers.First());
        }
Пример #4
0
        public void Should_set_group_level()
        {
            var dataSource = ArrangeGroupedDataSource();

            enumerator = new GridDataSourceEnumerator(dataSource, factory.Object);

            var all             = enumerator.ToArray();
            var firstGroupItem  = all[0];
            var secondGroupItem = all[2];

            firstGroupItem.GroupLevel.ShouldEqual(0);
            firstGroupItem.GroupLevel.ShouldEqual(secondGroupItem.GroupLevel);
        }
        public void Should_return_data_items_in_groups()
        {
            var dataSource = ArrangeGroupedDataSource();

            enumerator = new GridDataSourceEnumerator(dataSource, factory.Object, default(GridInsertRowPosition));
            var all = enumerator.ToArray();
            var second = all[1];

            second.Type.ShouldEqual(GridItemType.DataRow);

            var customer = second.DataItem as Customer;
            var gender = customer.Gender;
            gender.ShouldEqual(Gender.Female);
        }
Пример #6
0
        public void Should_return_group_after_data_items()
        {
            var dataSource = ArrangeGroupedDataSource();

            enumerator = new GridDataSourceEnumerator(dataSource, factory.Object);

            var all   = enumerator.ToArray();
            var third = all[2];

            third.Type.ShouldEqual(GridItemType.GroupRow);

            var group = third.DataItem as IGroup;

            group.Key.ShouldEqual(Gender.Male);
        }
Пример #7
0
        public void Should_return_data_items_in_groups()
        {
            var dataSource = ArrangeGroupedDataSource();

            enumerator = new GridDataSourceEnumerator(dataSource, factory.Object);
            var all    = enumerator.ToArray();
            var second = all[1];

            second.Type.ShouldEqual(GridItemType.DataRow);

            var customer = second.DataItem as Customer;
            var gender   = customer.Gender;

            gender.ShouldEqual(Gender.Female);
        }
Пример #8
0
        public void Should_return_detail_row_after_group()
        {
            var dataSource = ArrangeGroupedDataSource();

            factory.Setup(c => c.CreateItem(It.IsAny <Customer>())).Returns((Customer c) => new GridItem
            {
                Type     = GridItemType.DataRow,
                State    = GridItemStates.Master,
                DataItem = c
            });

            enumerator = new GridDataSourceEnumerator(dataSource, factory.Object, default(GridInsertRowPosition));

            var all = enumerator.ToArray();

            all[2].Type.ShouldEqual(GridItemType.DetailRow);
        }
Пример #9
0
        public void Should_set_group_level_of_detail_row_if_grouped()
        {
            var dataSource = ArrangeGroupedDataSource();

            factory.Setup(c => c.CreateItem(It.IsAny <Customer>())).Returns((Customer c) => new GridItem
            {
                Type     = GridItemType.DataRow,
                State    = GridItemStates.Master,
                DataItem = c
            });

            enumerator = new GridDataSourceEnumerator(dataSource, factory.Object);

            var all = enumerator.ToArray();

            all[2].GroupLevel.ShouldEqual(1);
        }
Пример #10
0
        public void Should_set_odd_item_as_alternating()
        {
            var dataSource = ArrangeCustomers();

            factory.Setup(c => c.CreateItem(It.IsAny <Customer>())).Returns((Customer c) => new GridItem
            {
                Type     = GridItemType.DataRow,
                State    = GridItemStates.Default,
                DataItem = c
            });

            enumerator = new GridDataSourceEnumerator(dataSource, factory.Object);

            var all = enumerator.ToArray();

            (all[0].State & GridItemStates.Alternating).ShouldNotEqual(GridItemStates.Alternating);
            (all[1].State & GridItemStates.Alternating).ShouldEqual(GridItemStates.Alternating);
        }
Пример #11
0
        public void Should_return_detail_row()
        {
            var dataSource = new [] { "foo" };

            factory.Setup(c => c.CreateItem(dataSource[0])).Returns((string c) => new GridItem
            {
                Type     = GridItemType.DataRow,
                State    = GridItemStates.Master,
                DataItem = c
            });

            enumerator = new GridDataSourceEnumerator(dataSource, factory.Object);

            var all = enumerator.ToArray();

            var second = all[1];

            second.Type.ShouldEqual(GridItemType.DetailRow);
            second.DataItem.ShouldBeSameAs(dataSource[0]);

            all.Length.ShouldEqual(2);
        }
Пример #12
0
        public void Should_set_group_level_for_nested_groups()
        {
            var dataSource = ArrangeCustomers().GroupBy(new[]
            {
                new GroupDescriptor
                {
                    Member = "Gender"
                },
                new GroupDescriptor
                {
                    Member = "IsActive"
                }
            });

            enumerator = new GridDataSourceEnumerator(dataSource, factory.Object);

            var all = enumerator.ToArray();
            var firstNestedGroupItem  = all[1];
            var secondNestedGroupItem = all[4];

            firstNestedGroupItem.GroupLevel.ShouldEqual(1);
            firstNestedGroupItem.GroupLevel.ShouldEqual(secondNestedGroupItem.GroupLevel);
        }
        public void Should_return_detail_row_after_group()
        {
            var dataSource = ArrangeGroupedDataSource();

            factory.Setup(c => c.CreateItem(It.IsAny<Customer>())).Returns((Customer c) => new GridItem
            {
                Type = GridItemType.DataRow,
                State = GridItemStates.Master,
                DataItem = c
            });

            enumerator = new GridDataSourceEnumerator(dataSource, factory.Object);

            var all = enumerator.ToArray();

            all[2].Type.ShouldEqual(GridItemType.DetailRow);
        }
        public void Should_set_odd_item_as_alternating()
        {
            var dataSource = ArrangeCustomers();
            factory.Setup(c => c.CreateItem(It.IsAny<Customer>())).Returns((Customer c) => new GridItem
            {
                Type = GridItemType.DataRow,
                State = GridItemStates.Default,
                DataItem = c
            });

            enumerator = new GridDataSourceEnumerator(dataSource, factory.Object, default(GridInsertRowPosition));

            var all = enumerator.ToArray();

            (all[0].State & GridItemStates.Alternating).ShouldNotEqual(GridItemStates.Alternating);
            (all[1].State & GridItemStates.Alternating).ShouldEqual(GridItemStates.Alternating);
        }
        public void Should_set_group_level_of_detail_row_if_grouped()
        {
            var dataSource = ArrangeGroupedDataSource();

            factory.Setup(c => c.CreateItem(It.IsAny<Customer>())).Returns((Customer c) => new GridItem
            {
                Type = GridItemType.DataRow,
                State = GridItemStates.Master,
                DataItem = c
            });

            enumerator = new GridDataSourceEnumerator(dataSource, factory.Object, default(GridInsertRowPosition));

            var all = enumerator.ToArray();

            all[2].GroupLevel.ShouldEqual(1);
        }
        public void Should_set_group_level_for_nested_groups()
        {
            var dataSource = ArrangeCustomers().GroupBy(new[]
            {
                new GroupDescriptor
                {
                    Member = "Gender"
                },
                new GroupDescriptor
                {
                    Member = "IsActive"
                }
            });

            enumerator = new GridDataSourceEnumerator(dataSource, factory.Object, default(GridInsertRowPosition));

            var all = enumerator.ToArray();
            var firstNestedGroupItem = all[1];
            var secondNestedGroupItem = all[4];

            firstNestedGroupItem.GroupLevel.ShouldEqual(1);
            firstNestedGroupItem.GroupLevel.ShouldEqual(secondNestedGroupItem.GroupLevel);
        }
        public void Should_set_group_level()
        {
            var dataSource = ArrangeGroupedDataSource();

            enumerator = new GridDataSourceEnumerator(dataSource, factory.Object, default(GridInsertRowPosition));

            var all = enumerator.ToArray();
            var firstGroupItem = all[0];
            var secondGroupItem = all[2];

            firstGroupItem.GroupLevel.ShouldEqual(0);
            firstGroupItem.GroupLevel.ShouldEqual(secondGroupItem.GroupLevel);
        }
        public void Should_return_nested_group()
        {
            var dataSource = ArrangeCustomers().GroupBy(new[]
            {
                new GroupDescriptor
                {
                    Member = "Gender"
                },
                new GroupDescriptor
                {
                    Member = "IsActive"
                }
            });

            enumerator = new GridDataSourceEnumerator(dataSource, factory.Object, default(GridInsertRowPosition));

            var all = enumerator.ToArray();
            var second = all[1];

            second.Type.ShouldEqual(GridItemType.GroupRow);

            var group = second.DataItem as IGroup;
            group.Key.ShouldEqual(true);
        }
        public void Should_return_group_after_data_items()
        {
            var dataSource = ArrangeGroupedDataSource();

            enumerator = new GridDataSourceEnumerator(dataSource, factory.Object, default(GridInsertRowPosition));

            var all = enumerator.ToArray();
            var third = all[2];

            third.Type.ShouldEqual(GridItemType.GroupRow);

            var group = third.DataItem as IGroup;
            group.Key.ShouldEqual(Gender.Male);
        }
        public void Should_return_detail_row()
        {
            var dataSource = new[] { "foo" };

            factory.Setup(c => c.CreateItem(dataSource[0])).Returns((string c) => new GridItem
            {
                Type = GridItemType.DataRow,
                State = GridItemStates.Master,
                DataItem = c
            });

            enumerator = new GridDataSourceEnumerator(dataSource, factory.Object, default(GridInsertRowPosition));

            var all = enumerator.ToArray();

            var second = all[1];

            second.Type.ShouldEqual(GridItemType.DetailRow);
            second.DataItem.ShouldBeSameAs(dataSource[0]);

            all.Length.ShouldEqual(2);
        }