forked from DarthFubuMVC/fubumvc
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
439 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Web; | ||
using NUnit.Framework; | ||
using FubuMVC.Core; | ||
|
||
namespace FubuMVC.Tests | ||
{ | ||
[TestFixture] | ||
public class AjaxExtensionsTester | ||
{ | ||
private HttpContext _ajaxContext; | ||
private HttpContext _nonAjaxContext; | ||
private IDictionary<string, object> _ajaxRequestInput = new Dictionary<string, object> { { "X-Requested-With", "XMLHttpRequest" } }; | ||
private IDictionary<string, object> _nonAjaxRequestInput = new Dictionary<string, object> { { "X-Requested-With", "some_value" } }; | ||
|
||
[SetUp] | ||
public void SetUp() | ||
{ | ||
var request = new HttpRequest("foo.txt", "http://test", "X-Requested-With=XMLHttpRequest"); | ||
_ajaxContext = new HttpContext(request, new HttpResponse(Console.Out)); | ||
var nonAjaxRequest = new HttpRequest("foo.txt", "http://test", "X-Requested-With=some_value"); | ||
_nonAjaxContext = new HttpContext(nonAjaxRequest, new HttpResponse(Console.Out)); | ||
} | ||
|
||
[Test] | ||
public void is_http_context_an_ajax_request() | ||
{ | ||
_ajaxContext.IsAjaxRequest().ShouldBeTrue(); | ||
_nonAjaxContext.IsAjaxRequest().ShouldBeFalse(); | ||
} | ||
|
||
[Test] | ||
public void is_dictionary_input_an_ajax_request() | ||
{ | ||
_ajaxRequestInput.IsAjaxRequest().ShouldBeTrue(); | ||
_nonAjaxRequestInput.IsAjaxRequest().ShouldBeFalse(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
using FubuMVC.Core; | ||
using FubuMVC.Core.Behaviors; | ||
using FubuMVC.Core.Runtime; | ||
using FubuMVC.Core.View; | ||
using FubuMVC.UI; | ||
using NUnit.Framework; | ||
using Rhino.Mocks; | ||
|
||
namespace FubuMVC.Tests.Behaviors | ||
{ | ||
[TestFixture] | ||
public class BasicBehaviorTester | ||
{ | ||
public static IPartialInvokingHandler PartialInvokingHandler; | ||
private IFubuPage _page; | ||
private IPartialFactory _partialFactory; | ||
private BasicBehavior _behavior; | ||
private IFubuRequest _request; | ||
|
||
public class PartialHandlingBehavior : IActionBehavior | ||
{ | ||
public void Invoke() | ||
{ | ||
|
||
} | ||
|
||
public void InvokePartial() | ||
{ | ||
PartialInvokingHandler.Invoke(); | ||
} | ||
} | ||
public interface IPartialInvokingHandler{void Invoke();} | ||
public class FakeController | ||
{ | ||
public void SomeAction() { } | ||
} | ||
public class WrappingBehavior : BasicBehavior | ||
{ | ||
public WrappingBehavior() | ||
: base(PartialBehavior.Ignored) | ||
{ | ||
} | ||
|
||
public DoNext PerformInvoke() | ||
{ | ||
return base.performInvoke(); | ||
} | ||
} | ||
public class InputModel { } | ||
|
||
[SetUp] | ||
public void SetUp() | ||
{ | ||
_page = MockRepository.GenerateStub<IFubuPage>(); | ||
_partialFactory = MockRepository.GenerateStub<IPartialFactory>(); | ||
_behavior = new WrappingBehavior(); | ||
PartialInvokingHandler = MockRepository.GenerateStub<IPartialInvokingHandler>(); | ||
_behavior.InsideBehavior = new PartialHandlingBehavior(); | ||
|
||
_partialFactory.Stub(f => f.BuildPartial(typeof(InputModel))).Return(_behavior); | ||
_page.Stub(p => p.Get<IPartialFactory>()).Return(_partialFactory); | ||
|
||
_request = MockRepository.GenerateStub<IFubuRequest>(); | ||
_page.Stub(p => p.Get<IFubuRequest>()).Return(_request); | ||
} | ||
|
||
[Test] | ||
public void should_invoke_partial_inside_behavior_by_default_even_when_partial_behavior_does_not_execute() | ||
{ | ||
_page.Partial<InputModel>(); | ||
PartialInvokingHandler.AssertWasCalled(h=>h.Invoke()); | ||
} | ||
|
||
[Test] | ||
public void perform_invoke_should_return_continue() | ||
{ | ||
new WrappingBehavior().PerformInvoke().ShouldEqual(DoNext.Continue); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.