Commit ba82974
Changed files (5)
src
MVPtoMVVM.mvp
MVPtoMVVM.test
src/MVPtoMVVM.mvp/presenters/TodoItemPresenter.cs
@@ -88,7 +88,9 @@ namespace MVPtoMVVM.presenters
{
view.SaveButtonEnabled = IsDirty && IsDescriptionValid() && IsDueDateValid();
view.DescriptionHasValidationErrors = !IsDescriptionValid();
+ view.DescriptionValidationMessage = GetDescriptionValidationMessage();
view.DueDateHasValidationErrors = !IsDueDateValid();
+ view.DueDateValidationMessage = GetDueDateValidationMessage();
view.IsDueSoon = IsDueSoon();
}
@@ -106,5 +108,15 @@ namespace MVPtoMVVM.presenters
{
return dueDate <= DateTime.Today.AddDays(1);
}
+
+ private string GetDescriptionValidationMessage()
+ {
+ return IsDescriptionValid() ? null : "You must enter a description";
+ }
+
+ private string GetDueDateValidationMessage()
+ {
+ return IsDueDateValid() ? null : "Due Date must be today or later";
+ }
}
}
\ No newline at end of file
src/MVPtoMVVM.mvp/views/ITodoItemView.cs
@@ -14,6 +14,8 @@ namespace MVPtoMVVM.views
bool DescriptionHasValidationErrors { set; }
bool DueDateHasValidationErrors { set; }
bool IsDueSoon { set; }
+ string DescriptionValidationMessage { set; }
+ string DueDateValidationMessage { set; }
void Remove(int itemId);
}
}
\ No newline at end of file
src/MVPtoMVVM.mvp/Bootstrap.cs
@@ -1,4 +1,5 @@
using MVPtoMVVM.domain;
+using MVPtoMVVM.presenters;
using StructureMap;
namespace MVPtoMVVM.mvp
@@ -11,6 +12,7 @@ namespace MVPtoMVVM.mvp
x.Scan(scanner =>
{
scanner.AssemblyContainingType(typeof(TodoItem));
+ scanner.AssemblyContainingType(typeof(TodoItemPresenter));
scanner.WithDefaultConventions();
})
);
src/MVPtoMVVM.mvp/TodoItemView.xaml.cs
@@ -1,6 +1,5 @@
using System;
using System.Windows;
-using System.Windows.Controls;
using System.Windows.Media;
using MVPtoMVVM.presenters;
using MVPtoMVVM.views;
@@ -91,6 +90,16 @@ namespace MVPtoMVVM.mvp
set { dueSoonAlert.Visibility = value ? Visibility.Visible : Visibility.Hidden; }
}
+ public string DescriptionValidationMessage
+ {
+ set { description.ToolTip = value; }
+ }
+
+ public string DueDateValidationMessage
+ {
+ set { dueDate.ToolTip = value; }
+ }
+
public void Remove(int itemId)
{
parent.Remove(itemId);
src/MVPtoMVVM.test/mvp/BootStrapperTest.cs
@@ -1,3 +1,4 @@
+using System;
using MVPtoMVVM.mvp;
using MVPtoMVVM.repositories;
using NUnit.Framework;
@@ -18,7 +19,7 @@ namespace MVPtoMVVM.test.mvp
[Test]
public void it_should_register_the_repository()
{
- ObjectFactory.WhatDoIHave();
+ Console.Out.WriteLine(ObjectFactory.WhatDoIHave());
Assert.That(ObjectFactory.GetInstance<ITodoItemRepository>(), Is.TypeOf<TodoItemRepository>());
}
}