summaryrefslogtreecommitdiff
path: root/slips/src/test/Marina.Test/Unit/Web/Handlers/RequestHandlerSpecificationTest.cs
blob: 8b6c4fd7b1dbb693622ae246fe3e80521128164d (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
49
50
51
52
53
using Marina.Infrastructure;
using Marina.Web.Handlers;
using Marina.Web.Http;
using MbUnit.Framework;
using Rhino.Mocks;

namespace Marina.Test.Unit.Web.Handlers {
	[TestFixture]
	public class RequestHandlerSpecificationTest {
		private MockRepository _mockery;

		[SetUp]
		public void Setup( ) {
			_mockery = new MockRepository( );
		}

		[TearDown]
		public void TearDown( ) {
			_mockery.VerifyAll( );
		}

		[Test]
		public void Should_return_true_if_destination_contains_command_name( ) {
			IHttpGateway mockRequest = _mockery.DynamicMock< IHttpGateway >( );
			string commandName = "test.marina";
			using ( _mockery.Record( ) ) {
				SetupResult.For( mockRequest.Destination( ) ).Return( commandName );
			}

			using ( _mockery.Playback( ) ) {
				Assert.IsTrue( CreateSUT( commandName ).IsSatisfiedBy( mockRequest ) );
			}
		}

		[Test]
		public void Should_return_false_if_destination_does_not_contain_command_name( ) {
			IHttpGateway mockRequest = _mockery.DynamicMock< IHttpGateway >( );
			string firstCommandName = "test.marina";
			string secondCommandName = "test2.marina";

			using ( _mockery.Record( ) ) {
				SetupResult.For( mockRequest.Destination( ) ).Return( secondCommandName );
			}
			using ( _mockery.Playback( ) ) {
				Assert.IsFalse( CreateSUT( firstCommandName ).IsSatisfiedBy( mockRequest ) );
			}
		}

		private ISpecification< IHttpGateway > CreateSUT( string commandName ) {
			return new RequestHandlerSpecification( commandName );
		}
	}
}