summaryrefslogtreecommitdiff
path: root/slips/src/test/Marina.Test/Unit/Web
diff options
context:
space:
mode:
authormokhan <mokhan@da190166-9cfc-4ee1-ae03-434a172be219>2009-02-21 21:44:27 +0000
committermokhan <mokhan@da190166-9cfc-4ee1-ae03-434a172be219>2009-02-21 21:44:27 +0000
commit1dfdccb8118aeaa3cd844ac8de2a672c93312166 (patch)
tree4b19e7f816ab1019f180a46b68572af4b66fe4bc /slips/src/test/Marina.Test/Unit/Web
parent42d66bcab8262c7b8b2452615df535e694a3ec1c (diff)
git-svn-id: http://svn.xp-dev.com/svn/mokhan-sait@2 da190166-9cfc-4ee1-ae03-434a172be219
Diffstat (limited to 'slips/src/test/Marina.Test/Unit/Web')
-rw-r--r--slips/src/test/Marina.Test/Unit/Web/Commands/AvailableSlipsCommandTest.cs56
-rw-r--r--slips/src/test/Marina.Test/Unit/Web/Handlers/RequestHandlerSpecificationTest.cs53
-rw-r--r--slips/src/test/Marina.Test/Unit/Web/Handlers/RequestHandlerTest.cs49
-rw-r--r--slips/src/test/Marina.Test/Unit/Web/Views/Pages/AvailableSlipsWebViewTest.cs49
-rw-r--r--slips/src/test/Marina.Test/Unit/Web/Views/ViewTest.cs48
5 files changed, 255 insertions, 0 deletions
diff --git a/slips/src/test/Marina.Test/Unit/Web/Commands/AvailableSlipsCommandTest.cs b/slips/src/test/Marina.Test/Unit/Web/Commands/AvailableSlipsCommandTest.cs
new file mode 100644
index 0000000..c3ca810
--- /dev/null
+++ b/slips/src/test/Marina.Test/Unit/Web/Commands/AvailableSlipsCommandTest.cs
@@ -0,0 +1,56 @@
+using System.Collections.Generic;
+using Marina.Infrastructure;
+using Marina.Presentation.DTO;
+using Marina.Task;
+using Marina.Web.Commands;
+using Marina.Web.Views.Pages;
+using MbUnit.Framework;
+using Rhino.Mocks;
+
+namespace Marina.Test.Unit.Web.Commands {
+ [TestFixture]
+ public class AvailableSlipsCommandTest {
+ private MockRepository _mockery;
+ private ICatalogTasks _mockTask;
+ private IAvailableSlipsWebView _mockView;
+
+ [SetUp]
+ public void Setup() {
+ _mockery = new MockRepository( );
+ _mockTask = _mockery.DynamicMock< ICatalogTasks >( );
+ _mockView = _mockery.DynamicMock< IAvailableSlipsWebView >( );
+ }
+
+ private ICommand CreateSUT() {
+ return new AvailableSlipsCommand( _mockView, _mockTask );
+ }
+
+ [Test]
+ public void Should_leverage_task_to_retrieve_all_available_slips_on_initialize() {
+ using ( _mockery.Record( ) ) {
+ Expect.Call( _mockTask.GetAllAvailableSlips( ) ).Return( null );
+ }
+
+ using ( _mockery.Playback( ) ) {
+ CreateSUT( ).Execute( );
+ }
+ }
+
+ [Test]
+ public void Should_add_available_slips_to_bag_and_render_view() {
+ IEnumerable< SlipDisplayDTO > slips = new List< SlipDisplayDTO >( );
+
+ using ( _mockery.Record( ) ) {
+ SetupResult.For( _mockTask.GetAllAvailableSlips( ) ).Return( slips );
+ using ( _mockery.Ordered( ) ) {
+ _mockView.AddToBag( slips );
+ _mockView.Render( );
+ }
+ }
+
+ using ( _mockery.Playback( ) ) {
+ CreateSUT( ).Execute( );
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/test/Marina.Test/Unit/Web/Handlers/RequestHandlerSpecificationTest.cs b/slips/src/test/Marina.Test/Unit/Web/Handlers/RequestHandlerSpecificationTest.cs
new file mode 100644
index 0000000..8b6c4fd
--- /dev/null
+++ b/slips/src/test/Marina.Test/Unit/Web/Handlers/RequestHandlerSpecificationTest.cs
@@ -0,0 +1,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 );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/test/Marina.Test/Unit/Web/Handlers/RequestHandlerTest.cs b/slips/src/test/Marina.Test/Unit/Web/Handlers/RequestHandlerTest.cs
new file mode 100644
index 0000000..b4a15ef
--- /dev/null
+++ b/slips/src/test/Marina.Test/Unit/Web/Handlers/RequestHandlerTest.cs
@@ -0,0 +1,49 @@
+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 RequestHandlerTest {
+ private MockRepository _mockery;
+ private ISpecification< IHttpGateway > _mockSpecification;
+ private ICommand _mockCommand;
+
+ [SetUp]
+ public void Setup( ) {
+ _mockery = new MockRepository( );
+ _mockSpecification = _mockery.DynamicMock< ISpecification< IHttpGateway > >( );
+ _mockCommand = _mockery.DynamicMock< ICommand >( );
+ }
+
+ [Test]
+ public void Should_delegate_to_specification_to_see_if_criteria_is_satisfied( ) {
+ IHttpGateway request = _mockery.DynamicMock< IHttpGateway >( );
+
+ using ( _mockery.Record( ) ) {
+ Expect.Call( _mockSpecification.IsSatisfiedBy( request ) ).Return( true );
+ }
+
+ using ( _mockery.Playback( ) ) {
+ CreateSUT( ).IsSatisfiedBy( request );
+ }
+ }
+
+ [Test]
+ public void Should_delegate_to_command_when_told_to_execute( ) {
+ using ( _mockery.Record( ) ) {
+ _mockCommand.Execute( );
+ }
+
+ using ( _mockery.Playback( ) ) {
+ CreateSUT( ).Execute( );
+ }
+ }
+
+ private IRequestHandler CreateSUT( ) {
+ return new RequestHandler( _mockSpecification, _mockCommand );
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/test/Marina.Test/Unit/Web/Views/Pages/AvailableSlipsWebViewTest.cs b/slips/src/test/Marina.Test/Unit/Web/Views/Pages/AvailableSlipsWebViewTest.cs
new file mode 100644
index 0000000..2a40745
--- /dev/null
+++ b/slips/src/test/Marina.Test/Unit/Web/Views/Pages/AvailableSlipsWebViewTest.cs
@@ -0,0 +1,49 @@
+using System.Collections.Generic;
+using Marina.Presentation.DTO;
+using Marina.Web.Http;
+using Marina.Web.Views;
+using Marina.Web.Views.Pages;
+using MbUnit.Framework;
+using Rhino.Mocks;
+
+namespace Marina.Test.Unit.Web.Views.Pages {
+ [TestFixture]
+ public class AvailableSlipsWebViewTest {
+ private MockRepository _mockery;
+ private IViewLuggageTransporter< IEnumerable< SlipDisplayDTO > > _mockViewBag;
+ private IHttpGateway _mockGateway;
+
+ [SetUp]
+ public void Setup() {
+ _mockery = new MockRepository( );
+ _mockViewBag = _mockery.DynamicMock< IViewLuggageTransporter< IEnumerable< SlipDisplayDTO > > >( );
+ _mockGateway = _mockery.DynamicMock< IHttpGateway >( );
+ }
+
+ public IAvailableSlipsWebView CreateSUT() {
+ return new AvailableSlipsWebView( _mockViewBag, _mockGateway );
+ }
+
+ [Test]
+ public void Should_add_item_to_view_bag() {
+ IEnumerable< SlipDisplayDTO > slips = new List< SlipDisplayDTO >( );
+
+ using ( _mockery.Record( ) ) {
+ _mockViewBag.Add( slips );
+ }
+
+ using ( _mockery.Playback( ) ) {
+ CreateSUT( ).AddToBag( slips );
+ }
+ }
+
+ [Test]
+ public void Should_return_the_name_of_the_page() {
+ using ( _mockery.Record( ) ) {}
+
+ using ( _mockery.Playback( ) ) {
+ Assert.AreEqual( "AvailableSlips.aspx", CreateSUT( ).Name( ) );
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/slips/src/test/Marina.Test/Unit/Web/Views/ViewTest.cs b/slips/src/test/Marina.Test/Unit/Web/Views/ViewTest.cs
new file mode 100644
index 0000000..a3b2d08
--- /dev/null
+++ b/slips/src/test/Marina.Test/Unit/Web/Views/ViewTest.cs
@@ -0,0 +1,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( );
+ }
+ }
+ }
+} \ No newline at end of file