Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

put actionless views back in place with integrated tests against the …

…Spark engine
  • Loading branch information...
commit ab790604e44cdf64421584a93c4ff4d0281ac5d0 1 parent bbbc2bd
@jeremydmiller jeremydmiller authored
View
7 src/FubuMVC.Core/Registration/DSL/ViewExpression.cs
@@ -5,6 +5,7 @@
using System.Collections.Generic;
using FubuMVC.Core.View.Activation;
using FubuMVC.Core.View.Attachment;
+using FubuMVC.Core.View.New;
namespace FubuMVC.Core.Registration.DSL
{
@@ -181,10 +182,8 @@ public void Configure(ViewBag bag, BehaviorGraph graph)
.Where(token => _viewTokenFilter(token))
.Each(token =>
{
- throw new NotImplementedException();
- var chain = graph.AddChain();
- //var output = token.ToBehavioralNode();
- //chain.AddToEnd(output);
+ var chain = BehaviorChain.ForWriter(new ViewNode(token));
+ graph.AddChain(chain);
_configureChain(chain, token);
});
View
14 src/FubuMVC.Core/Registration/Nodes/BehaviorChain.cs
@@ -275,7 +275,19 @@ public ActionCall LastCall()
/// <returns></returns>
public Type InputType()
{
- return this.OfType<IMayHaveInputType>().FirstValue(x => x.InputType());
+ var calls = this.OfType<IMayHaveInputType>();
+ if (calls.Any())
+ {
+ return calls.FirstValue(x => x.InputType());
+ }
+
+ // This is for chains with an actionless view
+ if (HasOutput())
+ {
+ return ResourceType();
+ }
+
+ return null;
}
/// <summary>
View
6 src/FubuMVC.Tests/Registration/Nodes/BehaviorChainTester.cs
@@ -663,6 +663,12 @@ public void the_writer_should_be_attached_to_the_output_node()
{
theChain.Output.Writers.Single().ShouldBeTheSameAs(theWriter);
}
+
+ [Test]
+ public void the_chain_can_still_decipher_its_input_type()
+ {
+ theChain.InputType().ShouldEqual(typeof (HtmlTag));
+ }
}
public class FakeInputNode : BehaviorNode, IMayHaveInputType
View
4 src/StoryTellerTesting/IntegrationTesting.csproj
@@ -125,6 +125,7 @@
<Compile Include="ViewEngines\HelloRazor\HelloRazorController.cs" />
<Compile Include="ViewEngines\HelloRazor\RazorEngineIntegrationTester.cs" />
<Compile Include="ViewEngines\HelloSpark\AirController.cs" />
+ <Compile Include="ViewEngines\HelloSpark\PartialsWithSparkIntegrationTester.cs" />
<Compile Include="ViewEngines\HelloSpark\SparkEngineIntegrationTester.cs" />
</ItemGroup>
<ItemGroup>
@@ -198,6 +199,9 @@
<Content Include="ViewEngines\HelloRazor\HelloPartial.cshtml" />
<Content Include="ViewEngines\HelloRazor\HelloWorld.cshtml" />
<None Include="ViewEngines\HelloSpark\Breathe.spark" />
+ <None Include="ViewEngines\HelloSpark\Full.spark" />
+ <None Include="ViewEngines\HelloSpark\Partial2.spark" />
+ <None Include="ViewEngines\HelloSpark\Partial1.spark" />
<None Include="ViewEngines\HelloSpark\TakeABreath.spark" />
</ItemGroup>
<ItemGroup>
View
6 src/StoryTellerTesting/ViewEngines/HelloSpark/Full.spark
@@ -0,0 +1,6 @@
+<viewdata model="IntegrationTesting.ViewEngines.HelloSpark.FullViewModel" />
+<p>The partial is below</p>
+
+!{this.Partial(Model.PartialModel)}
+
+<p>The partial is above</p>
View
3  src/StoryTellerTesting/ViewEngines/HelloSpark/Partial1.spark
@@ -0,0 +1,3 @@
+<viewdata model="IntegrationTesting.ViewEngines.HelloSpark.PartialInput" />
+<h1>My name is !{Model.Name}</h1>
+!{this.Partial(Model.NestedInput)}
View
2  src/StoryTellerTesting/ViewEngines/HelloSpark/Partial2.spark
@@ -0,0 +1,2 @@
+<viewdata model="IntegrationTesting.ViewEngines.HelloSpark.MoreInput" />
+<p>!{Model.Description}</p>
View
67 src/StoryTellerTesting/ViewEngines/HelloSpark/PartialsWithSparkIntegrationTester.cs
@@ -0,0 +1,67 @@
+using System;
+using System.Diagnostics;
+using FubuMVC.Core;
+using FubuMVC.Core.Diagnostics.HtmlWriting;
+using IntegrationTesting.Conneg;
+using NUnit.Framework;
+using FubuTestingSupport;
+using FubuMVC.Spark;
+
+namespace IntegrationTesting.ViewEngines.HelloSpark
+{
+ [TestFixture]
+ public class Partials_and_actionless_views_WithSparkIntegrationTester : FubuRegistryHarness
+ {
+ protected override void configure(FubuRegistry registry)
+ {
+ registry.UseSpark();
+ registry.IncludeDiagnostics(true);
+ registry.Actions.IncludeType<PartialController>();
+ registry.Views.RegisterActionLessViews(v => v.ViewModel == typeof (PartialInput));
+ registry.Views.RegisterActionLessViews(v => v.ViewModel == typeof (MoreInput));
+ registry.Views.TryToAttachWithDefaultConventions();
+ }
+
+ [Test]
+ public void pair_of_nested_partials()
+ {
+ Debug.WriteLine(endpoints.Get<BehaviorGraphWriter>(x => x.PrintRoutes()));
+
+ var text = endpoints.Get<PartialController>(x => x.get_partials()).ReadAsText();
+
+ text.ShouldContain("<h1>My name is Shiner</h1>");
+ text.ShouldContain("<p>I am a 7 year old Labrador mix</p>");
+ }
+ }
+
+ public class PartialController
+ {
+ public FullViewModel get_partials()
+ {
+ return new FullViewModel{
+ PartialModel = new PartialInput{
+ Name = "Shiner",
+ NestedInput = new MoreInput{
+ Description = "I am a 7 year old Labrador mix"
+ }
+ }
+ };
+ }
+ }
+
+ public class PartialInput
+ {
+ public string Name { get; set; }
+ public MoreInput NestedInput { get; set; }
+ }
+
+ public class MoreInput
+ {
+ public string Description { get; set; }
+ }
+
+ public class FullViewModel
+ {
+ public PartialInput PartialModel { get; set; }
+ }
+}
View
4 src/StoryTellerTesting/ViewEngines/HelloSpark/SparkEngineIntegrationTester.cs
@@ -40,4 +40,8 @@ public void simple_view()
// Debug.WriteLine(text);
//}
}
+
+
+
+
}
Please sign in to comment.
Something went wrong with that request. Please try again.