Example #1
0
        public static IUrlRegistry UseStubUrlRegistry <T>(this InteractionContext <T> context) where T : class
        {
            var registry = new StubUrlRegistry();

            context.Services.Inject <IUrlRegistry>(registry);
            return(registry);
        }
Example #2
0
        protected override void beforeEach()
        {
            theChain       = new BehaviorChain();
            theChain.Route = new RouteDefinition("something")
            {
                Input = new RouteInput <FakeInput>("somepattern")
            };


            theNode = new MenuNode(FakeKeys.Key1, r => theChain);
            theNode.Resolve(null);
            theNode.BehaviorChain.ShouldBeTheSameAs(theChain);
            theNode.UrlInput = new object();

            theNode.Icon("some image");

            theNode.Children.AddToEnd(new MenuNode(FakeKeys.Key2));
            theNode.Children.AddToEnd(new MenuNode(FakeKeys.Key3));
            theNode.Children.AddToEnd(new MenuNode(FakeKeys.Key4));

            theIconUrl = "test.png";
            MockFor <IAssetUrls>().Stub(x => x.UrlForAsset(AssetFolder.images, theNode.Icon())).Return(theIconUrl);

            theUrls = new StubUrlRegistry();
            Services.Inject <IUrlRegistry>(theUrls);

            MockFor <IMenuStateService>().Stub(x => x.DetermineStateFor(theNode))
            .Return(MenuItemState.Available);

            MockFor <IChainUrlResolver>().Stub(x => x.UrlFor(theNode.UrlInput, theNode.BehaviorChain))
            .Return("the full url");
        }
Example #3
0
        protected override void beforeEach()
        {
            theChain       = new BehaviorChain();
            theChain.Route = new RouteDefinition("something")
            {
                Input = new RouteInput <FakeInput>("somepattern")
            };


            theNode = new MenuNode(FakeKeys.Key1, r => theChain);
            theNode.Resolve(null);
            theNode.BehaviorChain.ShouldBeTheSameAs(theChain);
            theNode.UrlInput = new object();

            theNode.Icon("some image");

            theNode.Children.AddToEnd(new MenuNode(FakeKeys.Key2));
            theNode.Children.AddToEnd(new MenuNode(FakeKeys.Key3));
            theNode.Children.AddToEnd(new MenuNode(FakeKeys.Key4));

            theUrls = new StubUrlRegistry();
            Services.Inject <IUrlRegistry>(theUrls);

            MockFor <IMenuStateService>().Stub(x => x.DetermineStateFor(theNode))
            .Return(MenuItemState.Available);

            MockFor <ICurrentHttpRequest>().Stub(x => x.ToFullUrl(theNode.CreateUrl()))
            .Return("the full url");

            theToken = ClassUnderTest.BuildToken(theNode);
        }
        public void getting_a_service_delegates_to_the_service_locator()
        {
            var stub = new StubUrlRegistry();

            MockFor <IServiceLocator>().Stub(x => x.GetInstance <IUrlRegistry>()).Return(stub);

            ClassUnderTest.Service <IUrlRegistry>().ShouldBeTheSameAs(stub);
        }
        // TODO -- put this into FubuMVC.TestingSupport or whatever it's called
        public static StubUrlRegistry StubUrls <T>(this RhinoAutoMocker <T> mocker) where T : class
        {
            var urls = new StubUrlRegistry();

            mocker.Inject <IUrlRegistry>(urls);

            return(urls);
        }
Example #6
0
 public void SetUp()
 {
     theChain       = new BehaviorChain();
     theRoutedChain = new RoutedChain("something");
     theUrls        = new StubUrlRegistry();
     _report        = new Lazy <EndpointReport>(() => EndpointReport.ForChain(theChain));
     _routedReport  = new Lazy <EndpointReport>(() => EndpointReport.ForChain(theRoutedChain));
 }
 public void SetUp()
 {
     theChain = new BehaviorChain();
     theRoutedChain = new RoutedChain("something");
     theUrls = new StubUrlRegistry();
     _report = new Lazy<EndpointReport>(() => EndpointReport.ForChain(theChain));
     _routedReport = new Lazy<EndpointReport>(() => EndpointReport.ForChain(theRoutedChain));
 }
