예제 #1
0
        protected override void beforeEach()
        {
            theRequest = new TwitterLoginRequest {
                Url = "hello/there"
            };

            MockFor <IFubuRequest>().Stub(x => x.Get <TwitterLoginRequest>()).Return(theRequest);

            theLoginBehavior = MockFor <IActionBehavior>();

            var chain = new BehaviorChain();

            chain.AddToEnd(ActionCall.For <LoginController>(x => x.get_login(null)));

            var graph = new BehaviorGraph();

            graph.AddChain(chain);

            Services.Inject(graph);

            MockFor <IPartialFactory>().Stub(x => x.BuildPartial(chain)).Return(theLoginBehavior);

            ClassUnderTest.Failure();

            theLoginRequest = (LoginRequest)MockFor <IFubuRequest>().GetArgumentsForCallsMadeOn(x => x.Set(Arg <LoginRequest> .Is.NotNull))[0][0];
        }
예제 #2
0
 public RequestOutputCacheBehavior(IFubuRequest request, IRequestOutputCache <TInputModel> cache, IOutputWriter writer, IActionBehavior inner)
 {
     _request = request;
     _writer  = writer;
     _inner   = inner;
     _cache   = cache;
 }
예제 #3
0
 public DiagnosticBehavior(IDebugReport report, IDebugDetector detector, IActionBehavior inner, IUrlRegistry urls)
 {
     _report   = report;
     _detector = detector;
     _inner    = inner;
     _urls     = urls;
 }
        protected override sealed void beforeEach()
        {
            theInsideBehavior             = MockRepository.GenerateMock <IActionBehavior>();
            ClassUnderTest.InsideBehavior = theInsideBehavior;

            theContextIs();
        }
예제 #5
0
        protected override void beforeEach()
        {
            MockFor <PartialBehaviorProvider>().Expect(x => x()).Return(PartialBehavior.Executes);

            InnerBehavior = MockFor <IActionBehavior>();
            ClassUnderTest.InsideBehavior = InnerBehavior;
        }
예제 #6
0
 public DiagnosticBehavior(IDebugReport report, IDebugDetector detector, IActionBehavior inner, IUrlRegistry urls)
 {
     _report = report;
     _detector = detector;
     _inner = inner;
     _urls = urls;
 }
예제 #7
0
        public void SetUp()
        {
            path = new ViewPath
            {
                ViewName = "something"
            };

            var render = new WebFormView(path.ViewName);
            var container = new Container(x =>
            {
                x.For<IActionBehavior>().Use(new ObjectDefInstance(render.As<IContainerModel>().ToObjectDef(DiagnosticLevel.None)));
                x.For<IWebFormsControlBuilder>().Use<WebFormsControlBuilder>();
                x.For<IWebFormRenderer>().Use<WebFormRenderer>();
                x.For<HttpContextBase>().Use(() => new FakeHttpContext());
                x.For<IOutputWriter>().Use<OutputWriter>();
                x.For<IFubuRequest>().Use<InMemoryFubuRequest>();
                x.For<IPageActivator>().Use<PageActivator>();
                x.For<IPageActivationRules>().Use<PageActivationRuleCache>();
                x.For<IServiceLocator>().Use<StructureMapServiceLocator>();
                x.For<IHttpWriter>().Use(new NulloHttpWriter());
                x.For<IFileSystem>().Use<FileSystem>();

            });

            behavior = container.GetInstance<IActionBehavior>();
        }
예제 #8
0
 public ConnegBehavior(IFubuRequest request, IActionBehavior inner, IConnegInputHandler inputHandler, IConnegOutputHandler outputHandler)
 {
     _request       = request;
     _inner         = inner;
     _inputHandler  = inputHandler;
     _outputHandler = outputHandler;
 }
예제 #9
0
 protected override void beforeEach()
 {
     exception = new NotImplementedException();
     inner     = MockFor <IActionBehavior>();
     inner.Expect(x => x.Invoke()).Throw(exception);
     MockFor <IDebugDetector>().Stub(x => x.IsDebugCall()).Return(false);
 }
예제 #10
0
 public ChromeBehavior(IPartialInvoker partials, IActionBehavior inner, IOutputWriter writer, Action <ChromeContent> customization)
 {
     _partials      = partials;
     _inner         = inner;
     _writer        = writer;
     _customization = customization;
 }
예제 #11
0
        protected override void beforeEach()
        {
            Services.Inject <IExceptionHandlingObserver>(new ExceptionHandlingObserver());

            theInnerBehavior     = MockFor <IActionBehavior>();
            ClassUnderTest.Inner = theInnerBehavior;
        }
