public void List_of_columns_is_returned()
        {
            var provider = new DefaultListColumnProvider();

            var columns = provider.GetColumnsForType(listItemType, controllerContext);

            Assert.IsInstanceOfType(columns, typeof(ListColumns));
        }
        public void Property1_is_returned_with_default_order()
        {
            var provider = new DefaultListColumnProvider();

            var columns = provider.GetColumnsForType(listItemType, controllerContext);

            var listColumn = columns.Find("Property1");

            Assert.AreEqual(10000, listColumn.Order);
        }
        public void List_columns_are_ordered_when_returned()
        {
            var provider = new DefaultListColumnProvider();

            var columns = provider.GetColumnsForType(listItemType, controllerContext);

            Assert.AreEqual("Property4", columns.ElementAt(0).Name);
            Assert.AreEqual("Property2", columns.ElementAt(1).Name);
            Assert.AreEqual("Property1", columns.ElementAt(2).Name);
        }
        public void Property1_is_returned_with_cell_template()
        {
            var provider = new DefaultListColumnProvider();

            viewEngine.MakeViewExists("CellTemplates/Property1");

            var columns = provider.GetColumnsForType(listItemType, controllerContext);

            var listColumn = columns.Find("Property1");

            Assert.AreEqual("CellTemplates/Property1", listColumn.CellTemplate);
        }
        public void Property2_is_returned_with_the_is_sorted_true_when_it_is_being_sorted()
        {
            var provider = new DefaultListColumnProvider();

            queryString.Add("sortby", "property2");

            var columns = provider.GetColumnsForType(listItemType, controllerContext);

            var listColumn = columns.Find("Property2");

            Assert.IsTrue(listColumn.IsSorted);
        }
        public void Property2_is_returned_with_the_is_sorted_false()
        {
            var provider = new DefaultListColumnProvider();

            var columns = provider.GetColumnsForType(listItemType, controllerContext);

            var listColumn = columns.Find("Property2");

            Assert.IsFalse(listColumn.IsSorted);
        }
        public void Property2_is_returned_with_sort_direction_set_to_null()
        {
            var provider = new DefaultListColumnProvider();

            queryString.Add("sortby", "property13");

            var columns = provider.GetColumnsForType(listItemType, controllerContext);

            var listColumn = columns.Find("Property2");

            Assert.IsNull(listColumn.SortDirection);
        }
        public void Property2_is_returned_with_sort_direction_descending()
        {
            var provider = new DefaultListColumnProvider();

            queryString.Add("sortby", "property2");
            queryString.Add("sortdirection", "descending");

            var columns = provider.GetColumnsForType(listItemType, controllerContext);

            var listColumn = columns.Find("Property2");

            Assert.AreEqual(SortDirection.Descending, listColumn.SortDirection);
        }
        public void Property1_is_returned_with_has_header_template_set_to_true()
        {
            var provider = new DefaultListColumnProvider();

            viewEngine.MakeViewExists("HeaderTemplates/Property1");

            var columns = provider.GetColumnsForType(listItemType, controllerContext);

            Assert.IsTrue(columns.Find("Property1").HasHeaderTemplate);
        }
        public void Property2_is_returned_with_no_header_template()
        {
            var provider = new DefaultListColumnProvider();

            var columns = provider.GetColumnsForType(listItemType, controllerContext);

            Assert.IsNull(columns.Find("Property2").HeaderTemplate);
        }
        public void Property2_is_returned_with_header_template()
        {
            var provider = new DefaultListColumnProvider();

            viewEngine.MakeViewExists("HeaderTemplates/Property2");

            var columns = provider.GetColumnsForType(listItemType, controllerContext);

            Assert.AreEqual("HeaderTemplates/Property2", columns.Find("Property2").HeaderTemplate);
        }
        public void Property2_is_returned_with_has_cell_template_true()
        {
            var provider = new DefaultListColumnProvider();

            viewEngine.MakeViewExists("CellTemplates/Property2");

            var columns = provider.GetColumnsForType(listItemType, controllerContext);

            var listColumn = columns.Find("Property2");

            Assert.IsTrue(listColumn.HasCellTemplate);
        }
        public void Property1_is_returned_with_the_name()
        {
            var provider = new DefaultListColumnProvider();

            var columns = provider.GetColumnsForType(listItemType, controllerContext);

            Assert.IsNotNull(columns.Find("Property1"));
        }
        public void Property1_is_returned_with_the_display_name()
        {
            var provider = new DefaultListColumnProvider();

            var columns = provider.GetColumnsForType(listItemType, controllerContext);

            var listColumn = columns.Find("Property1");

            Assert.AreEqual("Property1 Display Name", listColumn.DisplayName);
        }
        public void Property2_is_returned_with_type()
        {
            var provider = new DefaultListColumnProvider();

            var columns = provider.GetColumnsForType(listItemType, controllerContext);

            Assert.AreEqual(typeof(int), columns.Find("Property2").Type);
        }
        public void Property2_is_returned_with_sortby_in_the_sort_url()
        {
            var provider = new DefaultListColumnProvider();

            RouteTable.Routes.MapRoute("test", "{action}/a/{controller}/testing");

            routeData.Values["action"] = "myaction";
            routeData.Values.Add("controller", "mycontroller");

            var columns = provider.GetColumnsForType(listItemType, controllerContext);

            var listColumn = columns.Find("Property2");

            Assert.AreEqual("/myaction/a/mycontroller/testing?sortBy=Property2", listColumn.SortUrl);
        }
        public void Property3_is_not_returned()
        {
            var provider = new DefaultListColumnProvider();

            var columns = provider.GetColumnsForType(listItemType, controllerContext);

            var listColumn = columns.Find("Property3");

            Assert.IsNull(listColumn);
        }
        public void Property2_is_returned_with_sortdirection_set_to_descending_in_the_sort_url_when_the_column_is_sorted()
        {
            var provider = new DefaultListColumnProvider();

            RouteTable.Routes.MapRoute("test", "{action}/t/{controller}/testing");

            routeData.Values["action"] = "myaction";
            routeData.Values.Add("controller", "mycontroller");

            queryString.Add("sortby", "property2");
            queryString.Add("sortdirection", "ascending");

            var columns = provider.GetColumnsForType(listItemType, controllerContext);

            var listColumn = columns.Find("Property2");

            Assert.AreEqual("/myaction/t/mycontroller/testing?sortBy=Property2&sortdirection=Descending", listColumn.SortUrl);
        }
        public void Property1_is_returned_with_has_cell_template_false()
        {
            var provider = new DefaultListColumnProvider();

            var columns = provider.GetColumnsForType(listItemType, controllerContext);

            var listColumn = columns.Find("Property2");

            Assert.IsFalse(listColumn.HasCellTemplate);
        }
        public void Property1_is_returned_with_has_header_template_set_to_false()
        {
            var provider = new DefaultListColumnProvider();

            var columns = provider.GetColumnsForType(listItemType, controllerContext);

            Assert.IsFalse(columns.Find("Property1").HasHeaderTemplate);
        }