Example #8
0
        public IUrlRegistry UseStubUrlRegistry()
        {
            var registry = new StubUrlRegistry();

            Services.Inject <IUrlRegistry>(registry);

            return(registry);
        }
Example #9
0
        public void image_url()
        {
            var page = MockRepository.GenerateMock<IFubuPage>();
            var urls = new StubUrlRegistry();
            page.Stub(x => x.Urls).Return(urls);

            page.ImageUrl("some icon name")
                .ShouldEqual(urls.UrlForAsset(AssetFolder.images, "some icon name"));
        }
        public void running_The_activator_applies_all_topic_registries()
        {
            var urls = new StubUrlRegistry();

            new TopicGraphActivator(urls).Activate(null, new PackageLog());

            TopicGraph.AllTopics.Find <ATopic>().ChildNodes.Select(x => x.Title).ShouldHaveTheSameElementsAs("B", "C");
            TopicGraph.AllTopics.Find <DTopic>().ChildNodes.Select(x => x.Title).ShouldHaveTheSameElementsAs("E");
            TopicGraph.AllTopics.Find <CTopic>().ChildNodes.Select(x => x.Title).ShouldHaveTheSameElementsAs("D");
        }
        public void SetUp()
        {
            _page = MockRepository.GenerateMock<IFubuPage>();
            _urls = new StubUrlRegistry();


            _page.Expect(p => p.Urls).Return(_urls);
            _model = new InputModel();
            //_urls.Stub(u => u.UrlFor(Arg<InputModel>.Is.NotNull)).Return("some url");
        }
Example #12
0
        protected override void beforeEach()
        {
            Services.Inject <IExceptionHandlingObserver>(new ExceptionHandlingObserver());

            theUrls = new StubUrlRegistry();
            Services.Inject <IUrlRegistry>(theUrls);

            theInnerBehavior     = MockFor <IActionBehavior>();
            ClassUnderTest.Inner = theInnerBehavior;
        }
Example #13
0
        public void image_url()
        {
            var page = MockRepository.GenerateMock <IFubuPage>();
            var urls = new StubUrlRegistry();

            page.Stub(x => x.Urls).Return(urls);

            page.ImageUrl("some icon name")
            .ShouldEqual(urls.UrlForAsset(AssetFolder.images, "some icon name"));
        }
Example #14
0
        public void SetUp()
        {
            _page = MockRepository.GenerateMock <IFubuPage>();
            _urls = new StubUrlRegistry();


            _page.Expect(p => p.Urls).Return(_urls);
            _model = new InputModel();
            //_urls.Stub(u => u.UrlFor(Arg<InputModel>.Is.NotNull)).Return("some url");
        }
Example #15
0
        public void should_have_the_url_with_the_querystring()
        {
            var url = new StubUrlRegistry().UrlFor(new NamedGridRequest()
            {
                GridName = theRequest.GridName
            });

            url += theQuerystring;

            theCounts.Url.ShouldEqual(url);
        }
        public void create_a_link()
        {
            var expression = new LinkExpression(x => x.UrlFor(new SomeLinkInput()))
                .Rel("some rel");
            var urls = new StubUrlRegistry();

            var link = expression.As<ILinkCreator>().CreateLink(urls);

            link.Url.ShouldBe(urls.UrlFor(new SomeLinkInput()));

            link.Rel.ShouldBe("some rel");
        }
        public void create_a_link()
        {
            var expression = new LinkExpression(x => x.UrlFor(new SomeLinkInput()))
                             .Rel("some rel");
            var urls = new StubUrlRegistry();

            var link = expression.As <ILinkCreator>().CreateLink(urls);

            link.Url.ShouldBe(urls.UrlFor(new SomeLinkInput()));

            link.Rel.ShouldBe("some rel");
        }