예제 #12
0
        protected override void beforeEach()
        {
            inner = MockFor <IActionBehavior>();

            ClassUnderTest.Inner = inner;
            ClassUnderTest.InvokePartial();
        }
예제 #13
0
        public void TransferToCall(ActionCall call, string categoryOrHttpMethod = null)
        {
            var chain = _resolver.Find(call.HandlerType, call.Method, categoryOrHttpMethod);

            IActionBehavior partial = _factory.BuildBehavior(chain);

            partial.InvokePartial();
        }
예제 #14
0
        protected override void beforeEach()
        {
            inner = MockFor <IActionBehavior>();
            MockFor <IDebugReport>().Stub(x => x.StartBehavior(inner)).Return(new BehaviorReport(inner));

            ClassUnderTest.Inner = inner;
            ClassUnderTest.InvokePartial();
        }
예제 #15
0
 public FullChainSwitcher(IActionBehavior inner,
                          ICurrentChain chainStack,
                          BehaviorChain targetChain)
 {
     Inner        = inner;
     _chainStack  = chainStack;
     _targetChain = targetChain;
 }
예제 #16
0
        public void SetUp()
        {
            theCorrelator   = MockRepository.GenerateStub <ICorrelateRequests>();
            theNextBehavior = MockRepository.GenerateStub <IActionBehavior>();

            theBehavior = new SetCorrelationHeaders(theCorrelator, theNextBehavior);
            theBehavior.Invoke();
        }
 public EnsureFeatureIsEnabled(IFubuRequest fubuRequest, IActionBehavior innerBehavior, ICurrentHttpRequest currentHttpRequest, IHandle404 handle404, IFeatureValidator featureValidator)
 {
     _fubuRequest        = fubuRequest;
     _innerBehavior      = innerBehavior;
     _currentHttpRequest = currentHttpRequest;
     _handle404          = handle404;
     _featureValidator   = featureValidator;
 }
예제 #18
0
 public FullChainSwitcher(IActionBehavior inner,
                          ICurrentChain chainStack,
                          BehaviorChain targetChain)
 {
     Inner = inner;
     _chainStack = chainStack;
     _targetChain = targetChain;
 }
예제 #19
0
        protected override void beforeEach()
        {
            theCurrentRequest = new CurrentRequest();
            MockFor <IFubuRequest>().Stub(x => x.Get <CurrentRequest>()).Return(theCurrentRequest);

            theInnerBehavior     = MockFor <IActionBehavior>();
            ClassUnderTest.Inner = theInnerBehavior;
        }
		public void SetUp()
		{
			theCorrelator = MockRepository.GenerateStub<ICorrelateRequests>();
			theNextBehavior = MockRepository.GenerateStub<IActionBehavior>();

			theBehavior = new SetCorrelationHeaders(theCorrelator, theNextBehavior);
			theBehavior.Invoke();
		}
예제 #21
0
 public AuthorizationBehavior(
     IOutputWriter writer,
     IActionBehavior actionBehavior,
     ISecureSession<Token> secureSession)
 {
     _writer = writer;
     _actionBehavior = actionBehavior;
     _secureSession = secureSession;
 }
예제 #22
0
 public ExceptionHandlerBehavior(
     IActionBehavior innerBehavior,
     ILogger logger,
     IOutputWriter outputWriter)
 {
     _innerBehavior = innerBehavior;
     _logger = logger;
     _outputWriter = outputWriter;
 }
예제 #23
0
        protected override void beforeEach()
        {
            theTarget = BehaviorChain.For <ControllerTarget>(x => x.ZeroInOneOut());
            theChain  = MockFor <ICurrentChain>();
            theInner  = MockFor <IActionBehavior>();

            Container.Inject(theTarget);
            ClassUnderTest.InvokePartial();
        }
예제 #24
0
        protected override void beforeEach()
        {
            PartialBehaviorProvider provider = () => PartialBehavior.Ignored;

            Container.Configure(x => x.For(typeof(PartialBehaviorProvider)).Use(provider));

            InnerBehavior = MockFor <IActionBehavior>();
            ClassUnderTest.InsideBehavior = InnerBehavior;
        }
예제 #25
0
 protected override void Invoke(IActionBehavior behavior)
 {
     var task = Task.Factory.StartNew(behavior.Invoke, TaskCreationOptions.AttachedToParent);
     var disposable = behavior as IDisposable;
     if (disposable != null)
     {
         task.ContinueWith(x => disposable.Dispose(), TaskContinuationOptions.AttachedToParent);
     }
 }
