public void When_binding_a_form_to_an_object() { var binder = new Binder(); var form = NeededObjectsFactory.CreateForm(); var post = new Post(); binder.Bind(form, post); Assert.That(post.Title, Is.EqualTo(TestVariables.Title)); Assert.That(post.Author, Is.EqualTo(TestVariables.Author)); Assert.That(post.Date, Is.EqualTo(TestVariables.Posted)); Assert.That(post.Body, Is.EqualTo(TestVariables.Body)); }
public void When_binding_a_form_to_an_object_with_aliases() { var binder = new Binder(); var aliases = new List<BindaAlias> { new BindaAlias("Location", "PostLocation") }; var form = NeededObjectsFactory.CreateForm(); form.PostLocation.Text = TestVariables.Location; var post = new Post(); binder.Bind(form, post, aliases); Assert.That(post.Title, Is.EqualTo(TestVariables.Title)); Assert.That(post.Author, Is.EqualTo(TestVariables.Author)); Assert.That(post.Date, Is.EqualTo(TestVariables.Posted)); Assert.That(post.Body, Is.EqualTo(TestVariables.Body)); Assert.That(post.Location, Is.EqualTo(TestVariables.Location)); }
public void When_binding_a_prefix_form_to_an_object_with_custom_registrations() { var binder = new Binder(); binder.AddControlPrefix(new HungarianNotationControlPrefix()); binder.AddRegistration(typeof(FluxCapacitor), "PopularityRanking"); var form = NeededObjectsFactory.CreatePrefixForm(); form.fcPopularityRanking.PopularityRanking = TestVariables.PopularityRanking; var post = new Post(); binder.Bind(form, post); Assert.That(post.Title, Is.EqualTo(TestVariables.Title)); Assert.That(post.Author, Is.EqualTo(TestVariables.Author)); Assert.That(post.Date, Is.EqualTo(TestVariables.Posted)); Assert.That(post.Body, Is.EqualTo(TestVariables.Body)); Assert.That(post.PopularityRanking, Is.EqualTo(TestVariables.PopularityRanking)); }
public void When_binding_a_prefix_form_to_an_object() { var binder = new Binder(); binder.AddControlPrefix(new HungarianNotationControlPrefix()); var form = NeededObjectsFactory.CreatePrefixForm(); var post = new Post(); binder.Bind(form, post); Assert.That(post.Title, Is.EqualTo(TestVariables.Title)); Assert.That(post.Author, Is.EqualTo(TestVariables.Author)); Assert.That(post.Date, Is.EqualTo(TestVariables.Posted)); Assert.That(post.Body, Is.EqualTo(TestVariables.Body)); }
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)); }
public void When_binding_a_form_to_an_object_with_custom_control_registrations() { var binder = new Binder(); var form = NeededObjectsFactory.CreateForm(); var strategy = new TestBindaStrategy(); binder.AddRegistration(strategy, form.Title); strategy.GetValue = "Good Title"; binder.AddRegistration(typeof (TextBox), "Text"); form.Title.Text = "Bad Title"; var post = new Post(); binder.Bind(form, post); Assert.That(post.Title, Is.EqualTo(strategy.GetValue)); }