Example #18
0
        protected override void beforeEach()
        {
            MockFor <IServiceLocator>().Stub(x => x.GetInstance <ISmartGridHarness>(typeof(TheTestGrid).NameForGrid()))
            .Return(MockFor <ISmartGridHarness>());

            MockFor <ISmartGridHarness>().Stub(x => x.GetQuerystring()).Return(theQuerystringFromTheHarness);

            theUrls = new StubUrlRegistry();
            Services.Inject <IUrlRegistry>(theUrls);

            theArgs         = new object[] { "a", "b" };
            theResultingUrl = ClassUnderTest.GetUrl <LookupRequest, TheTestGrid>(theArgs);
        }
        public void urls_are_pulled_from_the_service_locator_but_only_once()
        {
            var stub = new StubUrlRegistry();

            MockFor <IServiceLocator>().Stub(x => x.GetInstance <IUrlRegistry>()).Return(stub);

            ClassUnderTest.Urls.ShouldBeTheSameAs(stub);
            ClassUnderTest.Urls.ShouldBeTheSameAs(stub);
            ClassUnderTest.Urls.ShouldBeTheSameAs(stub);
            ClassUnderTest.Urls.ShouldBeTheSameAs(stub);
            ClassUnderTest.Urls.ShouldBeTheSameAs(stub);

            MockFor <IServiceLocator>().AssertWasCalled(x => x.GetInstance <IUrlRegistry>(), x => x.Repeat.Once());
        }
        public void write_url_for_model()
        {
            var urls = new StubUrlRegistry();
            var services = MockRepository.GenerateMock<IServiceLocator>();
            services.Stub(x => x.GetInstance<IUrlRegistry>()).Return(urls);

            theAccessorProjection.WriteUrlFor(age => new CreateValueTarget{
                Name = age.ToString()
            });

            var expectedUrl = urls.UrlFor(new CreateValueTarget{
                Name = "37"
            });

            theAccessorProjection.Write(new ProjectionContext<ValueTarget>(services, _theValues), theMediaNode);

            theMediaNode.Element.GetAttribute("Age").ShouldEqual(expectedUrl);
        }
        public void create_a_context_for_a_different_type()
        {
            var formatter = MockFor <IDisplayFormatter>();

            MockFor <IServiceLocator>().Stub(x => x.GetInstance <IDisplayFormatter>()).Return(formatter);

            var stub = new StubUrlRegistry();

            MockFor <IServiceLocator>().Stub(x => x.GetInstance <IUrlRegistry>()).Return(stub);

            var different = new DifferentTarget();

            var context = ClassUnderTest.ContextFor(different);

            context.Urls.ShouldBeTheSameAs(stub);
            context.Formatter.ShouldBeTheSameAs(formatter);
            context.Subject.ShouldBeTheSameAs(different);
        }
        public void write_url_for_model()
        {
            var urls     = new StubUrlRegistry();
            var services = MockRepository.GenerateMock <IServiceLocator>();

            services.Stub(x => x.GetInstance <IUrlRegistry>()).Return(urls);

            theAccessorProjection.WriteUrlFor(age => new CreateValueTarget {
                Name = age.ToString()
            });

            var expectedUrl = urls.UrlFor(new CreateValueTarget {
                Name = "37"
            });

            theAccessorProjection.As <IProjection <ValueTarget> >().Write(new ProjectionContext <ValueTarget>(services, _theValues), theMediaNode);

            theMediaNode.Element.GetAttribute("Age").ShouldEqual(expectedUrl);
        }
Example #23
0
        public void SetUp()
        {
            var projection = new Projection <Address>(DisplayFormatting.RawValues);

            projection.Value(x => x.Address1);
            projection.Value(x => x.Address2);
            projection.Value(x => x.City);
            projection.Value(x => x.StateOrProvince).Name("State");

            theXmlMediaOptions = new XmlMediaOptions()
            {
                Root = "Address"
            };
            theDocument = new XmlMediaDocument(theXmlMediaOptions);

            var urls = new StubUrlRegistry();

            var linkSource = new LinksSource <Address>();

            linkSource.ToSubject().Rel("self");
            linkSource.To(a => new AddressAction("change")).Rel("change");
            linkSource.To(a => new AddressAction("delete")).Rel("delete");

            theOutput = new InMemoryOutputWriter();

            var media = new MediaWriter <Address>(theDocument, linkSource, urls, projection, null, theOutput);


            theAddress = new Address()
            {
                Address1        = "22 Cherry Lane",
                Address2        = "Apt A",
                City            = "Austin",
                StateOrProvince = "Texas"
            };



            media.Write("text/plain", theAddress);

            Debug.WriteLine(theOutput);
        }
