public static void UsingInMemoryFubuRequest()
 {
     // SAMPLE: using-in-memory-fubu-request
     var request = new InMemoryFubuRequest();
     request.Set(new PrivateMessage{Name = "Darth Vader"});
     // ENDSAMPLE
 }
Beispiel #2
0
        public void if_converter_cannot_handle_existing_value_type_use_fuburequest()
        {
            var model = new Model();

            theFubuRequest.Set(model);

            theRequest.Value(typeof(Model), "anything").ShouldBeTheSameAs(model);
        }
        public void SetUp()
        {
            var request = new InMemoryFubuRequest();
            var container = StructureMapContainerFacility.GetBasicFubuContainer().GetNestedContainer();
            container.Inject<IFubuRequest>(request);

            theEtagRequest = new ETagRequest();
            theTarget = new Target();

            request.Set(theEtagRequest);
            request.Set(theTarget);

            // The FubuTupleBinder should be registered by default
            var binder = container.GetInstance<IObjectResolver>();

            theTuple = binder.BindModel(typeof (ETagTuple), new InMemoryRequestData()).Value.ShouldBeOfType<ETagTuple>();
        }
        protected override void beforeEach()
        {
            theRequest = new InMemoryFubuRequest();

            theContinuation = FubuContinuation.EndWithStatusCode(HttpStatusCode.NotModified);
            theRequest.Set(theContinuation);

            Services.Inject <IFubuRequest>(theRequest);
        }
Beispiel #5
0
        public void SetUp()
        {
            var request   = new InMemoryFubuRequest();
            var container = StructureMapContainerFacility.GetBasicFubuContainer().GetNestedContainer();

            container.Inject <IFubuRequest>(request);

            theEtagRequest = new ETagRequest();
            theTarget      = new Target();

            request.Set(theEtagRequest);
            request.Set(theTarget);

            // The FubuTupleBinder should be registered by default
            var binder = container.GetInstance <IObjectResolver>();

            theTuple = binder.BindModel(typeof(ETagTuple), new InMemoryRequestData()).Value.ShouldBeOfType <ETagTuple>();
        }
        public void SetUp()
        {
            request = new InMemoryFubuRequest();
            writer = MockRepository.GenerateMock<IOutputWriter>();

            request.Set("some html");

            var behavior = new RenderHtmlBehavior(writer, request);
            behavior.Invoke();
        }
Beispiel #7
0
        protected override void beforeEach()
        {
            _theServices = MockRepository.GenerateMock <IServiceLocator>();

            _theRequest = new InMemoryFubuRequest();
            _theRequest.Set(new SubclassTestModelForActivation());
            _theServices.Stub(x => x.GetInstance <IFubuRequest>()).Return(_theRequest);
            _simpleFubuPage = new SimpleFubuPage <TestModelForActivation>();
            ClassUnderTest.Activate(_theServices, _simpleFubuPage);
        }
        public void SetUp()
        {
            request = new InMemoryFubuRequest();
            writer = MockRepository.GenerateMock<IOutputWriter>();

            request.Set("some text");

            var behavior = new RenderTextBehavior<string>(writer, request, MimeType.Html);
            behavior.Invoke();
        }
Beispiel #9
0
        public static void UsingInMemoryFubuRequest()
        {
            // SAMPLE: using-in-memory-fubu-request
            var request = new InMemoryFubuRequest();

            request.Set(new PrivateMessage {
                Name = "Darth Vader"
            });
            // ENDSAMPLE
        }
Beispiel #10
0
        protected override void beforeEach()
        {
            theMessage = new Message1();
            theRequest = new InMemoryFubuRequest();
            theRequest.Set(theMessage);
            Services.Inject <IFubuRequest>(theRequest);

            ClassUnderTest.InsideBehavior = MockFor <IActionBehavior>();

            ClassUnderTest.Invoke();
        }
        protected override void beforeEach()
        {
            document = new HtmlDocument();
            var request = new InMemoryFubuRequest();

            Services.Inject <IFubuRequest>(request);

            request.Set(document);

            ClassUnderTest.Invoke();
        }
Beispiel #12
0
        public void SetUp()
        {
            request = new InMemoryFubuRequest();
            writer  = MockRepository.GenerateMock <IOutputWriter>();

            request.Set("some html");

            var behavior = new RenderHtmlBehavior(writer, request);

            behavior.Invoke();
        }
Beispiel #13
0
        public void activate_a_fubu_page_with_a_model_on_it()
        {
            var input = new FubuPageTarget();

            theRequest.Set(input);

            var theModelPage = MockRepository.GenerateMock <IFubuPage <FubuPageTarget> >();

            theActivator.Activate(theModelPage);

            theModelPage.AssertWasCalled(x => x.Model = input);
        }
