当前位置: 首页>>代码示例>>C#>>正文


C# Browser.Get方法代码示例

本文整理汇总了C#中Nancy.Testing.Browser.Get方法的典型用法代码示例。如果您正苦于以下问题:C# Browser.Get方法的具体用法?C# Browser.Get怎么用?C# Browser.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Nancy.Testing.Browser的用法示例。


在下文中一共展示了Browser.Get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestWithoutDots

        public void TestWithoutDots()
        {
            var module = new ConfigurableNancyModule(with => with.Get("/echo/{slug*}", (o, nancyModule) => o.slug));
            var browser = new Browser(with => with.Module(module));

            Assert.Equal(browser.Get("/echo/foo").Body.AsString(), "foo");
            Assert.Equal(browser.Get("/echo/foo/bar").Body.AsString(), "foo/bar");
            Assert.Equal(browser.Get("/echo/foo.bar/gaz").Body.AsString(), "foo.bar/gaz");
            Assert.Equal(browser.Get("/echo/foo.bar").Body.AsString(), "foo.bar");
        }
开发者ID:bendetat,项目名称:frankenwiki,代码行数:10,代码来源:TestDots.cs

示例2: BundleIsReturned

    public void BundleIsReturned(string selector, string attribute) {
        var browser = new Browser(new OptimizingBootstrapper());
        var response = browser.Get("/RazorHome", with => with.HttpRequest());

        var cq = CQ.Create(response.Body.AsString());

        var url = cq.Find(selector).Attr(attribute);

        response = browser.Get(url, with => with.HttpRequest());
        Console.Write(response.Body.AsString());
        Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
    }
开发者ID:ChrisMH,项目名称:Cassette.Nancy,代码行数:12,代码来源:BundleRequestHandlerTest.cs

示例3: SassFileIsReturned

    public void SassFileIsReturned()
    {
      var browser = new Browser(new NonOptimizingBootstrapper());
      var response = browser.Get("/RazorHome", with => with.HttpRequest());
      Console.Write(response.Body.AsString());

      var cq = CQ.Create(response.Body.AsString());
      var url = cq.Find("head link[href^='/_cassette/asset/Styles/Main.sass?']").Attr("href").Split(new char[] { '?' });

      response = browser.Get(url[0], with => with.HttpRequest());
      Console.Write(response.Body.AsString());
      Assert.Equal(HttpStatusCode.OK, response.StatusCode);
    } 
开发者ID:prabirshrestha,项目名称:Cassette.Nancy,代码行数:13,代码来源:AssetRequestHandlerTest.cs

示例4: SassFileIsReturned

    public void SassFileIsReturned()
    {
      var browser = new Browser(new NonOptimizingBootstrapper());
      var response = browser.Get("/RazorHome", with => with.HttpRequest());
      Console.Write(response.Body.AsString());

      var query = new SharpQuery(response.Body.AsString());
      var url = query.Find("head link[href^='/_cassette/asset/Styles/Main.sass?']").Attr("href");

      response = browser.Get(url, with => with.HttpRequest());
      Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
      Console.Write(response.Body.AsString());
    } 
开发者ID:thefringeninja,项目名称:Cassette.Nancy,代码行数:13,代码来源:AssetRouteHandlerTest.cs

示例5: JsFileIsReturned

    public void JsFileIsReturned()
    {
      var browser = new Browser(new NonOptimizingBootstrapper());
      var response = browser.Get("/RazorHome", with => with.HttpRequest());
      Console.Write(response.Body.AsString());

      var cq = CQ.Create(response.Body.AsString());
      var url = cq.Find("body script[src^='/_cassette/asset/Scripts/lib/underscore.js?']").Attr("src").Split(new char[] { '?' });

      response = browser.Get(url[0], with => with.HttpRequest());
      Console.Write(response.Body.AsString());
      Assert.Equal(HttpStatusCode.OK, response.StatusCode);
    }
开发者ID:prabirshrestha,项目名称:Cassette.Nancy,代码行数:13,代码来源:AssetRequestHandlerTest.cs

