Ejemplo n.º 1
0
        public void When_binding_an_object_to_aform_using_prefixes_withaliases()
        {
            var binder = new Binder();

            binder.AddControlPrefix(new HungarianNotationControlPrefix());
            var form    = new MySamplePrefixForm();
            var aliases = new List <BindaAlias> {
                new BindaAlias("Location", "PostLocation")
            };
            var post = NeededObjectsFactory.CreatePost();

            binder.Bind(post, form, aliases);

            Assert.That(form.txtTitle.Text, Is.EqualTo(TestVariables.Title));
            Assert.That(form.txtAuthor.Text, Is.EqualTo(TestVariables.Author));
            Assert.That(form.dpDate.Value, Is.EqualTo(TestVariables.Posted));
            Assert.That(form.txtBody.Text, Is.EqualTo(TestVariables.Body));
            Assert.That(form.txtPostLocation.Text, Is.EqualTo(TestVariables.Location));
        }
Ejemplo n.º 2
0
        public void When_binding_an_oject_to_aform_using_prefixes_with_custom_registrations()
        {
            var binder = new Binder();

            binder.AddControlPrefix(new HungarianNotationControlPrefix());
            binder.AddRegistration(typeof(FluxCapacitor), "PopularityRanking");
            var form = new MySamplePrefixForm();
            var post = NeededObjectsFactory.CreatePost();

            post.PopularityRanking = TestVariables.PopularityRanking;

            binder.Bind(post, form);

            Assert.That(form.txtTitle.Text, Is.EqualTo(TestVariables.Title));
            Assert.That(form.txtAuthor.Text, Is.EqualTo(TestVariables.Author));
            Assert.That(form.dpDate.Value, Is.EqualTo(TestVariables.Posted));
            Assert.That(form.txtBody.Text, Is.EqualTo(TestVariables.Body));
            Assert.That(form.fcPopularityRanking.PopularityRanking, Is.EqualTo(TestVariables.PopularityRanking));
        }