Added another test.

pull/1135/head
Steve Smith 2016-03-12 00:01:22 -05:00
parent 06d923fd05
commit 82fe3ad532
1 changed files with 17 additions and 0 deletions

View File

@ -35,6 +35,23 @@ namespace TestingControllerSample.Tests.UnitTests
Assert.Equal("Session not found.", result.Content);
}
[Fact]
public void ReturnsViewResultWithStormSessionViewModel()
{
var mockRepo = new Mock<IBrainStormSessionRepository>();
int testSessionId = 1;
mockRepo.Setup(r => r.GetById(testSessionId))
.Returns(GetTestSessions().FirstOrDefault(s => s.Id == testSessionId));
var controller = new SessionController(mockRepo.Object);
var result = Assert.IsType<ViewResult>(controller.Index(testSessionId));
var model = Assert.IsType<StormSessionViewModel>(result.ViewData.Model);
Assert.Equal("Test One", model.Name);
Assert.Equal(2, model.DateCreated.Day);
Assert.Equal(testSessionId, model.Id);
}
private List<BrainStormSession> GetTestSessions()
{
var sessions = new List<BrainStormSession>();