コード例 #1
0
ファイル: RandomPageTests.cs プロジェクト: 35e8/roadkill
		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"));
		}
コード例 #2
0
        public void Should_Redirect_To_Correct_Controller_Using_Random()
        {
            // Arrange
            _container.Repository.AddNewPage(new Page() { Id = 1, Title = "1" }, "text", "", DateTime.Now);
            _container.Repository.AddNewPage(new Page() { Id = 2, Title = "2" }, "text", "", DateTime.Now);
            _container.Repository.AddNewPage(new Page() { Id = 3, Title = "3" }, "text", "", DateTime.Now);
            _container.Repository.AddNewPage(new Page() { Id = 4, Title = "4" }, "text", "", DateTime.Now);
            _container.Repository.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
        }