示例6: JsFileIsReturned

    public void JsFileIsReturned()
    {
      var browser = new Browser(new NonOptimizingBootstrapper());
      var response = browser.Get("/RazorHome", with => with.HttpRequest());
      Console.Write(response.Body.AsString());

      var query = new SharpQuery(response.Body.AsString());
      var url = query.Find("body script[src^='/_cassette/asset/Scripts/lib/underscore.js?']").Attr("src");
      
      response = browser.Get(url, with => with.HttpRequest());
      Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
      Console.Write(response.Body.AsString());
    }
开发者ID:thefringeninja,项目名称:Cassette.Nancy,代码行数:13,代码来源:AssetRouteHandlerTest.cs

示例7: BundleIsReturned

    public void BundleIsReturned(string location, string element, string attribute, string urlFragmet)
    {
      var browser = new Browser(new OptimizingBootstrapper());
      var response = browser.Get("/RazorHome", with => with.HttpRequest());
      Console.Write(response.Body.AsString());
      
      var cq = CQ.Create(response.Body.AsString());

      var url = cq.Find(string.Format("{0} {1}[{2}^='{3}']", location, element, attribute, urlFragmet)).Attr(attribute);

      response = browser.Get(url, with => with.HttpRequest());
      Console.Write(response.Body.AsString());
      Assert.Equal(HttpStatusCode.OK, response.StatusCode);
    }
开发者ID:prabirshrestha,项目名称:Cassette.Nancy,代码行数:14,代码来源:BundleRequestHandlerTest.cs

示例8: BundleIsReturned

    public void BundleIsReturned(string location, string element, string attribute, string urlFragmet)
    {
      CassetteStartup.ShouldOptimizeOutput = true;
      var browser = new Browser(new TestBootstrapper());
      var response = browser.Get("/RazorHome", with => with.HttpRequest());
      Console.Write(response.Body.AsString());
      
      var query = new SharpQuery(response.Body.AsString());

      var url = query.Find(string.Format("{0} {1}[{2}^='{3}']", location, element, attribute, urlFragmet)).Attr(attribute);
      
      response = browser.Get(url, with => with.HttpRequest());
      Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
      Console.Write(response.Body.AsString());
    }
开发者ID:terjetyl,项目名称:Cassette.Nancy,代码行数:15,代码来源:BundleRouteHandlerTest.cs

示例9: ExposeTheBug

 public void ExposeTheBug()
 {
     var b = new Browser(c => { });
     var response = b.Get("/");
     var str = response.Body.AsString();
     Assert.AreNotEqual("foo", str);
 }
开发者ID:provegard,项目名称:NancyBug,代码行数:7,代码来源:Tester.cs

示例10: SetUp

        public void SetUp()
        {
            _server = new Browser(new ServerBootstrapper());

            sampleConfig = TestHelper.GetSampleConfig();
            environmentConfig = TestHelper.GetEnvironmentOverrideConfig();

            setConfigResponse = _server.Post("application/new", context =>
            {
                context.HttpRequest();
                context.JsonBody(sampleConfig as object);
            });

            setEnvironmentConfigResponse = _server.Post("application/new", context =>
            {
                context.HttpRequest();
                context.JsonBody(environmentConfig as object);
                context.Query(TestHelper.Environment, "test");
            });

            getCreatedEnvironmentConfigResponse = _server.Get("application/new", context =>
            {
                context.Query(TestHelper.Environment, "test");
            });

            getEnvironmentConfigResult = getCreatedEnvironmentConfigResponse.Body.AsJson();
        }
开发者ID:cimdalli,项目名称:DynamicConfigurator,代码行数:27,代码来源:with_environment_data.cs

示例11: Should_add_negotiated_content_headers_to_response

        public void Should_add_negotiated_content_headers_to_response()
        {
            // Given

              var module = new ConfigurableNancyModule(with =>
              {
            with.Get("/headers", (x, m) =>
            {
              var context =
                  new NancyContext { NegotiationContext = new NegotiationContext() };

              var negotiator =
                  new Negotiator(context);
              negotiator.WithContentType("text/xml");

              return negotiator;
            });
              });

              var brower = new Browser(with =>
              {
            with.ResponseProcessor<TestProcessor>();

            with.Module(module);
              });

              // When
              var response = brower.Get("/headers");

              // Then
              Assert.Equal("text/xml", response.Context.Response.ContentType);
        }