예제 #26
0
 public ExceptionHandlerBehavior(IActionBehavior behavior, HandlerChain chain, Envelope envelope, IInvocationContext context, ILogger logger, IFubuRequest request)
 {
     _behavior = behavior;
     _chain    = chain;
     _envelope = envelope;
     _context  = context;
     _logger   = logger;
     _request  = request;
 }
예제 #27
0
        public override void LoadFrom(YamlMappingNode mapping)
        {
            base.LoadFrom(mapping);
            var serializer = YamlObjectSerializer.NewReader(mapping);

            serializer.DataField(this, x => x.ActionType, "actionType", ActionType.Error);
            if (ActionType == ActionType.Error)
            {
                Logger.ErrorS("action", "missing or invalid actionType for action with name {0}", Name);
            }

            // TODO: Split this class into server/client after RobustToolbox#1405
            if (IoCManager.Resolve <IModuleManager>().IsClientModule)
            {
                return;
            }

            IActionBehavior behavior = null;

            serializer.DataField(ref behavior, "behavior", null);
            switch (behavior)
            {
            case null:
                BehaviorType = BehaviorType.None;
                Logger.ErrorS("action", "missing or invalid behavior for action with name {0}", Name);
                break;

            case IInstantAction instantAction:
                ValidateBehaviorType(BehaviorType.Instant, typeof(IInstantAction));
                BehaviorType  = BehaviorType.Instant;
                InstantAction = instantAction;
                break;

            case IToggleAction toggleAction:
                ValidateBehaviorType(BehaviorType.Toggle, typeof(IToggleAction));
                BehaviorType = BehaviorType.Toggle;
                ToggleAction = toggleAction;
                break;

            case ITargetEntityAction targetEntity:
                ValidateBehaviorType(BehaviorType.TargetEntity, typeof(ITargetEntityAction));
                BehaviorType       = BehaviorType.TargetEntity;
                TargetEntityAction = targetEntity;
                break;

            case ITargetPointAction targetPointAction:
                ValidateBehaviorType(BehaviorType.TargetPoint, typeof(ITargetPointAction));
                BehaviorType      = BehaviorType.TargetPoint;
                TargetPointAction = targetPointAction;
                break;

            default:
                BehaviorType = BehaviorType.None;
                Logger.ErrorS("action", "unrecognized behavior type for action with name {0}", Name);
                break;
            }
        }
예제 #28
0
 public ExceptionHandlerBehavior(IActionBehavior behavior, HandlerChain chain, Envelope envelope, IInvocationContext context, ILogger logger, IFubuRequest request)
 {
     _behavior = behavior;
     _chain = chain;
     _envelope = envelope;
     _context = context;
     _logger = logger;
     _request = request;
 }
예제 #29
0
        protected override void theContextIs()
        {
            call    = ActionCall.For <ControllerTarget>(x => x.ZeroInOneOut());
            partial = MockRepository.GenerateMock <IActionBehavior>();

            MockFor <IPartialFactory>().Expect(x => x.BuildPartial(call)).Return(partial);

            ProcessContinuation(FubuContinuation.TransferTo <ControllerTarget>(x => x.ZeroInOneOut()));
        }
예제 #30
0
        protected override void theContextIs()
        {
            partial = MockRepository.GenerateMock <IActionBehavior>();
            input   = new InputModel();

            MockFor <IPartialFactory>().Expect(x => x.BuildPartial(typeof(InputModel))).Return(partial);

            ProcessContinuation(FubuContinuation.TransferTo(input));
        }
예제 #31
0
        public IHttpHandler GetHttpHandler(RequestContext requestContext)
        {
            var dictionary             = new AggregateDictionary(requestContext);
            ServiceArguments arguments = new ServiceArguments().With(dictionary);

            IActionBehavior behavior = GetBehavior(arguments);

            return(new FubuHttpHandler(behavior));
        }
