public void ExpectRegistrarDispatchContextCanBeOverridden(RouteRegistrar registrar, Guid token)
        {
            var module  = new StubModule();
            var service = CreateStubServiceToReturn(token);
            var factory = CreateStubServiceFactoryFor(service);

            registrar
            .WithDispatchContext(x => x.WithServiceFactory(factory))
            .RegisterServiceInto(module, typeof(StubService));

            new Browser(with => with.Module(module)).Get <Guid>("/whatever").Should().Be(token);
        }
		public void ExpectRegistrarDispatchContextCanBeOverridden(RouteRegistrar registrar, Guid token)
		{
			var module = new StubModule();
			var service = CreateStubServiceToReturn(token);
			var factory = CreateStubServiceFactoryFor(service);

			registrar
				.WithDispatchContext(x => x.WithServiceFactory(factory))
				.RegisterServiceInto(module, typeof(StubService));

			new Browser(with => with.Module(module)).Get<Guid>("/whatever").Should().Be(token);
		}
		public void ExpectMethodCannotBeOverriddenByModifyingDispatchContext(RouteRegistrar registrar, Guid goodToken, Guid badToken)
		{
			var module = new StubModule();
			var service = CreateStubServiceToReturn(goodToken);
			service.Stub(x => x.StubNonServiceMethod(Arg<Request>.Is.Anything)).Return(badToken);
			var factory = CreateStubServiceFactoryFor(service);

			registrar
				.WithDispatchContext(x => x
					.WithServiceFactory(factory)
					.WithMethod(InfoOf.Method<StubService>(svc => svc.StubNonServiceMethod(null))))
				.RegisterServiceInto(module, typeof(StubService));

			new Browser(with => with.Module(module)).Get<Guid>("/whatever").Should().Be(goodToken);
		}
        public void ExpectMethodCannotBeOverriddenByModifyingDispatchContext(RouteRegistrar registrar, Guid goodToken, Guid badToken)
        {
            var module  = new StubModule();
            var service = CreateStubServiceToReturn(goodToken);

            service.Stub(x => x.StubNonServiceMethod(Arg <Request> .Is.Anything)).Return(badToken);
            var factory = CreateStubServiceFactoryFor(service);

            registrar
            .WithDispatchContext(x => x
                                 .WithServiceFactory(factory)
                                 .WithMethod(InfoOf.Method <StubService>(svc => svc.StubNonServiceMethod(null))))
            .RegisterServiceInto(module, typeof(StubService));

            new Browser(with => with.Module(module)).Get <Guid>("/whatever").Should().Be(goodToken);
        }
        public void ExpectOverridingRegistrarDispatchContextMultipleTimesInheritsSettingsFromPreviousContext(RouteRegistrar registrar, Guid token)
        {
            var module  = new StubModule();
            var service = new StubService();
            var factory = MockRepository.GenerateMock <Func <Type, object> >();

            factory.Stub(x => x(Arg <Type> .Is.Anything)).Return(service);

            registrar
            .WithDispatchContext(x => x.WithServiceFactory(factory))
            .WithDispatchContext(x => x.WithDefaultResponse(token))
            .RegisterServiceInto(module, typeof(StubService));

            new Browser(with => with.Module(module)).Get <Guid>("/void").Should().Be(token);
            factory.AssertWasCalled(x => x(Arg <Type> .Is.Equal(typeof(StubService))), x => x.Repeat.Once());
        }
        public void ExpectOriginalDispatchContextRemainsUnmodifiedWhenOverridden(RouteRegistrar registrar, Guid token)
        {
            var module  = new StubModule();
            var factory = MockRepository.GenerateMock <Func <Type, object> >();

            registrar
            .WithDispatchContext(x => x.WithServiceFactory(factory))
            .RegisterServiceInto(module, typeof(StubService));

            var anotherModule = new StubModule();

            registrar.RegisterServiceInto(anotherModule, typeof(StubService));

            new Browser(with => with.Module(anotherModule)).Get <object>("/whatever");
            factory.AssertWasNotCalled(x => x(Arg <Type> .Is.Anything));
        }
		public void ExpectOverridingRegistrarDispatchContextMultipleTimesInheritsSettingsFromPreviousContext(RouteRegistrar registrar, Guid token)
		{
			var module = new StubModule();
			var service = new StubService();
			var factory = MockRepository.GenerateMock<Func<Type, object>>();
			factory.Stub(x => x(Arg<Type>.Is.Anything)).Return(service);

			registrar
				.WithDispatchContext(x => x.WithServiceFactory(factory))
					.WithDispatchContext(x => x.WithDefaultResponse(token))
					.RegisterServiceInto(module, typeof(StubService));

			new Browser(with => with.Module(module)).Get<Guid>("/void").Should().Be(token);
			factory.AssertWasCalled(x => x(Arg<Type>.Is.Equal(typeof(StubService))), x => x.Repeat.Once());
		}
		public void ExpectOriginalDispatchContextRemainsUnmodifiedWhenOverridden(RouteRegistrar registrar, Guid token)
		{
			var module = new StubModule();
			var factory = MockRepository.GenerateMock<Func<Type, object>>();

			registrar
				.WithDispatchContext(x => x.WithServiceFactory(factory))
				.RegisterServiceInto(module, typeof(StubService));

			var anotherModule = new StubModule();
			registrar.RegisterServiceInto(anotherModule, typeof(StubService));

			new Browser(with => with.Module(anotherModule)).Get<object>("/whatever");
			factory.AssertWasNotCalled(x => x(Arg<Type>.Is.Anything));
		}
コード例 #9
0
		public void WithDispatchContext_Called_ExpectReturnedRegistrarIsNotTheSameInstanceAsCalledOn(RouteRegistrar registrar)
		{
			registrar.WithDispatchContext(x => x).Should().NotBeSameAs(registrar);
		}
コード例 #10
0
 public void WithDispatchContext_Called_ExpectReturnedRegistrarIsNotTheSameInstanceAsCalledOn(RouteRegistrar registrar)
 {
     registrar.WithDispatchContext(x => x).Should().NotBeSameAs(registrar);
 }