Permalink
Browse files

formatting

  • Loading branch information...
1 parent cd8c759 commit 25c1af7f4f6ccda2f3b826f470b0fc4201f1e191 @SlyNet SlyNet committed Dec 19, 2011
@@ -1,45 +0,0 @@
-using System.Web.Mvc;
-using Machine.Specifications;
-using RestfulRouting.Format;
-
-namespace RestfulRouting.Spec.Format.ResultExposal
-{
- [Subject(typeof(FormatResult))]
- public class When_ExposeActionResult_method_called_on_format_result
- {
- static FormatResult formatResult;
- static ActionResult returnedHtmlActionResult;
- static ActionResult returnedJsonActionResult;
- static ActionResult returnedJsActionResult;
- static ActionResult returnedCsvResult;
- static ActionResult returnedXmlActionResult;
-
- Establish context = () => {
- formatResult = new FormatResult(format => {
- format.Html = () => new ViewResult();
- format.Json = () => new JsonResult();
- format.Js = () => new JavaScriptResult();
- format.Xml = () => new ContentResult();
- format.Csv = () => new PartialViewResult();
- });
- };
-
- Because of = () => {
- returnedHtmlActionResult = formatResult.ExposeActionResult().Html();
- returnedJsonActionResult = formatResult.ExposeActionResult().Json();
- returnedJsActionResult = formatResult.ExposeActionResult().Js();
- returnedXmlActionResult = formatResult.ExposeActionResult().Xml();
- returnedCsvResult = formatResult.ExposeActionResult().Csv();
- };
-
- It should_return_associated_with_json_result = () => returnedHtmlActionResult.ShouldBeOfType<ViewResult>();
-
- It should_return_associated_with_html_result = () => returnedJsonActionResult.ShouldBeOfType<JsonResult>();
-
- It should_return_associated_with_js_result = () => returnedJsActionResult.ShouldBeOfType<JavaScriptResult>();
-
- It should_return_associated_with_xml_result = () => returnedXmlActionResult.ShouldBeOfType<ContentResult>();
-
- It should_return_associated_with_csv_result = () => returnedCsvResult.ShouldBeOfType<PartialViewResult>();
- }
-}
@@ -15,8 +15,9 @@ public class When_format_collection_has_no_appropriate_action_registered
static Exception exception;
Establish context = () => {
- var formats = new FormatCollection();
- formats.Json = () => new JsonResult();
+ var formats = new FormatCollection {
+ Json = () => new JsonResult()
+ };
exposer = new ActionResultExposer(formats);
};
@@ -27,6 +27,16 @@ public ActionResult Js()
return ExecuteAction(FormatCollection.JsKey);
}
+ public ActionResult Xml()
+ {
+ return ExecuteAction(FormatCollection.XmlKey);
+ }
+
+ public ActionResult Csv()
+ {
+ return ExecuteAction(FormatCollection.CsvKey);
+ }
+
private ActionResult ExecuteAction(string key)
{
if (!this.formatCollection.ContainsKey(key))
@@ -38,15 +48,5 @@ private ActionResult ExecuteAction(string key)
return this.formatCollection[key]();
}
-
- public ActionResult Xml()
- {
- return ExecuteAction(FormatCollection.XmlKey);
- }
-
- public ActionResult Csv()
- {
- return ExecuteAction(FormatCollection.CsvKey);
- }
}
}

0 comments on commit 25c1af7

Please sign in to comment.