Exemple #1
0
        public void DataTemplateTextCellDetailPropertyTest()
        {
            MockForms.Init();
            var target = new HomeView().PeopleListView.GetValue(ListView.ItemTemplateProperty);

            Assert.True(
                target != null,
                "You must have a property named `ItemTemplate` in the `PeopleListView` control."
                );
            Assert.True(
                target is DataTemplate,
                "The `ItemTemplate` property of the `PeopleListView` control must be set to a `DataTemplate`."
                );
            List <Cell> cells = new List <Cell>();

            try
            {
                cells = new HomeView().PeopleListView?.TemplatedItems.ToList <Cell>();
            }
            catch (InvalidOperationException)
            {
                Assert.True(
                    false,
                    "The `DataTemplate` property of the `PeopleListView` control should contain a single `TextCell` control."
                    );
            }
            catch (InvalidCastException)
            {
                Assert.True(
                    false,
                    "The `DataTemplate` property of the `PeopleListView` control should only contain a single `TextCell` control and no other type of control."
                    );
            }
            Assert.True(
                cells.Any() && cells.All(i => i is TextCell),
                "The `DataTemplate` property of the `PeopleListView` control should contain a single `TextCell` control."
                );
            Assert.True(
                cells.OfType <TextCell>().All(t => t.GetBinding(TextCell.TextProperty)?.Path == "Name"),
                "The `TextCell` control within the `DataTemplate` property of the `PeopleListView` control should have it's `Text` property data-bound to the context's `Name` property."
                );
            Assert.True(
                cells.OfType <TextCell>().All(t => t.GetBinding(TextCell.DetailProperty)?.Path == "Company"),
                "The `TextCell` control within the `DataTemplate` property of the `PeopleListView` control should have it's `Detail` property data-bound to the context's `Company` property."
                );
        }
Exemple #2
0
        public void DataTemplateTextCellTest()
        {
            MockForms.Init();
            var target = new HomeView().PeopleListView.GetValue(ListView.ItemTemplateProperty);

            Assert.True(
                target != null,
                "You must have a property named `ItemTemplate` in the `PeopleListView` control."
                );
            Assert.True(
                target is DataTemplate,
                "The `ItemTemplate` property of the `PeopleListView` control must be set to a `DataTemplate`."
                );
            List <Cell> cells = new List <Cell>();

            try
            {
                cells = new HomeView().PeopleListView?.TemplatedItems.ToList <Cell>();
            }
            catch (InvalidOperationException)
            {
                Assert.True(
                    false,
                    "The `DataTemplate` property of the `PeopleListView` control should contain a single `TextCell` control."
                    );
            }
            catch (InvalidCastException)
            {
                Assert.True(
                    false,
                    "The `DataTemplate` property of the `PeopleListView` control should contain a single `TextCell` control."
                    );
            }
            Assert.True(
                cells.Any() && cells.All(i => i is TextCell),
                "The `DataTemplate` property of the `PeopleListView` control should contain a single `TextCell` control."
                );
        }