Beispiel #14
0
        public void find_values_invokes_the_fubu_request()
        {
            var request = new InMemoryFubuRequest();
            var address = new Address();

            request.Set(address);

            var source = new ValueSource <Address>(request);

            source.FindValues().ShouldBeOfType <SimpleValues <Address> >()
            .Subject.ShouldBeTheSameAs(address);
        }
Beispiel #15
0
        public void SetUp()
        {
            request = new InMemoryFubuRequest();
            writer  = MockRepository.GenerateMock <IOutputWriter>();


            request.Set("some text");

            var behavior = new RenderTextBehavior <string>(writer, request, MimeType.Html);

            behavior.Invoke();
        }
        public void find_values_invokes_the_fubu_request()
        {
            var request = new InMemoryFubuRequest();
            var address = new Address();

            request.Set(address);

            var source = new ValueSource<Address>(request);

            source.FindValues().ShouldBeOfType<SimpleValues<Address>>()
                .Subject.ShouldBeTheSameAs(address);
        }
Beispiel #17
0
        protected override void beforeEach()
        {
            var repository = new InMemoryRepository(null);

            Services.Inject <IRepository>(repository);

            _fubuRequest = new InMemoryFubuRequest();
            _requestedId = Guid.NewGuid();
            _fubuRequest.Set(new ItemRequest {
                Id = _requestedId
            });
            Services.Inject <IFubuRequest>(_fubuRequest);
        }
        public StructureMapPageHarness(IContainer container)
            : base(new T(), new SimpleFubuPage <T>())
        {
            Container = container;
            Request   = new InMemoryFubuRequest();
            container.Inject(Request);

            Request.Set(Model);

            Page.ServiceLocator = new StructureMapServiceLocator(Container);

            Page.Model = Model;
        }
Beispiel #19
0
        public StructureMapPageHarness(IContainer container)
            : base(new T(), new FubuPage <T>())
        {
            Container = container;
            Request   = new InMemoryFubuRequest();
            container.Inject(Request);

            Request.Set(Model);

            container.BuildUp(Page);

            Page.SetModel(Request);
        }
Beispiel #20
0
        public void return_values_for_direct_enumerable()
        {
            var enumerable = new AddressValuesEnumerable();

            var request = new InMemoryFubuRequest();

            request.Set(enumerable);

            var source = new DirectFeedSource <AddressValuesEnumerable, Address>(request);

            source.GetValues().Select(x => x.ValueFor(o => o.City))
            .ShouldHaveTheSameElementsAs("Austin", "Dallas", "Houston");
        }
        public void should_execute_the_control_rendering_when_rendering()
        {
            _builder.Stub(b => b.LoadControlFromVirtualPath(null, null))
            .IgnoreArguments()
            .Return(new TestControl());

            _builder.Expect(b => b.ExecuteControl(null, null)).IgnoreArguments();

            _request.Set(new TestViewModel());

            new PartialRenderer(_builder)
            .Render(new TestView(), typeof(TestControl), new TestControlViewModel(), "");

            _builder.VerifyAllExpectations();
        }
Beispiel #22
0
        public void activate_a_fubu_page_with_a_model_on_it()
        {
            var input = new FubuPageTarget();

            theRequest.Set(input);

            var theModelPage = MockRepository.GenerateMock <IFubuPage <FubuPageTarget> >();

            // Gets around a defensive prog. check
            theModelPage.Stub(x => x.Model).Return(input);

            theActivator.Activate(theModelPage);

            theModelPage.AssertWasCalled(x => x.Model = input);
        }
        public void current_context_and_group_with_normal_chain()
        {
            var currentChain = MockRepository.GenerateMock<ICurrentChain>();
            currentChain.Stub(x => x.OriginatingChain).Return(new BehaviorChain());

            var graph = new DiagnosticGraph();
            graph.Add(typeof(DiagnosticChain).Assembly);

            var request = new InMemoryFubuRequest();
            request.Set(new GroupRequest{Name = "FubuMVC.Diagnostics"});

            var context = new DiagnosticContext(currentChain, request, graph);

            context.CurrentChain().ShouldBeNull();
            context.CurrentGroup().Name.ShouldEqual("FubuMVC.Diagnostics");
        }
        public InvocationContext(Envelope envelope, HandlerChain chain)
        {
            if (envelope == null) throw new ArgumentNullException("envelope");

            var currentChain = new CurrentChain(chain, _emptyDictionary);
            Set(typeof(ICurrentChain), currentChain);

            _envelope = envelope;
            var inputType = envelope.Message.GetType();
            var request = new InMemoryFubuRequest();
            request.Set(inputType, _envelope.Message);

            Set(typeof(IFubuRequest), request);
            Set(typeof(IInvocationContext), this);
            Set(typeof(Envelope), envelope);
        }
