Skip to content

Commit

Permalink
added the BehaviorChain.ForWriter method
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremydmiller committed May 4, 2012
1 parent 456cfa6 commit bbbc2bd
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/FubuMVC.Core/Registration/DSL/ViewExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ public ViewExpression ApplyConvention<TConvention>(TConvention convention)
}
}

// TODO -- change to IConfigurationActino
public class ActionLessViewConvention : IViewBagConvention
{
private readonly Func<IViewToken, bool> _viewTokenFilter;
Expand Down
9 changes: 9 additions & 0 deletions src/FubuMVC.Core/Registration/Nodes/BehaviorChain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -353,5 +353,14 @@ public void ResourceType(Type type)
}
}
}

public static BehaviorChain ForWriter(WriterNode node)
{
var chain = new BehaviorChain();
chain.ResourceType(node.ResourceType);
chain.Output.Writers.AddToEnd(node);

return chain;
}
}
}
28 changes: 28 additions & 0 deletions src/FubuMVC.Tests/Registration/Nodes/BehaviorChainTester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
using FubuMVC.Core.Registration.Nodes;
using FubuMVC.Core.Registration.ObjectGraph;
using FubuMVC.Core.Registration.Routes;
using FubuMVC.Core.Resources.Conneg.New;
using FubuMVC.Core.Runtime.Formatters;
using FubuMVC.Core.Security;
using FubuMVC.FakeControllers;
using FubuMVC.StructureMap;
using FubuMVC.Tests.StructureMapIoC;
using FubuTestingSupport;
using HtmlTags;
using NUnit.Framework;
using StructureMap;

Expand Down Expand Up @@ -637,6 +639,32 @@ public void override_the_resource_type()
}
}

[TestFixture]
public class BehaviorChain_build_for_a_single_writer_node
{
private WriteHtml theWriter;
private BehaviorChain theChain;

[SetUp]
public void SetUp()
{
theWriter = new WriteHtml(typeof (HtmlTag));
theChain = BehaviorChain.ForWriter(theWriter);
}

[Test]
public void should_derive_its_resource_type_from_the_writer()
{
theChain.ResourceType().ShouldEqual(typeof (HtmlTag));
}

[Test]
public void the_writer_should_be_attached_to_the_output_node()
{
theChain.Output.Writers.Single().ShouldBeTheSameAs(theWriter);
}
}

public class FakeInputNode : BehaviorNode, IMayHaveInputType
{
private readonly Type _inputType;
Expand Down

0 comments on commit bbbc2bd

Please sign in to comment.