开发者ID:garethrhughes,项目名称:Nancy,代码行数:32,代码来源:ContentNegotiationFixture.cs

示例12: HomeModule

 public void HomeModule()
 {
     browser = new Browser (with => with.Module (new HomeModule ()));
     result = browser.Get ("/", with => {
         with.HttpRequest ();
     });
 }
开发者ID:chrlapointe,项目名称:yosethegame-dotnet-nancy,代码行数:7,代码来源:HomeTest.cs

示例13: Get_InvokesRavenClientWithNancyContextJsonPacketFactory

        public void Get_InvokesRavenClientWithNancyContextJsonPacketFactory()
        {
            var guid = Guid.NewGuid().ToString();
            var browser = new Browser(cfg =>
            {
                cfg.Module<LogModule>();
                cfg.ApplicationStartup((container, pipelines) =>
                {
                    // Override the IRavenClient implementation so we don't perform
                    // any HTTP request and can retrieve the GUID so we can later
                    // assert that it is the same we sent in. @asbjornu
                    container.Register<IRavenClient, TestableRavenClient>();
                });
            });

            var response = browser.Get("/log", with => { with.FormValue("GUID", guid); });

            Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);

            response.Body["#message"]
                .ShouldExistOnce()
                .And.ShouldContain(
                    guid,
                    StringComparison.InvariantCultureIgnoreCase);
        }
开发者ID:getsentry,项目名称:raven-csharp,代码行数:25,代码来源:NancyTests.cs

示例14: TestGetReturnsJsonArray

        public void TestGetReturnsJsonArray()
        {
            // Setup
            var mockBrightstar = new Mock<IBrightstarService>();
            mockBrightstar.Setup(s => s.ListStores()).Returns(new[] {"store1", "store2", "store3"});
            var app =
                new Browser(new FakeNancyBootstrapper(mockBrightstar.Object,
                                                      new FallbackStorePermissionsProvider(StorePermissions.All, StorePermissions.All),
                                                      new FallbackSystemPermissionsProvider(SystemPermissions.All, SystemPermissions.ListStores)));

            // Execute
            var response = app.Get("/", c => c.Accept(MediaRange.FromString("application/json")));

            // Assert
            Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
            Assert.That(response.ContentType, Contains.Substring("application/json"));
            Assert.That(response.Body, Is.Not.Null);
            var responseContent = response.Body.DeserializeJson <StoresResponseModel>();
            Assert.That(responseContent, Is.Not.Null);
            Assert.That(responseContent.Stores, Is.Not.Null);
            Assert.That(responseContent.Stores.Count, Is.EqualTo(3));
            Assert.That(responseContent.Stores.Any(s => s.Equals("store1") ));
            Assert.That(responseContent.Stores.Any(s => s.Equals("store2") ));
            Assert.That(responseContent.Stores.Any(s => s.Equals("store3") ));
        }
开发者ID:GTuritto,项目名称:BrightstarDB,代码行数:25,代码来源:StoresUrlSpec.cs

示例15: Should_return_main_page_with_valid_auth_cookie

        public void Should_return_main_page_with_valid_auth_cookie()
        {
            // Given
            var bootstrapper = new ConfigurableBootstrapper(with =>
            {
                with.Configure(env =>
                {
                    env.Diagnostics(
                        password: "password",
                        cryptographyConfiguration: this.cryptoConfig);
                });

                with.EnableAutoRegistration();
                with.Diagnostics<FakeDiagnostics>();
            });

            var browser = new Browser(bootstrapper);

            // When
            var result = browser.Get(DiagnosticsConfiguration.Default.Path + "/interactive/providers/", with =>
                {
                    with.Cookie(DiagsCookieName, this.GetSessionCookieValue("password"));
                });

            // Then should see our fake provider and not the default testing provider
            result.Body.AsString().ShouldContain("Fake testing provider");
            result.Body.AsString().ShouldNotContain("Testing Diagnostic Provider");
        }
开发者ID:rahulchrty,项目名称:Nancy,代码行数:28,代码来源:CustomInteractiveDiagnosticsFixture.cs


注:本文中的Nancy.Testing.Browser.Get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。