Beispiel #25
0
        protected override void beforeEach()
        {
            var repository = new InMemoryRepository(null);

            Services.Inject <IRepository>(repository);


            _site = new Site();
            repository.Save(_site);


            _fubuRequest = new InMemoryFubuRequest();
            _fubuRequest.Set(new ItemRequest {
                Id = _site.Id
            });
            Services.Inject <IFubuRequest>(_fubuRequest);

            ClassUnderTest.Invoke();
        }
Beispiel #26
0
        protected override void beforeEach()
        {
            Action <ITargetHandler, Input> action = (c, i) => c.OneInZeroOut(i);

            Services.Inject(action);

            theInput = new SpecialInput();

            var request = new InMemoryFubuRequest();

            request.Set(theInput);
            Services.Inject <IFubuRequest>(request);

            MockFor <ITargetHandler>().Expect(x => x.OneInZeroOut(theInput));

            ClassUnderTest.InsideBehavior = MockFor <IActionBehavior>();

            ClassUnderTest.Invoke();
        }
Beispiel #27
0
        protected override void beforeEach()
        {
            Func <ITargetHandler, Input, Output> func = (c, i) => c.OneInOneOut(i);

            Services.Inject <Func <ITargetHandler, Input, Output> >(func);

            theInput       = new SpecialInput();
            expectedOutput = new Output();

            var request = new InMemoryFubuRequest();

            request.Set(theInput);
            Services.Inject <IFubuRequest>(request);

            MockFor <ITargetHandler>().Expect(x => x.OneInOneOut(theInput)).Return(expectedOutput);

            ClassUnderTest.InsideBehavior = MockFor <IActionBehavior>();

            ClassUnderTest.Invoke();
        }
        public InvocationContext(Envelope envelope, HandlerChain chain)
        {
            if (envelope == null)
            {
                throw new ArgumentNullException("envelope");
            }

            var currentChain = new CurrentChain(chain, _emptyDictionary);

            Set(typeof(ICurrentChain), currentChain);

            _envelope = envelope;
            var inputType = envelope.Message.GetType();
            var request   = new InMemoryFubuRequest();

            request.Set(inputType, _envelope.Message);

            Set(typeof(IFubuRequest), request);
            Set(typeof(IInvocationContext), this);
            Set(typeof(Envelope), envelope);
        }
        protected override void beforeEach()
        {
            theMessage = new Message1();

            var request = new InMemoryFubuRequest();

            request.Set(theMessage);
            Services.Inject <IFubuRequest>(request);

            theInitialState = new SagaState();

            theHandler = MockFor <ITestingSagaHandler>();

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

            theRepository = MockFor <ISagaRepository <SagaState, Message1> >();

            theContextIs();

            ClassUnderTest.Invoke();
        }
        public void SetUp()
        {
            _page = MockRepository.GenerateMock<IFubuPage<InputModel>>();
            _renderer = MockRepository.GenerateStub<IPartialRenderer>();
            var serviceLocator = MockRepository.GenerateStub<IServiceLocator>();
            var namingConvention = MockRepository.GenerateStub<IElementNamingConvention>();
            _tags = new TagGenerator<InputModel>(new TagProfileLibrary(), namingConvention,
                                                 serviceLocator);

            _viewTypeRegistry = MockRepository.GenerateStub<IPartialViewTypeRegistry>();
            serviceLocator.Stub(s => s.GetInstance<IPartialViewTypeRegistry>()).Return(_viewTypeRegistry);

            var inMemoryFubuRequest = new InMemoryFubuRequest();
            inMemoryFubuRequest.Set(new InputModel());

            _page.Stub(s => s.Get<IFubuRequest>()).Return(inMemoryFubuRequest);

            _model = new InputModel{Partials=new List<PartialModel>{new PartialModel()}};
            _page.Expect(p => p.Get<ITagGenerator<InputModel>>()).Return(_tags);
            _page.Expect(p => p.Model).Return(_model);
            _page.Expect(p => p.Get<IPartialRenderer>()).Return(_renderer);
            _page.Expect(p => p.ServiceLocator).Return(serviceLocator);
        }
        public void SetUp()
        {
            _mocks = new MockRepository();
            _view = MockRepository.GenerateStub<IFubuPage>();
            _partialView = MockRepository.GenerateStub<IFubuPage>();
            _request = new InMemoryFubuRequest();
            _renderer = MockRepository.GenerateMock<IPartialRenderer>();

            _model = new TestModel();
            _partialModel = new PartialTestModel();

            _model.PartialModel = _partialModel;

            _request.Set(_model);

            _expression = new RenderPartialExpression<TestModel>(_view, _renderer, _request);
            _expression.Using<IFubuPage>(v => { _wasCalled = true; });
        }