Example #24
0
        protected override void beforeEach()
        {
            MockFor <IHttpRequest>().Stub(x => x.RelativeUrl())
            .Return("the relative url");

            MockFor <IHttpRequest>().Stub(x => x.HttpMethod())
            .Return("PUT");

            LocalSystemTime = DateTime.Today.Add(5.Hours());

            theOriginatingChain = new RoutedChain("some/url");
            theOriginatingChain.AddToEnd(new OutputNode(GetType()));
            theOriginatingChain.UniqueId.ShouldNotEqual(Guid.Empty);

            MockFor <ICurrentChain>().Stub(x => x.OriginatingChain).Return(theOriginatingChain);


            theUrls = Services.StubUrls();

            theLog = ClassUnderTest.BuildForCurrentRequest();
        }
        public void SetUp()
        {
            var projection = new Projection<Address>(DisplayFormatting.RawValues);
            projection.Value(x => x.Address1);
            projection.Value(x => x.Address2);
            projection.Value(x => x.City);
            projection.Value(x => x.StateOrProvince).Name("State");

            theXmlMediaOptions = new XmlMediaOptions(){
                Root = "Address"
            };
            theDocument = new XmlMediaDocument(theXmlMediaOptions);

            var urls = new StubUrlRegistry();

            var linkSource = new LinksSource<Address>();
            linkSource.ToSubject().Rel("self");
            linkSource.To(a => new AddressAction("change")).Rel("change");
            linkSource.To(a => new AddressAction("delete")).Rel("delete");

            theOutput = new InMemoryOutputWriter();

            var media = new MediaWriter<Address>(theDocument, linkSource, urls, projection, null, theOutput);


            theAddress = new Address(){
                Address1 = "22 Cherry Lane",
                Address2 = "Apt A",
                City = "Austin",
                StateOrProvince = "Texas"
            };



            media.Write("text/plain", theAddress);

            Debug.WriteLine(theOutput);
        }
 public void SetUp()
 {
     theChain = new BehaviorChain();
     theUrls = new StubUrlRegistry();
     _report = new Lazy<RouteReport>(() => RouteReport.ForChain(theChain, theUrls));
 }
 protected override void beforeEach()
 {
     urls = new StubUrlRegistry();
     Services.Inject <IUrlRegistry>(urls);
     ClassUnderTest.InsideBehavior = MockFor <IActionBehavior>();
 }
        public void running_The_activator_applies_all_topic_registries()
        {
            var urls = new StubUrlRegistry();
            new TopicGraphActivator(urls).Activate(null, new PackageLog());

            TopicGraph.AllTopics.Find<ATopic>().ChildNodes.Select(x => x.Title).ShouldHaveTheSameElementsAs("B", "C");
            TopicGraph.AllTopics.Find<DTopic>().ChildNodes.Select(x => x.Title).ShouldHaveTheSameElementsAs("E");
            TopicGraph.AllTopics.Find<CTopic>().ChildNodes.Select(x => x.Title).ShouldHaveTheSameElementsAs("D");
        }
 public void SetUp()
 {
     theSubject = new Site();
     theTarget  = new SimpleValues <Site>(theSubject);
     theUrls    = new StubUrlRegistry();
 }
 public void SetUp()
 {
     theChain = new BehaviorChain();
     theUrls  = new StubUrlRegistry();
     _report  = new Lazy <RouteReport>(() => RouteReport.ForChain(theChain, theUrls));
 }
Example #31
0
        public void url_should_be_the_url_for_grid_request_plus_the_querystring_from_the_harness()
        {
            var url = new StubUrlRegistry().UrlFor(new GridRequest <TheTestGrid>()) + theQuerystringFromTheHarness;

            theGridState.Url.ShouldEqual(url);
        }
Example #32
0
 public void SetUp()
 {
     theSubject = new Site();
     theTarget = new SimpleValues<Site>(theSubject);
     theUrls = new StubUrlRegistry();
 }