I am using Web Forms MVP to write an DotNetNuke user control. When the 'SubmitContactUs' event is raised in my unit test the presenter attempts to set the 'Message' property on the Modal. However the View.Modal is null in the presenter.
Shouldn't the Web Forms MVP framework automatically build a new View.
Model object in the presenter? It could be that the 'Arrange' portion of my test is missing something that the presenter needs. Any help would be appreciated.
Here is my test:
using System;
using AthleticHost.ContactUs.Core.Presenters;
using AthleticHost.ContactUs.Core.Views;
using Xunit;
using Moq;
namespace AthleticHost.ContactUs.Tests
{
public class ContactUsPresenterTests
{
[Fact]
public void ContactUsPresenter_Sets_Message_OnSubmit()
{
// Arrange
var view = new Mock<IContactUsView>();
var presenter = new ContactUsPresenter(view.Object);
// Act
view.Raise(v => v.Load += null, new EventArgs());
view.Raise(v => v.SubmitContactUs += null,
new SubmitContactUsEventArgs("Chester", "Tester",
"
[email protected]", "http://www.test.com",
"This is a test of the emergancy broadcast system..."));
presenter.ReleaseView();
// Assert
Assert.Contains("Chester Tester", view.Object.
Model.Message);
}
}
}