public void PollPassedToDetailsView() { // Arrange var fakeDB = new FakePollContext(); fakeDB.Polls = new FakePollSet(); var poll = new Poll { ID = 1, Title = "Hello" }; fakeDB.Polls.Add(poll); var poll2 = new Poll { ID = 2, Title = "world" }; fakeDB.Polls.Add(poll2); PollsController controller = new PollsController(fakeDB); // Act ViewResult result = controller.Details(1) as ViewResult; DetailsPollViewModel resultPoll = result.ViewData.Model as DetailsPollViewModel; // Assert Assert.AreEqual(resultPoll.Poll.Title, "Hello"); // Act ViewResult result2 = controller.Details(2) as ViewResult; DetailsPollViewModel resultPoll2 = result2.ViewData.Model as DetailsPollViewModel; // Assert Assert.AreEqual(resultPoll2.Poll.Title, "world"); }
public void Details_ValidRequest_ShouldReturnDetailsView() { var result = _pollsController.Details(1) as ViewResult; result.Should().NotBe(null); result.Should().BeOfType <ViewResult>(); }