BindaTests.Tests.BindingFormToObjectTests.When_binding_a_form_to_an_object_with_a_collection_and_item_bound_to_a_list_control C# (CSharp) Method

When_binding_a_form_to_an_object_with_a_collection_and_item_bound_to_a_list_control() private method

        public void When_binding_a_form_to_an_object_with_a_collection_and_item_bound_to_a_list_control()
        {
            var binder = new Binder();
            var form = new PostWithOptionsForm();
            var post = NeededObjectsFactory.CreatePost();
            post.PublishStates.Add(new PublishState { State = "Published" });
            post.PublishStates.Add(new PublishState { State = "Reviewed" });
            post.PublishStates.Add(new PublishState { State = "Pending Review" });
            post.PublishStates.Add(new PublishState { State = "Draft" });
            post.PublishState = post.PublishStates[2];
            binder.Bind(post, form);
            var newState = post.PublishStates[0];
            form.PublishState.SelectedItem = newState;

            binder.Bind(form, post);

            Assert.That(post.PublishState, Is.EqualTo(newState));
        }