public void GivenSomeQuestionsAndNoDisplayNameAndNoTags_Index_ReturnsAJsonViewOfMostRecentQuestions()
{
using (IDocumentSession documentSession = DocumentStore.OpenSession())
{
// Arrange.
var homeController = new HomeController(documentSession);
ControllerUtilities.SetUpControllerContext(homeController);
// Act.
// Note: this should return a list of the 20 most recent.
JsonResult result = homeController.IndexJson(null, null);
// Assert.
Assert.NotNull(result);
var questions = result.Data as IList<QuestionWithDisplayName>;
Assert.NotNull(questions);
Assert.Equal(20, questions.Count);
// Now lets Make sure each one is ok.
DateTime? previousDate = null;
foreach (var question in questions)
{
if (previousDate.HasValue)
{
Assert.True(previousDate.Value > question.CreatedOn);
}
previousDate = question.CreatedOn;
Assert.NotNull(question.DisplayName);
Assert.NotNull(question.Id);
Assert.NotNull(question.CreatedByUserId);
Assert.NotNull(question.Subject);
Assert.NotNull(question.Content);
}
}
}