本文整理汇总了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");
}
示例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);
}
示例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);
}
示例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());
}
示例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);
}
示例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());
}
示例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);
}
示例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());
}
示例9: ExposeTheBug
public void ExposeTheBug()
{
var b = new Browser(c => { });
var response = b.Get("/");
var str = response.Body.AsString();
Assert.AreNotEqual("foo", str);
}
示例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();
}
示例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);
}
示例12: HomeModule
public void HomeModule()
{
browser = new Browser (with => with.Module (new HomeModule ()));
result = browser.Get ("/", with => {
with.HttpRequest ();
});
}
示例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);
}
示例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") ));
}
示例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");
}