public void FillControllerIndexWithIdShouldRedirectToFillingForm() { // Arrange var expectedAction = "Template"; var expectedController = "Form"; var expectedFormId = Guid.NewGuid(); // Setup Mock Session Service var sessionServiceMock = new FillingSessionServiceMother().GetMockedService(); var session = new FillingSessionMother().GetBasicSession(); var expectedSessionId = session.Id; sessionServiceMock.Setup(s => s.StartNewSession()).Returns(session); var controller = new FillController(sessionServiceMock.Object); // Act var actual = controller.Index(expectedFormId) as RedirectToRouteResult; // Assert Assert.IsNotNull(actual); Assert.AreEqual(expectedAction, actual.RouteValues["action"].ToString()); Assert.AreEqual(expectedController, actual.RouteValues["controller"].ToString()); Assert.AreEqual(expectedFormId, actual.RouteValues["formId"]); Assert.AreEqual(expectedSessionId, actual.RouteValues["sid"]); sessionServiceMock.Verify(s => s.StartNewSession()); }
public void FillControllerIndexWithoutIdShouldRedirectToHome() { // Arrange var expectedAction = "Index"; var expectedController = "Home"; // Setup Mock Session Service var sessionServiceMock = new FillingSessionServiceMother().GetMockedService(); var controller = new FillController(sessionServiceMock.Object); // Act var actual = controller.Index(null) as RedirectToRouteResult; // Assert Assert.IsNotNull(actual); Assert.AreEqual(expectedAction, actual.RouteValues["action"].ToString()); Assert.AreEqual(expectedController, actual.RouteValues["controller"].ToString()); }