public void should_redirect_to_home_when_no_pages_exist() { // Arrange RandomPage randomPage = new RandomPage(new RandomMock()); randomPage.PageService = _container.PageService; // Act RedirectToRouteResult redirectResult = randomPage.GetResult(_controller) as RedirectToRouteResult; // Assert Assert.That(redirectResult, Is.Not.Null); Assert.That(redirectResult.RouteValues["controller"], Is.EqualTo("Home")); Assert.That(redirectResult.RouteValues["action"], Is.EqualTo("Index")); }
public void should_redirect_to_correct_controller_using_random() { // Arrange _container.PageRepository.AddNewPage(new Page() { Id = 1, Title = "1" }, "text", "", DateTime.Now); _container.PageRepository.AddNewPage(new Page() { Id = 2, Title = "2" }, "text", "", DateTime.Now); _container.PageRepository.AddNewPage(new Page() { Id = 3, Title = "3" }, "text", "", DateTime.Now); _container.PageRepository.AddNewPage(new Page() { Id = 4, Title = "4" }, "text", "", DateTime.Now); _container.PageRepository.AddNewPage(new Page() { Id = 5, Title = "5" }, "text", "", DateTime.Now); RandomPage randomPage = new RandomPage(new RandomMock()); randomPage.PageService = _container.PageService; // Act RedirectToRouteResult redirectResult = randomPage.GetResult(_controller) as RedirectToRouteResult; // Assert Assert.That(redirectResult, Is.Not.Null); Assert.That(redirectResult.RouteValues["controller"], Is.EqualTo("Wiki")); Assert.That(redirectResult.RouteValues["action"], Is.EqualTo("Index")); Assert.That(redirectResult.RouteValues["id"], Is.EqualTo(4)); // 4 as it's zero based }