예제 #32
0
        protected override void beforeEach()
        {
            exception = new NotImplementedException();
            inner     = MockFor <IActionBehavior>();
            inner.Expect(x => x.Invoke()).Throw(exception);
            MockFor <IDebugDetector>().Stub(x => x.IsOutputWritingLatched()).Return(false);
            MockFor <IDebugReport>().Stub(x => x.StartBehavior(inner)).Return(new BehaviorReport(inner));

            ClassUnderTest.Inner = inner;
        }
        protected override void Invoke(IActionBehavior behavior)
        {
            var task       = Task.Factory.StartNew(behavior.Invoke, TaskCreationOptions.AttachedToParent);
            var disposable = behavior as IDisposable;

            if (disposable != null)
            {
                task.ContinueWith(x => disposable.Dispose(), TaskContinuationOptions.AttachedToParent);
            }
        }
        public OutputCachingBehavior(IActionBehavior inner, IContentCache cache, IOutputWriter writer, IResourceHash resourceHash)
        {
            _inner = inner;
            _cache = cache;
            _writer = writer;
            _resourceHash = resourceHash;

            Invoker = x => x.Invoke();
            PartialInvoker = x => x.InvokePartial();
        }
        public override void Given()
        {
            AspNetSettings.IsCustomErrorsEnabled = false;

            _exception = new Exception("bad things happened");

            _insideBehavior     = MockFor <IActionBehavior>();
            _cut.InsideBehavior = _insideBehavior;
            _insideBehavior.Stub(s => s.Invoke()).Throw(_exception);
        }
예제 #36
0
        protected override void beforeEach()
        {
            exception = new NotImplementedException();
            inner     = MockFor <IActionBehavior>();
            inner.Expect(x => x.InvokePartial()).Throw(exception);
            MockFor <IDebugDetector>().Stub(x => x.IsDebugCall()).Return(true);

            ClassUnderTest.Inner = inner;
            ClassUnderTest.InvokePartial();
        }
예제 #37
0
 public AjaxAuthorizationBehavior(
     IOutputWriter writer,
     IActionBehavior actionBehavior,
     ISecureSession<Token> secureSession,
     IWebServer webServer)
 {
     _writer = writer;
     _actionBehavior = actionBehavior;
     _secureSession = secureSession;
     _webServer = webServer;
 }
예제 #38
0
        protected override void beforeEach()
        {
            theInput  = new PartialInputModel();
            theAction = MockFor <IActionBehavior>();

            MockFor <IFubuRequest>().Stub(x => x.Get <PartialInputModel>()).Return(theInput);
            MockFor <IAuthorizationPreviewService>().Expect(x => x.IsAuthorized(theInput)).Return(false);
            MockFor <IPartialFactory>().Stub(x => x.BuildPartial(typeof(PartialInputModel))).Return(theAction);

            theOutput = ClassUnderTest.InvokeObject(theInput);
        }
        protected override void beforeEach()
        {
            logs        = Services.RecordLogging();
            correlation = new BehaviorCorrelation(new FakeNode());
            Services.Inject(correlation);

            inner = MockFor <IActionBehavior>();
            ClassUnderTest.Inner = inner;

            ClassUnderTest.InvokePartial();
        }
예제 #40
0
        public BehaviorReport StartBehavior(IActionBehavior behavior)
        {
            var report = new BehaviorReport(behavior);

            _behaviors.Add(report);
            _behaviorStack.Push(report);

            AddDetails(new BehaviorStart());

            return(report);
        }
예제 #41
0
        public OutputCachingBehavior(IActionBehavior inner, IOutputCache cache, IOutputWriter writer,
            ICurrentChain currentChain, IEtagCache etagCache)
        {
            _inner = inner;
            _cache = cache;
            _writer = writer;
            _currentChain = currentChain;
            _etagCache = etagCache;

            Invoker = x => x.Invoke();
            PartialInvoker = x => x.InvokePartial();
        }
 public AjaxExceptionHandlerBehavior(
     IActionBehavior innerBehavior,
     IOutputWriter outputWriter,
     ILogger logger,
     IWebServer webServer)
 {
     _innerBehavior = innerBehavior;
     _outputWriter = outputWriter;
     _logger = logger;
     _webServer = webServer;
     ReturnError = Assembly.GetExecutingAssembly().IsInDebugMode();
 }
예제 #43
0
 public LoginResultBehavior(
     IFubuRequest request, 
     IUrlRegistry registry,
     IOutputWriter writer,
     IActionBehavior innerBehavior,
     IPartialFactory factory
 )
 {
     this.request = request;
     this.registry = registry;
     this.writer = writer;
     this.innerBehavior = innerBehavior;
     this.factory = factory;
 }
