Skip to content
Browse files

Updated

  • Loading branch information...
1 parent 4dd3d69 commit 771116afd6afbc42632c90fe3646529255764511 @developwithpassion developwithpassion committed May 17, 2012
View
50 source/app.specs/ViewAPageSpecs.cs
@@ -1,50 +0,0 @@
- using System;
- using Machine.Specifications;
- using app.web.application.catalogbrowsing;
- using app.web.core;
- using developwithpassion.specifications.rhinomocks;
- using developwithpassion.specifications.extensions;
-
-namespace app.specs
-{
- [Subject(typeof(ViewAPage<AReportModel>))]
- public class ViewAPageSpecs
- {
- public abstract class concern : Observes<ISupportAFeature,
- ViewAPage<AReportModel>>
- {
-
- }
-
-
- public class when_run : concern
- {
- Establish c = () =>
- {
- the_report_model = new AReportModel();
- depends.on<Func<IContainRequestDetails, AReportModel>>(x => the_report_model);
- display_engin = fake.an<IDisplayInformation>();
- depends.on(display_engin);
- };
-
- Because b = () =>
- {
- sut.process(model);
- };
-
-
- It should_display_specified_model = () =>
- {
- display_engin.received(x => x.display(the_report_model));
- };
-
- static IContainRequestDetails model;
- static AReportModel the_report_model;
- static IDisplayInformation display_engin;
- }
- }
-
- public class AReportModel
- {
- }
-}
View
53 source/app.specs/ViewASpecs.cs
@@ -0,0 +1,53 @@
+ using System;
+ using Machine.Specifications;
+ using app.web.application.catalogbrowsing;
+ using app.web.core;
+ using developwithpassion.specifications.rhinomocks;
+ using developwithpassion.specifications.extensions;
+
+namespace app.specs
+{
+ [Subject(typeof(ViewA<AReportModel>))]
+ public class ViewASpecs
+ {
+ public abstract class concern : Observes<ISupportAFeature,
+ ViewA<AReportModel>>
+ {
+
+ }
+
+
+ public class when_run : concern
+ {
+ Establish c = () =>
+ {
+ request = fake.an<IContainRequestDetails>();
+ the_report_model = new AReportModel();
+ query = depends.on<IFetchAn<AReportModel>>();
+ display_engine = fake.an<IDisplayInformation>();
+ depends.on(display_engine);
+
+
+ query.setup(x => x.run_using(request)).Return(the_report_model);
+ };
+
+ Because b = () =>
+ {
+ sut.process(request);
+ };
+
+
+ It should_display_the_model_found_using_the_query = () =>
+ display_engine.received(x => x.display(the_report_model));
+
+ static IContainRequestDetails request;
+ static AReportModel the_report_model;
+ static IDisplayInformation display_engine;
+ static IFetchAn<AReportModel> query;
+ }
+ }
+
+ public class AReportModel
+ {
+ }
+}
View
47 source/app.specs/ViewTheDepartmentsInADepartmentSpecs.cs
@@ -1,47 +0,0 @@
- using System.Collections.Generic;
- using Machine.Specifications;
- using app.web.application.catalogbrowsing;
- using app.web.core;
- using developwithpassion.specifications.rhinomocks;
- using developwithpassion.specifications.extensions;
-
-namespace app.specs
-{
- [Subject(typeof(ISupportAFeature))]
- public class ViewTheDepartmentsInADepartmentSpecs
- {
- public abstract class concern : Observes<ISupportAFeature,ViewTheDepartmentsInADepartment>
- {
-
- }
-
-
- public class when_run : concern
- {
- Establish c = () =>
- {
- department_repository = depends.on<IFindInformationAboutTheStore>();
- display_engine = depends.on<IDisplayInformation>();
- the_selected_department = new DepartmentSelection();
- request = fake.an<IContainRequestDetails>();
- sub_departments = new List<DepartmentDisplayItem>(){new DepartmentDisplayItem()};
-
- request.setup(x => x.map<DepartmentSelection>()).Return(the_selected_department);
- department_repository.setup(x => x.get_the_departments_in(the_selected_department)).Return(sub_departments);
- };
-
-
- Because b = () =>
- sut.process(request);
-
- It should_display_the_sub_departments = () =>
- display_engine.received(x => x.display(sub_departments));
-
- static IDisplayInformation display_engine;
- static DepartmentSelection the_selected_department;
- static IContainRequestDetails request;
- static IEnumerable<DepartmentDisplayItem> sub_departments;
- static IFindInformationAboutTheStore department_repository;
- }
- }
-}
View
50 source/app.specs/ViewTheMainDepartmentsInTheStoreSpecs.cs
@@ -1,50 +0,0 @@
-using System.Collections.Generic;
-using Machine.Specifications;
-using app.web.application.catalogbrowsing;
-using app.web.core;
-using developwithpassion.specifications.rhinomocks;
-using developwithpassion.specifications.extensions;
-
-namespace app.specs
-{
- [Subject(typeof(ViewTheMainDepartmentsInTheStore))]
- public class ViewTheMainDepartmentsInTheStoreSpecs
- {
- public abstract class concern : Observes<ISupportAFeature,
- ViewTheMainDepartmentsInTheStore>
- {
-
- }
-
-
- public class when_run : concern
- {
- Establish c = () =>
- {
- repository = depends.on<IFindInformationAboutTheStore>();
- display_engine = depends.on<IDisplayInformation>();
- request = fake.an<IContainRequestDetails>();
- main_departments = new List<DepartmentDisplayItem>() {new DepartmentDisplayItem()};
-
- repository.setup(x => x.get_the_main_departments_in_the_store()).Return(main_departments);
- };
-
- Because b = () =>
- sut.process(request);
-
- It should_get_the_main_departments = () =>
- {
-
- };
-
- It should_display_the_main_departments = () =>
- display_engine.received(x => x.display(main_departments));
-
-
- static IContainRequestDetails request;
- static IFindInformationAboutTheStore repository;
- static IEnumerable<DepartmentDisplayItem> main_departments;
- static IDisplayInformation display_engine;
- }
- }
-}
View
48 source/app.specs/ViewTheProductsInADepartmentSpecs.cs
@@ -1,48 +0,0 @@
- using System.Collections.Generic;
- using Machine.Specifications;
- using app.web.application.catalogbrowsing;
- using app.web.core;
- using developwithpassion.specifications.rhinomocks;
- using developwithpassion.specifications.extensions;
-
-namespace app.specs
-{
- [Subject(typeof(ViewTheProductsInADepartment))]
- public class ViewTheProductsInADepartmentSpecs
- {
- public abstract class concern : Observes<ISupportAFeature,ViewTheProductsInADepartment>
- {
-
- }
-
-
- public class when_run : concern
- {
- Establish c = () =>
- {
- product_repository = depends.on<IFindInformationAboutTheStore>();
- display_engine = depends.on<IDisplayInformation>();
- request_input_model = new ViewTheProductsInADepartmentRequest();
- request = fake.an<IContainRequestDetails>();
- products = new List<ProductDisplayItem>() {new ProductDisplayItem()};
-
- request.setup(x => x.map<ViewTheProductsInADepartmentRequest>()).Return(request_input_model);
- product_repository.setup(x => x.get_the_products_in(request_input_model)).Return(products);
- };
-
-
- Because b = () =>
- sut.process(request);
-
-
- It should_display_the_products = () =>
- display_engine.received(x => x.display(products));
-
- static IDisplayInformation display_engine;
- static ViewTheProductsInADepartmentRequest request_input_model;
- static IContainRequestDetails request;
- static IEnumerable<ProductDisplayItem> products;
- static IFindInformationAboutTheStore product_repository;
- }
- }
-}
View
5 source/app.specs/app.specs.csproj
@@ -123,10 +123,7 @@
<Compile Include="RequestProcessorRegistrySpecs.cs" />
<Compile Include="RequestProcessorSpecs.cs" />
<Compile Include="utility\ObjectFactory.cs" />
- <Compile Include="ViewAPageSpecs.cs" />
- <Compile Include="ViewTheDepartmentsInADepartmentSpecs.cs" />
- <Compile Include="ViewTheMainDepartmentsInTheStoreSpecs.cs" />
- <Compile Include="ViewTheProductsInADepartmentSpecs.cs" />
+ <Compile Include="ViewASpecs.cs" />
<Compile Include="WebFormDisplayEngineSpecs.cs" />
<Compile Include="WebFormViewRegistrySpecs.cs" />
</ItemGroup>
View
6 source/app/app.csproj
@@ -83,10 +83,7 @@
<Compile Include="web\application\catalogbrowsing\IFindInformationAboutTheStore.cs" />
<Compile Include="web\application\catalogbrowsing\ProductDisplayItem.cs" />
<Compile Include="web\application\catalogbrowsing\stubs\StubStoreCatalog.cs" />
- <Compile Include="web\application\catalogbrowsing\ViewAPage.cs" />
- <Compile Include="web\application\catalogbrowsing\ViewTheDepartmentsInADepartment.cs" />
- <Compile Include="web\application\catalogbrowsing\ViewTheMainDepartmentsInTheStore.cs" />
- <Compile Include="web\application\catalogbrowsing\ViewTheProductsInADepartment.cs" />
+ <Compile Include="web\application\catalogbrowsing\ViewA.cs" />
<Compile Include="web\application\catalogbrowsing\ViewTheProductsInADepartmentRequest.cs" />
<Compile Include="web\core\aspnet\ASPNetHandler.cs" />
<Compile Include="web\core\aspnet\CreatePage_Behaviour.cs" />
@@ -104,6 +101,7 @@
<Compile Include="web\core\IContainRequestDetails.cs" />
<Compile Include="web\core\ICreateRequests.cs" />
<Compile Include="web\core\IDisplayInformation.cs" />
+ <Compile Include="web\core\IFetchAn.cs" />
<Compile Include="web\core\IFindRequestProcessors.cs" />
<Compile Include="web\core\IProcessOneRequest.cs" />
<Compile Include="web\core\IProcessWebRequests.cs" />
View
26 source/app/web/application/catalogbrowsing/ViewA.cs
@@ -0,0 +1,26 @@
+using app.web.core;
+using app.web.core.aspnet;
+
+namespace app.web.application.catalogbrowsing
+{
+ public class ViewA<ReportModel> : ISupportAFeature
+ {
+ IFetchAn<ReportModel> query;
+ IDisplayInformation display_engine;
+
+ public ViewA(IFetchAn<ReportModel> query, IDisplayInformation display_engine)
+ {
+ this.query = query;
+ this.display_engine = display_engine;
+ }
+
+ public ViewA(IFetchAn<ReportModel> query):this(query,new WebFormDisplayEngine())
+ {
+ }
+
+ public void process(IContainRequestDetails request)
+ {
+ display_engine.display(query.run_using(request));
+ }
+ }
+}
View
32 source/app/web/application/catalogbrowsing/ViewAPage.cs
@@ -1,32 +0,0 @@
-using System;
-using app.web.core;
-using app.web.core.aspnet;
-
-namespace app.web.application.catalogbrowsing
-{
-
- public class ViewAPage<ReportModel> : ISupportAFeature
- {
- Func<IContainRequestDetails, ReportModel> accessor;
- IDisplayInformation display_engine;
-
-
-
- public ViewAPage(Func<IContainRequestDetails, ReportModel> accessor) : this(accessor , new WebFormDisplayEngine())
- {
- }
-
- public ViewAPage(Func<IContainRequestDetails, ReportModel> accessor, IDisplayInformation displayEngine)
- {
- this.accessor = accessor;
- display_engine = displayEngine;
- }
-
- public void process(IContainRequestDetails request)
- {
- display_engine.display(accessor(request));
- }
-
-
- }
-}
View
28 source/app/web/application/catalogbrowsing/ViewTheDepartmentsInADepartment.cs
@@ -1,28 +0,0 @@
-using app.web.application.catalogbrowsing.stubs;
-using app.web.core;
-using app.web.core.aspnet;
-
-namespace app.web.application.catalogbrowsing
-{
- public class ViewTheDepartmentsInADepartment : ISupportAFeature
- {
- IFindInformationAboutTheStore department_repository;
- IDisplayInformation display_engine;
-
- public ViewTheDepartmentsInADepartment(IFindInformationAboutTheStore department_repository,
- IDisplayInformation display_engine)
- {
- this.department_repository = department_repository;
- this.display_engine = display_engine;
- }
-
- public ViewTheDepartmentsInADepartment() : this(new StubStoreCatalog(), new WebFormDisplayEngine())
- {
- }
-
- public void process(IContainRequestDetails request)
- {
- display_engine.display(department_repository.get_the_departments_in(request.map<DepartmentSelection>()));
- }
- }
-}
View
29 source/app/web/application/catalogbrowsing/ViewTheMainDepartmentsInTheStore.cs
@@ -1,29 +0,0 @@
-using app.web.application.catalogbrowsing.stubs;
-using app.web.core;
-using app.web.core.aspnet;
-
-namespace app.web.application.catalogbrowsing
-{
- public class ViewTheMainDepartmentsInTheStore : ISupportAFeature
- {
- IFindInformationAboutTheStore store_catalog;
- IDisplayInformation display_engine;
-
- public ViewTheMainDepartmentsInTheStore(IFindInformationAboutTheStore store_catalog,
- IDisplayInformation display_engine)
- {
- this.store_catalog = store_catalog;
- this.display_engine = display_engine;
- }
-
- public ViewTheMainDepartmentsInTheStore() : this(new StubStoreCatalog(),
- new WebFormDisplayEngine())
- {
- }
-
- public void process(IContainRequestDetails request)
- {
- display_engine.display(store_catalog.get_the_main_departments_in_the_store());
- }
- }
-}
View
29 source/app/web/application/catalogbrowsing/ViewTheProductsInADepartment.cs
@@ -1,29 +0,0 @@
-using app.web.application.catalogbrowsing.stubs;
-using app.web.core;
-using app.web.core.aspnet;
-
-namespace app.web.application.catalogbrowsing
-{
- public class ViewTheProductsInADepartment : ISupportAFeature
- {
- IFindInformationAboutTheStore product_repository;
- IDisplayInformation display_engine;
-
- public ViewTheProductsInADepartment(IFindInformationAboutTheStore product_repository,
- IDisplayInformation display_engine)
- {
- this.product_repository = product_repository;
- this.display_engine = display_engine;
- }
-
- public ViewTheProductsInADepartment() : this(new StubStoreCatalog(), new WebFormDisplayEngine())
- {
- }
-
- public void process(IContainRequestDetails request)
- {
- display_engine.display(
- product_repository.get_the_products_in(request.map<ViewTheProductsInADepartmentRequest>()));
- }
- }
-}
View
7 source/app/web/core/IFetchAn.cs
@@ -0,0 +1,7 @@
+namespace app.web.core
+{
+ public interface IFetchAn<ReportModel>
+ {
+ ReportModel run_using(IContainRequestDetails request);
+ }
+}
View
38 source/app/web/core/stubs/StubSetOfProcessors.cs
@@ -2,7 +2,6 @@
using System.Collections.Generic;
using app.web.application.catalogbrowsing;
using app.web.application.catalogbrowsing.stubs;
-using app.web.core.aspnet;
namespace app.web.core.stubs
{
@@ -15,31 +14,30 @@ IEnumerator IEnumerable.GetEnumerator()
public IEnumerator<IProcessOneRequest> GetEnumerator()
{
- var storeCatalog = new StubStoreCatalog();
yield return
new RequestProcessor(x => true,
- new ViewAPage<IEnumerable<DepartmentDisplayItem>>(
- request =>
- storeCatalog.get_the_main_departments_in_the_store()));
+ new ViewA<IEnumerable<DepartmentDisplayItem>>(new GetTheMainDepartmentsInTheStore()))
+ ;
yield return
new RequestProcessor(x => true,
- new ViewAPage<IEnumerable<DepartmentDisplayItem>>(
- request =>
- storeCatalog.get_the_departments_in(
- request.map<DepartmentSelection>())));
-
- yield return
- new RequestProcessor(x => true,
- new ViewAPage<IEnumerable<ProductDisplayItem>>(
- request =>
- storeCatalog.get_the_products_in(
- request.map<ViewTheProductsInADepartmentRequest>())));
+ new ViewA<IEnumerable<ProductDisplayItem>>(new GetTheProductsInADepartment()))
+ ;
+ }
+ }
- yield return new RequestProcessor(x => true, new ViewTheProductsInADepartment());
+ public class GetTheProductsInADepartment : IFetchAn<IEnumerable<ProductDisplayItem>>
+ {
+ public IEnumerable<ProductDisplayItem> run_using(IContainRequestDetails request)
+ {
+ return new StubStoreCatalog().get_the_products_in(request.map<ViewTheProductsInADepartmentRequest>());
+ }
+ }
- yield return new RequestProcessor(x => true, new ViewTheProductsInADepartment());
- yield return new RequestProcessor(x => true, new ViewTheMainDepartmentsInTheStore());
- yield return new RequestProcessor(x => true, new ViewTheDepartmentsInADepartment());
+ public class GetTheMainDepartmentsInTheStore : IFetchAn<IEnumerable<DepartmentDisplayItem>>
+ {
+ public IEnumerable<DepartmentDisplayItem> run_using(IContainRequestDetails request)
+ {
+ return new StubStoreCatalog().get_the_main_departments_in_the_store();
}
}
}

0 comments on commit 771116a

Please sign in to comment.
Something went wrong with that request. Please try again.