Commits

Joel Ross committed 16dc8cb

Adding setting of title for the add / edit view based on a new project or not

  • Participants
  • Parent commits e10b511

Comments (0)

Files changed (4)

File src/Core/Presenters/EditProjectPresenter.cs

         public void SetProject(Project projectToEdit)
         {
             project = projectToEdit;
+            View.SetupForProject(!project.Id.HasValue || project.Id.Value <= 0);
             View.ProjectName = project.Name;
             View.ProjectUrl = project.Url;
             View.Username = project.Username;

File src/Core/Presenters/Views/IEditProjectView.cs

         string Username { get; set; }
         string Password { get; set; }
         event VoidHandler SaveProject;
+        void SetupForProject(bool isNew);
     }
 }

File src/Tests/Presenters/EditProjectPresenterSpecs.cs

 {
     public static class EditProjectPresenterSpecs
     {
-        public class when_an_edit_is_requested : under.the_default_context
+        public class when_an_add_is_requested : under.the_default_context
         {
             protected override void When()
             {
                 View.VerifySet(v => v.ProjectUrl = It.IsAny<string>());
                 View.VerifySet(v => v.Username = It.IsAny<string>());
                 View.VerifySet(v => v.Password = It.IsAny<string>());
-            } 
+            }
+
+            [Test]
+            public void it_should_set_the_view_as_new()
+            {
+                View.Verify(v => v.SetupForProject(true));
+            }
+        }
+
+        public class when_an_edit_is_requested : under.the_default_context
+        {
+            protected override void When()
+            {
+                SUT.SetProject(new Project{ Id = 12 });
+            }
+
+            [Test]
+            public void it_should_set_the_view_as_not_new()
+            {
+                View.Verify(v => v.SetupForProject(false));
+            }
         }
 
         public class when_the_view_wants_to_save_a_project : under.the_default_context

File src/UI/EditProjectView.cs

         }
 
         public event VoidHandler SaveProject = delegate { };
+        
+        public void SetupForProject(bool isNew)
+        {
+            Text = isNew ? "Add Project" : "Edit Project";
+        }
     }
 }