예제 #44
0
        public void SetUp()
        {
            theFactory = MockRepository.GenerateMock<IServiceFactory>();
            theChain = new RoutedChain("something");

            theRouteData = new Dictionary<string, object>();

            theArguments = new TypeArguments();
            theBehavior = MockRepository.GenerateMock<IActionBehavior>();

            theFactory.Stub(x => x.BuildBehavior(theArguments, theChain.UniqueId))
                .Return(theBehavior);

            theInvoker = new BehaviorInvoker(theFactory, theChain);
        }
예제 #45
0
 protected virtual void Invoke(IActionBehavior behavior)
 {
     try
     {
         behavior.Invoke();
     }
     finally
     {
         var disposable = behavior as IDisposable;
         if(disposable != null)
         {
             disposable.Dispose();
         }
     }
 }
		public void SetUp()
		{
			request   = MockRepository.GenerateStub<IFubuRequest>();
			inner     = MockRepository.GenerateStub<IActionBehavior>();
			viewModel = new RemapViewModel();
			behaviour = new RemapFailedValidationFormValuesBehaviour<RemapInputModel>(request) {InnerBehavior = inner};

			request.Stub(r => r.Get(typeof(RemapViewModel))).Return(viewModel);
			request.Stub(r => r.Get<RemapViewModel>()).Return(viewModel);

			inputModel = new RemapInputModel
			{
				Name = "Jimmy Bogard",
				Age = 150,
				Height = 125
			};
		}
예제 #47
0
        public void SetUp()
        {
            path = new ViewPath
            {
                ViewName = "something"
            };

            var render = new WebFormView(path.ViewName);
            var container = new Container(x =>
            {
                x.For<IActionBehavior>().Use(new ObjectDefInstance(render.As<IContainerModel>().ToObjectDef()));
                x.For<IWebFormsControlBuilder>().Use<WebFormsControlBuilder>();
                x.For<IWebFormRenderer>().Use<WebFormRenderer>();
                x.For<IOutputWriter>().Use<HttpResponseOutputWriter>();
                x.For<IFubuRequest>().Use<InMemoryFubuRequest>();
                x.For<IViewActivator>().Use<NulloViewActivator>();
            });

            behavior = container.GetInstance<IActionBehavior>();
        }
예제 #48
0
 public SSLRedirectBehavior(IActionBehavior innerBehavior, IOutputWriter outputWriter, ICurrentHttpRequest request)
 {
     _innerBehavior = innerBehavior;
     _outputWriter = outputWriter;
     _request = request;
 }
 public PartialLoggingBehavior(IChainExecutionLog log, BehaviorChain chain, IActionBehavior inner) 
 {
     _log = log;
     _chain = chain;
     Inner = inner;
 }
		public SetCorrelationHeaders(ICorrelateRequests correlator, IActionBehavior inner)
			: base(PartialBehavior.Ignored)
		{
			_correlator = correlator;
			InsideBehavior = inner;
		}
 public FakeUnitOfWorkBehavior(IActionBehavior inner)
 {
     _inner = inner;
 }
예제 #52
0
 public ChromeBehavior(IPartialInvoker partials, IActionBehavior inner, IOutputWriter writer)
 {
     _partials = partials;
     _inner = inner;
     _writer = writer;
 }
예제 #53
0
 public CacheBusterBehavior(IActionBehavior innerBehavior)
 {
     _innerBehavior = innerBehavior;
 }
예제 #54
0
 public FubuHttpHandler(IActionBehavior behavior)
 {
     _behavior = behavior;
 }
예제 #55
0
        public void SetUp()
        {
            _page = MockRepository.GenerateStub<IFubuPage>();
            _partialFactory = MockRepository.GenerateStub<IPartialFactory>();
            _behavior = MockRepository.GenerateStub<IActionBehavior>();

            _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);
        }
예제 #56
0
 public MyTransactionBehavior(IActionBehavior inner)
 {
     _inner = inner;
 }
예제 #57
0
 public ConditionalOutput(Func<OutputFormatDetector, bool> condition, IActionBehavior behavior)
 {
     Condition = condition;
     Behavior = behavior;
 }
 public DemoBehaviorForSelectActions(IActionBehavior innerBehavior)
 {
     _innerBehavior = innerBehavior;
 }
 public TransactionScopeBehavior(IActionBehavior innerBehavior, IUnitOfWork unitOfWork)
 {
     _innerBehavior = innerBehavior;
     _unitOfWork = unitOfWork;
 }
예제 #60
0
 public BehaviorTracer(IDebugReport report, IDebugDetector debugDetector, IActionBehavior inner)
 {
     _report = report;
     _debugDetector = debugDetector;
     _inner = inner;
 }