コード例 #1
0
        public void When_binding_a_form_to_a_tree_view()
        {
            var binder   = new Binder();
            var form     = new PostWithOptionsForm();
            var post     = NeededObjectsFactory.CreatePost();
            var comments = NeededObjectsFactory.GenerateComments();

            post.Comments.AddRange(comments);
            binder.Bind(post, form);
            post = new Post();

            binder.Bind(form, post);

            Assert.That(post.Comments.Count, Is.EqualTo(2));
            Assert.That(post.Comments.GetCommentByAuthor("Tom").Comments.Count, Is.EqualTo(1));
            Assert.That(post.Comments.GetCommentByAuthor("Tom").Comments[0].Comments.Count, Is.EqualTo(1));
            Assert.That(post.Comments.GetCommentByAuthor("Sam").Comments.Count, Is.EqualTo(1));
        }
コード例 #2
0
        public void When_binding_a_tree_view_to_aform()
        {
            var binder   = new Binder();
            var form     = new PostWithOptionsForm();
            var post     = NeededObjectsFactory.CreatePost();
            var comments = NeededObjectsFactory.GenerateComments();

            post.Comments.AddRange(comments);

            binder.Bind(post, form);

            var allNodes = form.Comments.GetAllNodesRecursive();
            var tags     = allNodes.Select(x => x.Tag);

            CollectionAssert.AllItemsAreNotNull(tags);
            Assert.That(form.Comments.Nodes.Count, Is.EqualTo(2));
            Assert.That(allNodes.GetNodeCommentByAuthor("Tom").Nodes.Count, Is.EqualTo(1));
            Assert.That(allNodes.GetNodeCommentByAuthor("Tom").Nodes[0].Nodes.Count, Is.EqualTo(1));
            Assert.That(allNodes.GetNodeCommentByAuthor("Sam").Nodes.Count, Is.EqualTo(1));
        }