From 35f565854e160baf5d5106e6c0b86a9f7ade6132 Mon Sep 17 00:00:00 2001 From: David Tchepak Date: Sun, 17 Jul 2022 14:53:40 +1000 Subject: [PATCH] Port old routing/autovalue tests to new suite Remove old tests that rely too heavily on mock adapter. --- .../AutoValues/AutoArrayProviderSpecs.cs | 7 +- .../AutoValues/AutoQueryableProviderSpecs.cs | 10 +- .../AutoValues/AutoStringProviderSpecs.cs | 7 +- .../AutoValues/AutoSubstituteProviderSpecs.cs | 54 ++++--- .../AutoValues/AutoTaskProviderSpecs.cs | 35 +++-- .../AddCallToQueryResultHandlerSpecs.cs | 53 ------- .../Handlers/CheckReceivedCallHandlerSpecs.cs | 145 ------------------ .../ClearLastCallRouterHandlerSpecs.cs | 40 ----- .../Handlers/DoActionsCallHandlerSpecs.cs | 46 ------ .../Handlers/EventSubscriptionHandlerSpec.cs | 141 ----------------- .../Handlers/PropertySetterHandlerSpecs.cs | 96 ------------ .../Routing/Handlers/RaiseEventHandlerSpec.cs | 99 ------------ .../Handlers/RecordCallHandlerSpecs.cs | 54 ------- .../Routing/Handlers/ReturnAutoValueSpecs.cs | 119 -------------- .../ReturnConfiguredResultHandlerSpecs.cs | 70 --------- .../ReturnDefaultForReturnTypeHandlerSpecs.cs | 48 ------ .../ReturnResultForTypeHandlerSpecs.cs | 70 --------- .../Handlers/SetActionsForCallHandlerSpecs.cs | 56 ------- tests/NSubstitute.Specs/Routing/RouteSpecs.cs | 47 ------ 19 files changed, 66 insertions(+), 1131 deletions(-) rename tests/{NSubstitute.Specs => NSubstitute.Acceptance.Specs}/Routing/AutoValues/AutoArrayProviderSpecs.cs (81%) rename tests/{NSubstitute.Specs => NSubstitute.Acceptance.Specs}/Routing/AutoValues/AutoQueryableProviderSpecs.cs (91%) rename tests/{NSubstitute.Specs => NSubstitute.Acceptance.Specs}/Routing/AutoValues/AutoStringProviderSpecs.cs (79%) rename tests/{NSubstitute.Specs => NSubstitute.Acceptance.Specs}/Routing/AutoValues/AutoSubstituteProviderSpecs.cs (78%) rename tests/{NSubstitute.Specs => NSubstitute.Acceptance.Specs}/Routing/AutoValues/AutoTaskProviderSpecs.cs (71%) delete mode 100644 tests/NSubstitute.Specs/Routing/Handlers/AddCallToQueryResultHandlerSpecs.cs delete mode 100644 tests/NSubstitute.Specs/Routing/Handlers/CheckReceivedCallHandlerSpecs.cs delete mode 100644 tests/NSubstitute.Specs/Routing/Handlers/ClearLastCallRouterHandlerSpecs.cs delete mode 100644 tests/NSubstitute.Specs/Routing/Handlers/DoActionsCallHandlerSpecs.cs delete mode 100644 tests/NSubstitute.Specs/Routing/Handlers/EventSubscriptionHandlerSpec.cs delete mode 100644 tests/NSubstitute.Specs/Routing/Handlers/PropertySetterHandlerSpecs.cs delete mode 100644 tests/NSubstitute.Specs/Routing/Handlers/RaiseEventHandlerSpec.cs delete mode 100644 tests/NSubstitute.Specs/Routing/Handlers/RecordCallHandlerSpecs.cs delete mode 100644 tests/NSubstitute.Specs/Routing/Handlers/ReturnAutoValueSpecs.cs delete mode 100644 tests/NSubstitute.Specs/Routing/Handlers/ReturnConfiguredResultHandlerSpecs.cs delete mode 100644 tests/NSubstitute.Specs/Routing/Handlers/ReturnDefaultForReturnTypeHandlerSpecs.cs delete mode 100644 tests/NSubstitute.Specs/Routing/Handlers/ReturnResultForTypeHandlerSpecs.cs delete mode 100644 tests/NSubstitute.Specs/Routing/Handlers/SetActionsForCallHandlerSpecs.cs delete mode 100644 tests/NSubstitute.Specs/Routing/RouteSpecs.cs diff --git a/tests/NSubstitute.Specs/Routing/AutoValues/AutoArrayProviderSpecs.cs b/tests/NSubstitute.Acceptance.Specs/Routing/AutoValues/AutoArrayProviderSpecs.cs similarity index 81% rename from tests/NSubstitute.Specs/Routing/AutoValues/AutoArrayProviderSpecs.cs rename to tests/NSubstitute.Acceptance.Specs/Routing/AutoValues/AutoArrayProviderSpecs.cs index ba768f37e..205206adc 100644 --- a/tests/NSubstitute.Specs/Routing/AutoValues/AutoArrayProviderSpecs.cs +++ b/tests/NSubstitute.Acceptance.Specs/Routing/AutoValues/AutoArrayProviderSpecs.cs @@ -1,12 +1,13 @@ using System; using NSubstitute.Routing.AutoValues; -using NSubstitute.Specs.Infrastructure; using NUnit.Framework; namespace NSubstitute.Specs.Routing.AutoValues { - public class AutoArrayProviderSpecs : ConcernFor + public class AutoArrayProviderSpecs { + AutoArrayProvider sut = CreateSubjectUnderTest(); + [Test] public void Can_provide_value_for_arrays() { @@ -28,7 +29,7 @@ public void Provides_empty_array_value() Assert.That(array, Is.Empty); } - public override AutoArrayProvider CreateSubjectUnderTest() + private static AutoArrayProvider CreateSubjectUnderTest() { return new AutoArrayProvider(); } diff --git a/tests/NSubstitute.Specs/Routing/AutoValues/AutoQueryableProviderSpecs.cs b/tests/NSubstitute.Acceptance.Specs/Routing/AutoValues/AutoQueryableProviderSpecs.cs similarity index 91% rename from tests/NSubstitute.Specs/Routing/AutoValues/AutoQueryableProviderSpecs.cs rename to tests/NSubstitute.Acceptance.Specs/Routing/AutoValues/AutoQueryableProviderSpecs.cs index e848a15c2..0771019f6 100644 --- a/tests/NSubstitute.Specs/Routing/AutoValues/AutoQueryableProviderSpecs.cs +++ b/tests/NSubstitute.Acceptance.Specs/Routing/AutoValues/AutoQueryableProviderSpecs.cs @@ -1,15 +1,16 @@ #if NET45 || NETSTANDARD1_3 using NSubstitute.Routing.AutoValues; -using NSubstitute.Specs.Infrastructure; using NUnit.Framework; using System.Linq; using System.Collections.Generic; namespace NSubstitute.Specs.Routing.AutoValues { - public class AutoQueryableProviderSpecs : ConcernFor + public class AutoQueryableProviderSpecs { + AutoQueryableProvider sut = new AutoQueryableProvider(); + [Test] public void Can_provide_value_for_queryables() { @@ -76,11 +77,6 @@ public void Substitute_should_automock_queryable() Assert.DoesNotThrow(() => queryable.Any()); } - public override AutoQueryableProvider CreateSubjectUnderTest() - { - return new AutoQueryableProvider(); - } - public interface IFoo2 { IQueryable GetObject(); diff --git a/tests/NSubstitute.Specs/Routing/AutoValues/AutoStringProviderSpecs.cs b/tests/NSubstitute.Acceptance.Specs/Routing/AutoValues/AutoStringProviderSpecs.cs similarity index 79% rename from tests/NSubstitute.Specs/Routing/AutoValues/AutoStringProviderSpecs.cs rename to tests/NSubstitute.Acceptance.Specs/Routing/AutoValues/AutoStringProviderSpecs.cs index 462f9345d..28cf8bc85 100644 --- a/tests/NSubstitute.Specs/Routing/AutoValues/AutoStringProviderSpecs.cs +++ b/tests/NSubstitute.Acceptance.Specs/Routing/AutoValues/AutoStringProviderSpecs.cs @@ -1,12 +1,13 @@ using System; using NSubstitute.Routing.AutoValues; -using NSubstitute.Specs.Infrastructure; using NUnit.Framework; namespace NSubstitute.Specs.Routing.AutoValues { - public class AutoStringProviderSpecs : ConcernFor + public class AutoStringProviderSpecs { + AutoStringProvider sut = CreateSubjectUnderTest(); + [Test] public void Can_provide_value_for_string() { @@ -25,7 +26,7 @@ public void Can_not_provide_a_value_for_an_int_because_that_would_be_silly() Assert.That(sut.CanProvideValueFor(typeof(int)), Is.False); } - public override AutoStringProvider CreateSubjectUnderTest() + private static AutoStringProvider CreateSubjectUnderTest() { return new AutoStringProvider(); } diff --git a/tests/NSubstitute.Specs/Routing/AutoValues/AutoSubstituteProviderSpecs.cs b/tests/NSubstitute.Acceptance.Specs/Routing/AutoValues/AutoSubstituteProviderSpecs.cs similarity index 78% rename from tests/NSubstitute.Specs/Routing/AutoValues/AutoSubstituteProviderSpecs.cs rename to tests/NSubstitute.Acceptance.Specs/Routing/AutoValues/AutoSubstituteProviderSpecs.cs index fc7d1f66f..932f2f428 100644 --- a/tests/NSubstitute.Specs/Routing/AutoValues/AutoSubstituteProviderSpecs.cs +++ b/tests/NSubstitute.Acceptance.Specs/Routing/AutoValues/AutoSubstituteProviderSpecs.cs @@ -1,26 +1,52 @@ using System; +using System.Collections.Generic; using NSubstitute.Core; using NSubstitute.Routing.AutoValues; -using NSubstitute.Specs.Infrastructure; -using NSubstitute.Specs.SampleStructures; using NUnit.Framework; namespace NSubstitute.Specs.Routing.AutoValues { - public class AutoSubstituteProviderSpecs : ConcernFor + public class AutoSubstituteProviderSpecs { - private ISubstituteFactory _substituteFactory; + public interface IFoo + { + void Goo(); + string Bar(int aNumber, string aString); + event EventHandler Boo; + } + + private class TestSubstituteFactory : ISubstituteFactory + { + private IDictionary stubs = new Dictionary(); + public void StubCreateFor(object o) => stubs[typeof(T)] = o; + public object Create(Type[] typesToProxy, object[] constructorArguments) => stubs[typesToProxy[0]]; + + public object CreatePartial(Type[] typesToProxy, object[] constructorArguments) + { + throw new NotImplementedException(); + } + } + + private TestSubstituteFactory _substituteFactory; + + private AutoSubstituteProvider sut; + + public AutoSubstituteProviderSpecs() + { + _substituteFactory = new TestSubstituteFactory(); + sut = new AutoSubstituteProvider(_substituteFactory); + } [Test] public void Can_provide_value_for_interface() { - Assert.That(sut.CanProvideValueFor(typeof (IFoo))); + Assert.That(sut.CanProvideValueFor(typeof(IFoo))); } [Test] public void Can_provide_value_for_delegates() { - Assert.That(sut.CanProvideValueFor(typeof (Func))); + Assert.That(sut.CanProvideValueFor(typeof(Func))); } [Test] @@ -71,19 +97,9 @@ public void Should_not_provide_value_for_value_type() public void Should_create_substitute_for_type() { var autoValue = new object(); - _substituteFactory.stub(x => x.Create(new[] {typeof (IFoo)}, new object[0])).Return(autoValue); - - Assert.That(sut.GetValue(typeof (IFoo)), Is.SameAs(autoValue)); - } + _substituteFactory.StubCreateFor(autoValue); - public override void Context() - { - _substituteFactory = mock(); - } - - public override AutoSubstituteProvider CreateSubjectUnderTest() - { - return new AutoSubstituteProvider(_substituteFactory); + Assert.That(sut.GetValue(typeof(IFoo)), Is.SameAs(autoValue)); } public class TestClasses @@ -139,7 +155,7 @@ public class VirtualClassWithInternalConstructor { internal VirtualClassWithInte public class PureVirtualClassWithAPublicStaticMethod { - public static void StaticMethod() {} + public static void StaticMethod() { } } public class PureVirtualClassWithAPublicStaticProperty diff --git a/tests/NSubstitute.Specs/Routing/AutoValues/AutoTaskProviderSpecs.cs b/tests/NSubstitute.Acceptance.Specs/Routing/AutoValues/AutoTaskProviderSpecs.cs similarity index 71% rename from tests/NSubstitute.Specs/Routing/AutoValues/AutoTaskProviderSpecs.cs rename to tests/NSubstitute.Acceptance.Specs/Routing/AutoValues/AutoTaskProviderSpecs.cs index b28e89ad4..6e417bdfd 100644 --- a/tests/NSubstitute.Specs/Routing/AutoValues/AutoTaskProviderSpecs.cs +++ b/tests/NSubstitute.Acceptance.Specs/Routing/AutoValues/AutoTaskProviderSpecs.cs @@ -1,22 +1,37 @@ #if (NET4 || NET45) +using System; using System.Threading.Tasks; using NSubstitute.Routing.AutoValues; -using NSubstitute.Specs.Infrastructure; using NUnit.Framework; using System.Collections.Generic; namespace NSubstitute.Specs.Routing.AutoValues { - public class AutoTaskProviderSpecs : ConcernFor + public class AutoTaskProviderSpecs { - private IAutoValueProvider _testValuesProvider; + private class TestAutoValueProvider : IAutoValueProvider { + private IDictionary stubs = new Dictionary(); + public void Stub(T value) => stubs[typeof(T)] = value; + public bool CanProvideValueFor(Type type) => stubs.ContainsKey(type); + public object GetValue(Type type) => stubs[type]; + } + + private TestAutoValueProvider _testValuesProvider; + private AutoTaskProvider sut; + + public AutoTaskProviderSpecs() + { + _testValuesProvider = new TestAutoValueProvider(); + sut = new AutoTaskProvider( + new Lazy>( () => new [] { _testValuesProvider }) + ); + } [Test] public void Should_create_substitute_with_another_auto_value_provider_if_available() { const string autoValue = "test"; - _testValuesProvider.stub(x => x.CanProvideValueFor(typeof(string))).Return(true); - _testValuesProvider.stub(x => x.GetValue(typeof(string))).Return(autoValue); + _testValuesProvider.Stub(autoValue); var type = typeof (Task); Assert.True(sut.CanProvideValueFor(type)); @@ -66,16 +81,6 @@ public void Substitute_should_automock_task() Assert.Null(task.Result); } - public override void Context() - { - _testValuesProvider = mock(); - } - - public override AutoTaskProvider CreateSubjectUnderTest() - { - return new AutoTaskProvider(() => new[] { _testValuesProvider }); - } - public interface IFoo2 { Task GetObjectAsync(); diff --git a/tests/NSubstitute.Specs/Routing/Handlers/AddCallToQueryResultHandlerSpecs.cs b/tests/NSubstitute.Specs/Routing/Handlers/AddCallToQueryResultHandlerSpecs.cs deleted file mode 100644 index 2cdf4c162..000000000 --- a/tests/NSubstitute.Specs/Routing/Handlers/AddCallToQueryResultHandlerSpecs.cs +++ /dev/null @@ -1,53 +0,0 @@ -using NSubstitute.Core; -using NSubstitute.Routing.Handlers; -using NSubstitute.Specs.Infrastructure; -using NUnit.Framework; - -namespace NSubstitute.Specs.Routing.Handlers -{ - public class AddCallToQueryResultHandlerSpecs - { - public class When_handling_call : ConcernFor - { - private readonly object _target = new object(); - private ICall _call; - private ICallSpecificationFactory _callSpecFactory; - private ICallSpecification _callSpec; - private RouteAction _result; - private ISubstitutionContext _context; - - public override void Context() - { - _callSpec = mock(); - _call = mock(); - _callSpecFactory = mock(); - _context = mock(); - - _call.stub(x => x.Target()).Return(_target); - _callSpecFactory.stub(x => x.CreateFrom(_call, MatchArgs.AsSpecifiedInCall)).Return(_callSpec); - } - - public override void Because() - { - _result = sut.Handle(_call); - } - - [Test] - public void Add_call_target_and_spec_to_query() - { - _context.received(x => x.AddToQuery(_target, _callSpec)); - } - - [Test] - public void Continue_route() - { - Assert.That(_result, Is.EqualTo(RouteAction.Continue())); - } - - public override AddCallToQueryResultHandler CreateSubjectUnderTest() - { - return new AddCallToQueryResultHandler(_context, _callSpecFactory); - } - } - } -} \ No newline at end of file diff --git a/tests/NSubstitute.Specs/Routing/Handlers/CheckReceivedCallHandlerSpecs.cs b/tests/NSubstitute.Specs/Routing/Handlers/CheckReceivedCallHandlerSpecs.cs deleted file mode 100644 index 48bd895af..000000000 --- a/tests/NSubstitute.Specs/Routing/Handlers/CheckReceivedCallHandlerSpecs.cs +++ /dev/null @@ -1,145 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using NSubstitute.Core; -using NSubstitute.Routing.Handlers; -using NSubstitute.Specs.Infrastructure; -using NUnit.Framework; - -namespace NSubstitute.Specs.Routing.Handlers -{ - public class CheckReceivedCallHandlerSpecs - { - public abstract class Concern : ConcernFor - { - protected const int ValueToReturn = 7; - protected ISubstitutionContext _context; - protected ICall _call; - protected IReceivedCalls _receivedCalls; - protected ICallSpecification _callSpecFromCall; - protected ICallSpecification _callSpecFromMethodSpec; - protected ICallSpecificationFactory _callSpecificationFactory; - protected FakeExceptionThrower _exceptionThrower; - protected MatchArgs _argMatching = MatchArgs.AsSpecifiedInCall; - protected Quantity _quantity; - - public override void Context() - { - _context = mock(); - _receivedCalls = mock(); - _call = mock(); - _callSpecFromCall = mock(); - _callSpecFromMethodSpec = mock(); - _callSpecificationFactory = mock(); - - _exceptionThrower = new FakeExceptionThrower(); - - _callSpecFromCall.stub(x => x.IsSatisfiedBy(_call)).Return(true); - _callSpecFromMethodSpec.stub(x=>x.IsSatisfiedBy(_call)).Return(false); - - _callSpecificationFactory.stub(x => x.CreateFrom(_call, _argMatching)).Return(_callSpecFromCall); - } - - public override CheckReceivedCallsHandler CreateSubjectUnderTest() - { - return new CheckReceivedCallsHandler(_receivedCalls, _callSpecificationFactory, _exceptionThrower, _argMatching, _quantity); - } - } - - public class When_handling_call_that_has_been_received : Concern - { - private RouteAction _result; - - [Test] - public void Should_return_without_exception() - { - _exceptionThrower.ShouldNotHaveBeenToldToThrow(); - } - - [Test] - public void Should_continue_route() - { - Assert.That(_result, Is.SameAs(RouteAction.Continue())); - } - - public override void Because() - { - _result = sut.Handle(_call); - } - - public override void Context() - { - base.Context(); - _quantity = Quantity.AtLeastOne(); - _receivedCalls.stub(x => x.AllCalls()).Return(new[] { _call }); - _callSpecificationFactory.stub(x => x.CreateFrom(_call, MatchArgs.Any)).Return(_callSpecFromMethodSpec); - } - } - - public class When_handling_call_that_has_not_been_received_in_the_correct_quantity : Concern - { - ICallSpecification _callSpecWithAnyArguments; - private ICall[] _matchingCalls; - private ICall[] _relatedNonMatchingCalls; - - [Test] - public void Should_throw_exception_with_actual_calls_and_related_calls() - { - _exceptionThrower.ShouldHaveBeenToldToThrowWith(_callSpecFromCall, _matchingCalls, _relatedNonMatchingCalls, _quantity); - } - - public override void Because() - { - sut.Handle(_call); - } - - public override void Context() - { - base.Context(); - _callSpecWithAnyArguments = mock(); - _callSpecificationFactory.stub(x => x.CreateFrom(_call, MatchArgs.Any)).Return(_callSpecWithAnyArguments); - - _quantity = Quantity.Exactly(2); - _matchingCalls = new[] { _call }; - _relatedNonMatchingCalls = new[] { mock() }; - var completelyNonMatchingCalls = new[] { mock() }; - - Array.ForEach(_relatedNonMatchingCalls, call => _callSpecWithAnyArguments.stub(x => x.IsSatisfiedBy(call)).Return(true)); - - var allRelatedCalls = _matchingCalls.Concat(_relatedNonMatchingCalls).Concat(completelyNonMatchingCalls); - _receivedCalls.stub(x => x.AllCalls()).Return(allRelatedCalls); - } - } - - public class FakeExceptionThrower : IReceivedCallsExceptionThrower - { - private ICallSpecification _callSpecification; - private IEnumerable _matchingCalls; - private IEnumerable _nonMatchingCalls; - private Quantity _requiredQuantity; - private bool _wasCalled; - - public void Throw(ICallSpecification callSpecification, IEnumerable matchingCalls, IEnumerable nonMatchingCalls, Quantity requiredQuantity) - { - _wasCalled = true; - _callSpecification = callSpecification; - _matchingCalls = matchingCalls; - _nonMatchingCalls = nonMatchingCalls; - _requiredQuantity = requiredQuantity; - } - - public void ShouldHaveBeenToldToThrowWith(ICallSpecification callSpecification, IEnumerable matchingCalls, IEnumerable nonMatchingCalls, Quantity requiredQuantity) - { - Assert.That(_callSpecification, Is.EqualTo(callSpecification)); - Assert.That(_matchingCalls.ToArray(), Is.EquivalentTo(matchingCalls.ToArray())); - Assert.That(_nonMatchingCalls.ToArray(), Is.EquivalentTo(nonMatchingCalls.ToArray())); - Assert.That(_requiredQuantity, Is.EqualTo(requiredQuantity)); - } - - public void ShouldNotHaveBeenToldToThrow() - { - Assert.False(_wasCalled); - } - } - } -} \ No newline at end of file diff --git a/tests/NSubstitute.Specs/Routing/Handlers/ClearLastCallRouterHandlerSpecs.cs b/tests/NSubstitute.Specs/Routing/Handlers/ClearLastCallRouterHandlerSpecs.cs deleted file mode 100644 index 539fe1ae5..000000000 --- a/tests/NSubstitute.Specs/Routing/Handlers/ClearLastCallRouterHandlerSpecs.cs +++ /dev/null @@ -1,40 +0,0 @@ -using NSubstitute.Core; -using NSubstitute.Routing.Handlers; -using NSubstitute.Specs.Infrastructure; -using NUnit.Framework; - -namespace NSubstitute.Specs.Routing.Handlers -{ - public class ClearLastCallRouterHandlerSpecs - { - public class When_handling_a_call : ConcernFor - { - private ISubstitutionContext _context; - private RouteAction _result; - - public override void Because() - { - _result = sut.Handle(mock()); - } - - [Test] - public void Clear_last_call_router() - { - _context.received(x => x.ClearLastCallRouter()); - } - - [Test] - public void Continues_route() - { - Assert.That(_result, Is.EqualTo(RouteAction.Continue())); - } - - public override void Context() { _context = mock(); } - - public override ClearLastCallRouterHandler CreateSubjectUnderTest() - { - return new ClearLastCallRouterHandler(_context); - } - } - } -} \ No newline at end of file diff --git a/tests/NSubstitute.Specs/Routing/Handlers/DoActionsCallHandlerSpecs.cs b/tests/NSubstitute.Specs/Routing/Handlers/DoActionsCallHandlerSpecs.cs deleted file mode 100644 index 1d680178d..000000000 --- a/tests/NSubstitute.Specs/Routing/Handlers/DoActionsCallHandlerSpecs.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using NSubstitute.Core; -using NSubstitute.Routing.Handlers; -using NSubstitute.Specs.Infrastructure; -using NUnit.Framework; - -namespace NSubstitute.Specs.Routing.Handlers -{ - public class DoActionsCallHandlerSpecs - { - public class When_handling_a_call : ConcernFor - { - private ICall _call; - private ICallActions _callActions; - private RouteAction _result; - - [Test] - public void Should_invoke_all_actions_for_call_with_call_information() - { - _callActions.received(x => x.InvokeMatchingActions(_call)); - } - - [Test] - public void Should_continue_route() - { - Assert.That(_result, Is.SameAs(RouteAction.Continue())); - } - - public override void Because() - { - _result = sut.Handle(_call); - } - - public override void Context() - { - _call = mock(); - _callActions = mock(); - } - - public override DoActionsCallHandler CreateSubjectUnderTest() - { - return new DoActionsCallHandler(_callActions); - } - } - } -} \ No newline at end of file diff --git a/tests/NSubstitute.Specs/Routing/Handlers/EventSubscriptionHandlerSpec.cs b/tests/NSubstitute.Specs/Routing/Handlers/EventSubscriptionHandlerSpec.cs deleted file mode 100644 index db1afd33c..000000000 --- a/tests/NSubstitute.Specs/Routing/Handlers/EventSubscriptionHandlerSpec.cs +++ /dev/null @@ -1,141 +0,0 @@ -using System; -using System.Reflection; -using NSubstitute.Core; -using NSubstitute.Routing.Handlers; -using NSubstitute.Specs.Infrastructure; -using NUnit.Framework; -using Rhino.Mocks; - -namespace NSubstitute.Specs.Routing.Handlers -{ - public class EventSubscriptionHandlerSpec - { - public class Concern : ConcernFor - { - protected IEventHandlerRegistry _eventHandlerRegistry; - - public override void Context() - { - _eventHandlerRegistry = mock(); - - } - - public override EventSubscriptionHandler CreateSubjectUnderTest() - { - return new EventSubscriptionHandler(_eventHandlerRegistry); - } - - protected ICall CreateCall(MethodInfo subscribeMethodInfo, object[] arguments) - { - var call = mock(); - call.stub(x => x.GetMethodInfo()).Return(subscribeMethodInfo); - call.stub(x => x.GetArguments()).Return(arguments); - return call; - } - } - - public class When_handling_an_event_subscription : Concern - { - private const string SampleEventName = "Sample"; - private ICall _eventSubscription; - private object _handlerArgument; - private RouteAction _result; - - public override void Context() - { - base.Context(); - var subscribeMethodInfo = typeof (SampleClassWithEvent).GetEvent(SampleEventName).GetAddMethod(); - _handlerArgument = new object(); - _eventSubscription = CreateCall(subscribeMethodInfo, new[] {_handlerArgument}); - } - - public override void Because() - { - _result = sut.Handle(_eventSubscription); - } - - [Test] - public void Should_add_handler_for_event() - { - _eventHandlerRegistry.received(x => x.Add(SampleEventName, _handlerArgument)); - } - - [Test] - public void Should_continue_route() - { - Assert.That(_result, Is.SameAs(RouteAction.Continue())); - } - - } - - public class When_handling_an_event_unsubscription : Concern - { - private const string SampleEventName = "Sample"; - private ICall _eventUnsubscription; - private object _handlerArgument; - private RouteAction _result; - - public override void Context() - { - base.Context(); - var subscribeMethodInfo = typeof(SampleClassWithEvent).GetEvent(SampleEventName).GetRemoveMethod(); - _handlerArgument = new object(); - _eventUnsubscription = CreateCall(subscribeMethodInfo, new[] { _handlerArgument }); - } - - public override void Because() - { - _result = sut.Handle(_eventUnsubscription); - } - - [Test] - public void Should_remove_handler_for_event() - { - _eventHandlerRegistry.received(x => x.Remove(SampleEventName, _handlerArgument)); - } - - [Test] - public void Should_continue_route() - { - Assert.That(_result, Is.SameAs(RouteAction.Continue())); - } - } - - public class When_call_is_not_an_event_subscription_or_removal :Concern - { - private ICall _nonEventCall; - private RouteAction _result; - - public override void Context() - { - base.Context(); - var nonEventMethodInfo = typeof (SampleClassWithEvent).GetMethod("NonEventMethod"); - _nonEventCall = CreateCall(nonEventMethodInfo, new object[0]); - } - - public override void Because() - { - _result = sut.Handle(_nonEventCall); - } - - [Test] - public void Should_not_add_or_remove_a_handler_for_event() - { - _eventHandlerRegistry.did_not_receive(x => x.Add(Arg.Is.Anything, Arg.Is.Anything)); - } - - [Test] - public void Should_continue_route() - { - Assert.That(_result, Is.SameAs(RouteAction.Continue())); - } - } - - class SampleClassWithEvent - { - public event EventHandler Sample; - public void OnSample(EventArgs e) { var handler = Sample; if (handler != null) handler(this, e); } - public void NonEventMethod() {} - } - } -} \ No newline at end of file diff --git a/tests/NSubstitute.Specs/Routing/Handlers/PropertySetterHandlerSpecs.cs b/tests/NSubstitute.Specs/Routing/Handlers/PropertySetterHandlerSpecs.cs deleted file mode 100644 index 62df3385f..000000000 --- a/tests/NSubstitute.Specs/Routing/Handlers/PropertySetterHandlerSpecs.cs +++ /dev/null @@ -1,96 +0,0 @@ -using NSubstitute.Core; -using NSubstitute.Routing.Handlers; -using NSubstitute.Specs.Infrastructure; -using NUnit.Framework; - -namespace NSubstitute.Specs.Routing.Handlers -{ - public class PropertySetterHandlerSpecs - { - public abstract class Concern : ConcernFor - { - protected readonly object _setValue = new object(); - protected ICall _call; - protected IPropertyHelper _propertyHelper; - protected IConfigureCall ConfigureCall; - protected ICall _propertyGetter; - - public override void Context() - { - _propertyHelper = mock(); - ConfigureCall = mock(); - _call = mock(); - _propertyGetter = mock(); - - var settersWithMultipleArgsLikeIndexersHaveSetValueAsLastInArray = new[] { new object(), new object(), _setValue }; - _call.stub(x => x.GetArguments()).Return(settersWithMultipleArgsLikeIndexersHaveSetValueAsLastInArray); - _propertyHelper.stub(x => x.CreateCallToPropertyGetterFromSetterCall(_call)).Return(_propertyGetter); - } - - public override PropertySetterHandler CreateSubjectUnderTest() - { - return new PropertySetterHandler(_propertyHelper, ConfigureCall); - } - } - - public class When_call_is_a_property_setter : Concern - { - private ReturnValue _returnPassedToResultSetter; - private RouteAction _result; - - [Test] - public void Should_add_set_value_to_configured_results() - { - Assert.That(_returnPassedToResultSetter.ReturnFor(null), Is.EqualTo(_setValue)); - } - - [Test] - public void Should_continue_route() - { - Assert.That(_result, Is.SameAs(RouteAction.Continue())); - } - - public override void Because() - { - _result = sut.Handle(_call); - } - - public override void Context() - { - base.Context(); - _propertyHelper.stub(x => x.IsCallToSetAReadWriteProperty(_call)).Return(true); - ConfigureCall - .stub(x => x.SetResultForCall(It.Is(_propertyGetter), It.IsAny(), It.Is(MatchArgs.AsSpecifiedInCall))) - .WhenCalled(x => _returnPassedToResultSetter = (ReturnValue)x.Arguments[1]); - } - } - - public class When_call_is_not_a_property_setter : Concern - { - private RouteAction _result; - - [Test] - public void Should_not_add_any_values_to_configured_results() - { - ConfigureCall.did_not_receive(x => x.SetResultForCall(It.Is(_propertyGetter), It.IsAny(), It.Is(MatchArgs.AsSpecifiedInCall))); - } - - [Test] - public void Should_continue_route() - { - Assert.That(_result, Is.SameAs(RouteAction.Continue())); - } - - public override void Because() - { - _result = sut.Handle(_call); - } - - public override void Context() - { - base.Context(); - _propertyHelper.stub(x => x.IsCallToSetAReadWriteProperty(_call)).Return(false); - } - } - } -} \ No newline at end of file diff --git a/tests/NSubstitute.Specs/Routing/Handlers/RaiseEventHandlerSpec.cs b/tests/NSubstitute.Specs/Routing/Handlers/RaiseEventHandlerSpec.cs deleted file mode 100644 index b2af02930..000000000 --- a/tests/NSubstitute.Specs/Routing/Handlers/RaiseEventHandlerSpec.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Reflection; -using NSubstitute.Core; -using NSubstitute.Routing.Handlers; -using NSubstitute.Specs.Infrastructure; -using NUnit.Framework; -using Rhino.Mocks; - -namespace NSubstitute.Specs.Routing.Handlers -{ - public class RaiseEventHandlerSpec - { - public abstract class Concern : ConcernFor - { - private const string SampleEventName = "Sample"; - private IEventHandlerRegistry _eventHandlerRegistry; - private Func _getEventArguments; - protected IList _handlers; - - protected EventHandler EventHandler; - protected object[] EventArguments; - protected ICall Call; - - public override void Context() - { - var subscribeMethodInfo = typeof(SampleClassWithEvent).GetEvent(SampleEventName).GetAddMethod(); - Call = CreateCall(subscribeMethodInfo, new object[0]); - - EventArguments = new[] { new object(), EventArgs.Empty }; - _getEventArguments = mock>(); - _getEventArguments.stub(x => x(Call)).Return(EventArguments); - - EventHandler = mock>(); - _handlers = new object[] { EventHandler }; - _eventHandlerRegistry = mock(); - _eventHandlerRegistry.Stub(x => x.GetHandlers(SampleEventName)).Return(_handlers); - } - - public override RaiseEventHandler CreateSubjectUnderTest() - { - return new RaiseEventHandler(_eventHandlerRegistry, _getEventArguments); - } - - protected ICall CreateCall(MethodInfo subscribeMethodInfo, object[] arguments) - { - var call = mock(); - call.stub(x => x.GetMethodInfo()).Return(subscribeMethodInfo); - call.stub(x => x.GetArguments()).Return(arguments); - return call; - } - } - - public class When_raising_an_event_from_a_call : Concern - { - private RouteAction _result; - - [Test] - public void Should_raise_event_with_arguments() - { - EventHandler.AssertWasCalled(x => x.Invoke(EventArguments[0], (EventArgs) EventArguments[1])); - } - - [Test] - public void Should_continue_route() - { - Assert.That(_result, Is.SameAs(RouteAction.Continue())); - } - - public override void Because() - { - _result = sut.Handle(Call); - } - } - - public class When_raising_an_event_and_event_handler_throws_an_exception : Concern - { - public override void Context() - { - base.Context(); - EventHandler handler = (sender, eventArgs) => { throw new Exception(); }; - _handlers[0] = handler; - } - - [Test] - public void Should_throw_original_exception() - { - Assert.Throws(() => sut.Handle(Call)); - } - } - - class SampleClassWithEvent - { - public event EventHandler Sample; - public void OnSample(EventArgs e) { var handler = Sample; if (handler != null) handler(this, e); } - public void NonEventMethod() { } - } - } -} diff --git a/tests/NSubstitute.Specs/Routing/Handlers/RecordCallHandlerSpecs.cs b/tests/NSubstitute.Specs/Routing/Handlers/RecordCallHandlerSpecs.cs deleted file mode 100644 index f07eacf62..000000000 --- a/tests/NSubstitute.Specs/Routing/Handlers/RecordCallHandlerSpecs.cs +++ /dev/null @@ -1,54 +0,0 @@ -using NSubstitute.Core; -using NSubstitute.Routing.Handlers; -using NSubstitute.Specs.Infrastructure; -using NUnit.Framework; - -namespace NSubstitute.Specs.Routing.Handlers -{ - public class RecordCallHandlerSpecs - { - public class When_handling_call_to_a_member : ConcernFor - { - ICall _call; - ICallCollection _callCollection; - SequenceNumberGenerator _sequenceNumberGenerator; - RouteAction _result; - - [Test] - public void Should_record_call() - { - _callCollection.received(x => x.Add(_call)); - } - - [Test] - public void Should_assign_sequence_number() - { - _call.received(x => x.AssignSequenceNumber(42)); - } - - [Test] - public void Should_continue_route() - { - Assert.That(_result, Is.SameAs(RouteAction.Continue())); - } - - public override void Because() - { - _result = sut.Handle(_call); - } - - public override void Context() - { - _callCollection = mock(); - _call = mock(); - _sequenceNumberGenerator = mock(); - _sequenceNumberGenerator.stub(x => x.Next()).Return(42); - } - - public override RecordCallHandler CreateSubjectUnderTest() - { - return new RecordCallHandler(_callCollection, _sequenceNumberGenerator); - } - } - } -} \ No newline at end of file diff --git a/tests/NSubstitute.Specs/Routing/Handlers/ReturnAutoValueSpecs.cs b/tests/NSubstitute.Specs/Routing/Handlers/ReturnAutoValueSpecs.cs deleted file mode 100644 index 88fb06342..000000000 --- a/tests/NSubstitute.Specs/Routing/Handlers/ReturnAutoValueSpecs.cs +++ /dev/null @@ -1,119 +0,0 @@ -using System; -using NSubstitute.Core; -using NSubstitute.Routing.AutoValues; -using NSubstitute.Routing.Handlers; -using NSubstitute.Specs.Infrastructure; -using NUnit.Framework; - -namespace NSubstitute.Specs.Routing.Handlers -{ - public abstract class ReturnAutoValueSpecs - { - public abstract class Concern : ConcernFor - { - protected Type _type = typeof(int); - protected IAutoValueProvider _firstAutoValueProvider; - protected IAutoValueProvider _secondAutoValueProvider; - protected RouteAction _result; - protected ICall _call; - protected ICallResults _callResults; - protected ICallSpecification _callSpecification; - protected ICallSpecificationFactory _callSpecificationFactory; - - public override void Because() - { - _result = sut.Handle(_call); - } - - public override void Context() - { - base.Context(); - _call = mock(); - _call.stub(x => x.GetReturnType()).Return(_type); - _callResults = mock(); - _callSpecification = mock(); - _callSpecificationFactory = mock(); - _callSpecificationFactory.stub(x => x.CreateFrom(_call, MatchArgs.AsSpecifiedInCall)).Return(_callSpecification); - _firstAutoValueProvider = mock(); - _secondAutoValueProvider = mock(); - } - - public ReturnAutoValue CreateReturnAutoValue(AutoValueBehaviour autoValueBehaviour) - { - return new ReturnAutoValue(autoValueBehaviour, new[] {_firstAutoValueProvider, _secondAutoValueProvider}, _callResults, _callSpecificationFactory); - } - } - - public class When_has_an_auto_value_for_the_return_type_of_the_handled_call : Concern - { - readonly object _autoValue = new object(); - - [Test] - public void Should_return_auto_value() - { - Assert.That(_result.ReturnValue, Is.SameAs(_autoValue)); - } - - [Test] - public void Should_set_auto_value_as_value_to_return_for_subsequent_calls() - { - _callResults.received(x => x.SetResult(It.Is(_callSpecification), It.Matches(arg => arg.ReturnFor(null) == _autoValue))); - } - - public override void Context() - { - base.Context(); - _secondAutoValueProvider.stub(x => x.CanProvideValueFor(_type)).Return(true); - _secondAutoValueProvider.stub(x => x.GetValue(_type)).Return(_autoValue); - } - - public override ReturnAutoValue CreateSubjectUnderTest() - { - return CreateReturnAutoValue(AutoValueBehaviour.UseValueForSubsequentCalls); - } - } - - public class When_no_auto_value_is_available_for_return_type_of_handled_call : Concern - { - [Test] - public void Should_continue_route() - { - Assert.That(_result, Is.EqualTo(RouteAction.Continue())); - } - - public override ReturnAutoValue CreateSubjectUnderTest() - { - return CreateReturnAutoValue(AutoValueBehaviour.UseValueForSubsequentCalls); - } - } - - public class When_has_an_auto_value_for_the_return_type_and_set_to_forget_values : Concern - { - readonly object _autoValue = new object(); - - [Test] - public void Should_return_auto_value() - { - Assert.That(_result.ReturnValue, Is.SameAs(_autoValue)); - } - - [Test] - public void Should_set_auto_value_as_value_to_return_for_subsequent_calls() - { - _callResults.did_not_receive_with_any_args(x => x.SetResult(null, null)); - } - - public override void Context() - { - base.Context(); - _secondAutoValueProvider.stub(x => x.CanProvideValueFor(_type)).Return(true); - _secondAutoValueProvider.stub(x => x.GetValue(_type)).Return(_autoValue); - } - - public override ReturnAutoValue CreateSubjectUnderTest() - { - return CreateReturnAutoValue(AutoValueBehaviour.ReturnAndForgetValue); - } - } - } -} \ No newline at end of file diff --git a/tests/NSubstitute.Specs/Routing/Handlers/ReturnConfiguredResultHandlerSpecs.cs b/tests/NSubstitute.Specs/Routing/Handlers/ReturnConfiguredResultHandlerSpecs.cs deleted file mode 100644 index 63e710d9f..000000000 --- a/tests/NSubstitute.Specs/Routing/Handlers/ReturnConfiguredResultHandlerSpecs.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System; -using NSubstitute.Core; -using NSubstitute.Routing.Handlers; -using NSubstitute.Specs.Infrastructure; -using NUnit.Framework; - -namespace NSubstitute.Specs.Routing.Handlers -{ - public class ReturnConfiguredResultHandlerSpecs - { - public abstract class When_handling_call : ConcernFor - { - protected ICallResults _callResults; - protected ICall _call; - protected RouteAction _result; - - public override void Context() - { - _call = mock(); - _callResults = mock(); - } - - public override void Because() - { - _result = sut.Handle(_call); - } - - public override ReturnConfiguredResultHandler CreateSubjectUnderTest() - { - return new ReturnConfiguredResultHandler(_callResults); - } - } - - public class When_handling_call_with_configured_result : When_handling_call - { - private readonly object _expectedResult = new object(); - - [Test] - public void Should_return_configured_result() - { - Assert.That(_result.ReturnValue, Is.SameAs(_expectedResult)); - } - - public override void Context() - { - base.Context(); - _callResults.stub(x => x.HasResultFor(_call)).Return(true); - _callResults.stub(x => x.GetResult(_call)).Return(_expectedResult); - } - } - - public class When_handling_call_without_configured_result : When_handling_call - { - readonly Type _returnType = typeof(object); - - [Test] - public void Should_continue_route() - { - Assert.That(_result, Is.SameAs(RouteAction.Continue())); - } - - public override void Context() - { - base.Context(); - _callResults.stub(x => x.HasResultFor(_call)).Return(false); - _call.stub(x => x.GetReturnType()).Return(_returnType); - } - } - } -} \ No newline at end of file diff --git a/tests/NSubstitute.Specs/Routing/Handlers/ReturnDefaultForReturnTypeHandlerSpecs.cs b/tests/NSubstitute.Specs/Routing/Handlers/ReturnDefaultForReturnTypeHandlerSpecs.cs deleted file mode 100644 index 074e2f198..000000000 --- a/tests/NSubstitute.Specs/Routing/Handlers/ReturnDefaultForReturnTypeHandlerSpecs.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System.Reflection; -using NSubstitute.Core; -using NSubstitute.Routing.Handlers; -using NSubstitute.Specs.Infrastructure; -using NUnit.Framework; - -namespace NSubstitute.Specs.Routing.Handlers -{ - public class ReturnDefaultForReturnTypeHandlerSpecs - { - public class When_handling_a_call : ConcernFor - { - private readonly object _expectedDefault = new object(); - private IDefaultForType _defaultForType; - ICall _call; - RouteAction _result; - - [Test] - public void Should_return_default_for_type() - { - Assert.That(_result.ReturnValue, Is.SameAs(_expectedDefault)); - - } - public override void Because() - { - _result = sut.Handle(_call); - } - - public override void Context() - { - var methodInfo = ReflectionHelper.GetMethod(() => NonVoidMethod()); - var returnType = methodInfo.ReturnType; - _call = mock(); - _call.stub(x => x.GetMethodInfo()).Return(methodInfo); - - _defaultForType = mock(); - _defaultForType.stub(x => x.GetDefaultFor(returnType)).Return(_expectedDefault); - } - - public override ReturnDefaultForReturnTypeHandler CreateSubjectUnderTest() - { - return new ReturnDefaultForReturnTypeHandler(_defaultForType); - } - - private object NonVoidMethod() { return null; } - } - } -} \ No newline at end of file diff --git a/tests/NSubstitute.Specs/Routing/Handlers/ReturnResultForTypeHandlerSpecs.cs b/tests/NSubstitute.Specs/Routing/Handlers/ReturnResultForTypeHandlerSpecs.cs deleted file mode 100644 index 43da13fd4..000000000 --- a/tests/NSubstitute.Specs/Routing/Handlers/ReturnResultForTypeHandlerSpecs.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System; -using NSubstitute.Core; -using NSubstitute.Routing.Handlers; -using NSubstitute.Specs.Infrastructure; -using NUnit.Framework; - -namespace NSubstitute.Specs.Routing.Handlers -{ - public class ReturnResultForTypeHandlerSpecs - { - public abstract class When_handling_call : ConcernFor - { - protected IResultsForType _resultsForType; - protected ICall _call; - protected RouteAction _result; - - public override void Context() - { - _call = mock(); - _resultsForType = mock(); - } - - public override void Because() - { - _result = sut.Handle(_call); - } - - public override ReturnResultForTypeHandler CreateSubjectUnderTest() - { - return new ReturnResultForTypeHandler(_resultsForType); - } - } - - public class When_handling_call_with_configured_result : When_handling_call - { - private readonly object _expectedResult = new object(); - - [Test] - public void Should_return_configured_result() - { - Assert.That(_result.ReturnValue, Is.SameAs(_expectedResult)); - } - - public override void Context() - { - base.Context(); - _resultsForType.stub(x => x.HasResultFor(_call)).Return(true); - _resultsForType.stub(x => x.GetResult(_call)).Return(_expectedResult); - } - } - - public class When_handling_call_without_configured_result : When_handling_call - { - readonly Type _returnType = typeof(object); - - [Test] - public void Should_continue_route() - { - Assert.That(_result, Is.SameAs(RouteAction.Continue())); - } - - public override void Context() - { - base.Context(); - _resultsForType.stub(x => x.HasResultFor(_call)).Return(false); - _call.stub(x => x.GetReturnType()).Return(_returnType); - } - } - } -} \ No newline at end of file diff --git a/tests/NSubstitute.Specs/Routing/Handlers/SetActionsForCallHandlerSpecs.cs b/tests/NSubstitute.Specs/Routing/Handlers/SetActionsForCallHandlerSpecs.cs deleted file mode 100644 index 148a04cb2..000000000 --- a/tests/NSubstitute.Specs/Routing/Handlers/SetActionsForCallHandlerSpecs.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using NSubstitute.Core; -using NSubstitute.Routing.Handlers; -using NSubstitute.Specs.Infrastructure; -using NUnit.Framework; - -namespace NSubstitute.Specs.Routing.Handlers -{ - public class SetActionsForCallHandlerSpecs - { - public class When_handling_a_call : ConcernFor - { - private ICallActions _callActions; - private Action _action; - private ICall _call; - private ICallSpecificationFactory _callSpecificationFactory; - private ICallSpecification _callSpec; - private MatchArgs _matchArgs; - private RouteAction _result; - - [Test] - public void Should_add_action_for_specified_call_to_call_actions() - { - _callActions.received(x => x.Add(_callSpec, _action)); - } - - [Test] - public void Should_continue_route() - { - Assert.That(_result, Is.SameAs(RouteAction.Continue())); - } - - public override void Because() - { - _result = sut.Handle(_call); - } - - public override void Context() - { - _call = mock(); - _action = args => { }; - _callActions = mock(); - _callSpec = mock(); - _matchArgs = MatchArgs.AsSpecifiedInCall; - - _callSpecificationFactory = mock(); - _callSpecificationFactory.stub(x => x.CreateFrom(_call, _matchArgs)).Return(_callSpec); - } - - public override SetActionForCallHandler CreateSubjectUnderTest() - { - return new SetActionForCallHandler(_callSpecificationFactory, _callActions, _action, _matchArgs); - } - } - } -} \ No newline at end of file diff --git a/tests/NSubstitute.Specs/Routing/RouteSpecs.cs b/tests/NSubstitute.Specs/Routing/RouteSpecs.cs deleted file mode 100644 index 27edf26ae..000000000 --- a/tests/NSubstitute.Specs/Routing/RouteSpecs.cs +++ /dev/null @@ -1,47 +0,0 @@ -using NSubstitute.Core; -using NSubstitute.Routing; -using NSubstitute.Specs.Infrastructure; -using NUnit.Framework; - -namespace NSubstitute.Specs.Routing -{ - public class RouteSpecs - { - public class When_handling_a_call : ConcernFor - { - private object _result; - private ICall _call; - private ICallHandler _firstHandler; - private ICallHandler _secondHandler; - private readonly object _valueToReturn = new object(); - private ICallHandler[] _handlers; - - [Test] - public void Should_return_result_from_when_a_handler_provides_a_result() - { - Assert.That(_result, Is.SameAs(_valueToReturn)); - } - - public override void Because() - { - _result = sut.Handle(_call); - } - - public override void Context() - { - _call = mock(); - _firstHandler = mock(); - _firstHandler.stub(x => x.Handle(_call)).Return(RouteAction.Continue()); - _secondHandler = mock(); - _secondHandler.stub(x => x.Handle(_call)).Return(RouteAction.Return(_valueToReturn)); - - _handlers = new[] { _firstHandler, _secondHandler }; - } - - public override Route CreateSubjectUnderTest() - { - return new Route(_handlers); - } - } - } -} \ No newline at end of file