summaryrefslogtreecommitdiff
path: root/slips/src/test/Marina.Test/Unit/Web/Views/ViewTest.cs
blob: a3b2d084056d5152246b52b33488bc0a937988d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using Marina.Web.Http;
using Marina.Web.Views;
using MbUnit.Framework;
using Rhino.Mocks;
using Rhino.Mocks.Constraints;

namespace Marina.Test.Unit.Web.Views {
	[TestFixture]
	public class ViewTest {
		private MockRepository _mockery;
		private string _pageName;
		private IHttpGateway _mockGateway;

		[SetUp]
		public void Setup() {
			_mockery = new MockRepository( );
			_mockGateway = _mockery.DynamicMock< IHttpGateway >( );
			_pageName = string.Empty;
		}

		public IView CreateSUT() {
			return new View( _pageName, _mockGateway );
		}

		[Test]
		public void Should_return_the_name_of_the_page_it_was_created_with() {
			_pageName = "TestPage.aspx";

			using ( _mockery.Record( ) ) {}

			using ( _mockery.Playback( ) ) {
				Assert.AreEqual( _pageName, CreateSUT( ).Name( ) );
			}
		}

		[Test]
		public void Should_redirect_to_page() {
			using ( _mockery.Record( ) ) {
				_mockGateway.RedirectTo( null );
				LastCall.Constraints( Is.NotNull( ) );
			}

			using ( _mockery.Playback( ) ) {
				CreateSUT( ).Render( );
			}
		}
	}
}