本文整理汇总了C#中Nancy.Testing.Browser.Put方法的典型用法代码示例。如果您正苦于以下问题:C# Browser.Put方法的具体用法?C# Browser.Put怎么用?C# Browser.Put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nancy.Testing.Browser
的用法示例。
在下文中一共展示了Browser.Put方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: When_no_email_is_passed
public When_no_email_is_passed()
{
_Api = new Mock<IApiService>(MockBehavior.Strict);
_Browser = Testing.CreateBrowser<SecuredPagesModule>(with =>
{
with.LoggedInUser();
with.Api(_Api);
});
_Response = _Browser.Put("/Sites/testsite/Notifications/Email");
}
示例2: ForRequest_should_return_204_for_request_with_unit_response
public void ForRequest_should_return_204_for_request_with_unit_response()
{
// Given
var bootstrapper = new Bootstrapper();
var browser = new Browser(bootstrapper);
// When
var result = browser.Put("/testmessage", with => {
with.HttpRequest();
});
// Then
result.StatusCode.ShouldBeEquivalentTo(HttpStatusCode.NoContent);
}
示例3: TestPut
public void TestPut()
{
//Arrange
var bootstrapper = new DefaultNancyBootstrapper();
var browser = new Browser(bootstrapper);
//Act
var result = browser.Put("/routes", with => {
with.HttpRequest();
});
//Assert
Assert.AreEqual (HttpStatusCode.OK, result.StatusCode);
Assert.AreEqual ("Response with Put\n", result.Body.AsString());
}
示例4: When_creating_the_hook_fails
public When_creating_the_hook_fails()
{
_Api = new Mock<IApiService>(MockBehavior.Strict);
_Api.Setup(d => d.CreateServicehook(It.IsAny<string>(), It.IsAny<string>())).Returns(new CreateResult { Status = CreateStatus.Undefined });
_Browser = Testing.CreateBrowser<SecuredPagesModule>(with =>
{
with.LoggedInUser();
with.Api(_Api);
});
_Response = _Browser.Put("/Sites/testsite/Notifications/Email", ctx =>
{
ctx.FormValue("email", "[email protected]");
});
}
示例5: ExecuteInternal
protected override BrowserResponse ExecuteInternal(Browser browser)
{
return browser.Put(Path, OnContext);
}
示例6: TestPutUpdatesDefaultGraph
public void TestPutUpdatesDefaultGraph()
{
var mockJobInfo = new Mock<IJobInfo>();
mockJobInfo.Setup(m => m.JobCompletedOk).Returns(true);
var brightstar = new Mock<IBrightstarService>();
brightstar.Setup(s => s.DoesStoreExist("foo")).Returns(true);
brightstar.Setup(s => s.ExecuteUpdate("foo",
It.Is<string>(p=>SpaceNormalizedStringsAreEqual(@"DROP SILENT DEFAULT; INSERT DATA { <http://example.org/s> <http://example.org/p> <http://example.org/o> . }", p)),
true, It.IsAny<string>())).Returns(mockJobInfo.Object).Verifiable();
var app = new Browser(new FakeNancyBootstrapper(brightstar.Object));
var response = app.Put("/foo/graphs", with =>
{
with.Query("default", "");
with.Header("Content-Type", RdfFormat.NTriples.MediaTypes.First());
with.Body("<http://example.org/s> <http://example.org/p> <http://example.org/o> .");
});
Assert.That(response, Is.Not.Null);
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.NoContent));
brightstar.Verify();
}
示例7: AddRealEstate_should_return_201
public void AddRealEstate_should_return_201()
{
var browser = new Browser(cfg =>
{
cfg.Module<AddModule>();
cfg.Dependency<IRepository>(_repositoryMock.Object);
cfg.Dependency<IAddCorporationManager>(_filterAddManager.Object);
}, to => to.Accept("application/json"));
var response = browser.Put(@"http://localhost:59536/AddRealEstate/564db279b99f725971d81658", with =>
{
with.HttpRequest();
with.FormValue("code", "12345");
with.FormValue("street", "MockStreet");
with.FormValue("city", "MockCity");
with.FormValue("state", "MockState");
with.FormValue("zip", "112345");
with.Accept(new MediaRange("application/json"));
});
var bodyResponse = response.Body.AsString();
Assert.AreEqual(Nancy.HttpStatusCode.OK, response.StatusCode);
}
示例8: UpdateCorporation_ShouldReturn200
public void UpdateCorporation_ShouldReturn200()
{
var browser = new Browser(cfg =>
{
cfg.Module<AddModule>();
cfg.Dependency<IRepository>(_repositoryMock.Object);
cfg.Dependency<IAddCorporationManager>(_filterAddManager.Object);
}, to => to.Accept("application/json"));
var response = browser.Put(@"http://localhost:59536/UpdateCorporation/564db279b99f725971d81658", with =>
{
with.HttpRequest();
with.FormValue("Name", "MockNameUpdated");
with.Accept(new MediaRange("application/json"));
});
var x = response.Body.AsString();
Assert.AreEqual(Nancy.HttpStatusCode.OK, response.StatusCode);
}
示例9: Should_Return_Unauthorized_If_InvalidUser_Updating
public void Should_Return_Unauthorized_If_InvalidUser_Updating()
{
var fakePostRepository = new Mock<IPostRepository>();
fakePostRepository.Setup(x => x.Update(It.IsAny<Post>())).Returns(Task.FromResult((Post)null));
var browser = new Browser(
cfg =>
{
cfg.Module<BlogModule>();
cfg.Dependencies<IPostRepository>(fakePostRepository.Object);
});
var result = browser.Put("/1", with =>
{
with.HttpRequest();
with.FormValue("Content", "Test Content");
});
Assert.Equal(HttpStatusCode.Unauthorized, result.StatusCode);
}
示例10: Should_Return_ServerError_If_Cannot_Updated
public void Should_Return_ServerError_If_Cannot_Updated()
{
var fakePostRepository = new Mock<IPostRepository>();
fakePostRepository.Setup(x => x.Update(It.IsAny<Post>())).Returns(Task.FromResult((Post)null));
var browser = new Browser(
cfg =>
{
cfg.Module<BlogModule>();
cfg.Dependencies<IPostRepository>(fakePostRepository.Object);
cfg.RequestStartup((container, pipelines, context) =>
{
context.CurrentUser = new UserIdentity { UserName = "Test" };
});
});
var result = browser.Put("/999", with =>
{
with.HttpRequest();
with.FormValue("Content", "Test Content");
});
Assert.Equal(HttpStatusCode.InternalServerError, result.StatusCode);
}
示例11: TestPutCreatesNewNamedGraph
public void TestPutCreatesNewNamedGraph()
{
IEnumerable<string> existingGraphs = new String [] { };
var mockJobInfo = new Mock<IJobInfo>();
mockJobInfo.Setup(m => m.JobCompletedOk).Returns(true);
var brightstar = new Mock<IBrightstarService>();
brightstar.Setup(s => s.DoesStoreExist("foo")).Returns(true);
brightstar.Setup(s => s.ListNamedGraphs("foo")).Returns(existingGraphs);
brightstar.Setup(s => s.ExecuteUpdate("foo",
@"DROP SILENT GRAPH <http://example.org/g>; INSERT DATA { GRAPH <http://example.org/g> { <http://example.org/s> <http://example.org/p> <http://example.org/o> .
} }", true, It.IsAny<string>())).Returns(mockJobInfo.Object).Verifiable();
var app = new Browser(new FakeNancyBootstrapper(brightstar.Object));
var response = app.Put("/foo/graphs", with =>
{
with.Query("graph", "http://example.org/g");
with.Header("Content-Type", RdfFormat.NTriples.MediaTypes.First());
with.Body("<http://example.org/s> <http://example.org/p> <http://example.org/o> .");
});
Assert.That(response, Is.Not.Null);
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.Created));
brightstar.Verify();
}
示例12: TestRequestValidation
public void TestRequestValidation()
{
// given
var bootstrapper = new DefaultNancyBootstrapper();
var browser = new Browser(bootstrapper, defaults: to => to.Accept("application/json"));
ApiBootstrapper.AddOrUpdate("mock", new ApiMock());
// when incorrect instance request
var result = browser.Put("notmock/routing/", with =>
{
with.Body(string.Empty);
with.Header("content-type", "application/json");
with.HttpRequest();
});
// then not found
Assert.AreEqual(HttpStatusCode.NotFound, result.StatusCode);
// when empty request
result = browser.Get("mock/routing/", with =>
{
with.Body(string.Empty);
with.Header("content-type", "application/json");
with.HttpRequest();
});
// then not acceptable
Assert.AreEqual(HttpStatusCode.NotAcceptable, result.StatusCode);
// when request with incorrect locations.
result = browser.Get("mock/routing", with =>
{
with.Body(string.Empty);
with.Header("content-type", "application/json");
with.Query("vehicle", "car");
with.Query("loc", "1,1");
with.HttpRequest();
});
// then not acceptable
Assert.AreEqual(HttpStatusCode.NotAcceptable, result.StatusCode);
// when request with incorrect locations.
result = browser.Get("mock/routing", with =>
{
with.Body(string.Empty);
with.Header("content-type", "application/json");
with.Query("vehicle", "car");
with.Query("loc", "1;1");
with.HttpRequest();
});
// then not acceptable
Assert.AreEqual(HttpStatusCode.NotAcceptable, result.StatusCode);
// when request with incorrect locations.
result = browser.Get("mock/routing", with =>
{
with.Body(string.Empty);
with.Header("content-type", "application/json");
with.Query("vehicle", "car");
with.Query("loc", "a,1");
with.Query("loc", "1,1");
with.HttpRequest();
});
// then not acceptable
Assert.AreEqual(HttpStatusCode.NotAcceptable, result.StatusCode);
// when request with incorrect vehicle.
result = browser.Get("mock/routing", with =>
{
with.Body(string.Empty);
with.Header("content-type", "application/json");
with.Query("vehicle", "novehiclehere");
with.Query("loc", "1,1");
with.Query("loc", "1,1");
with.HttpRequest();
});
// then not acceptable
Assert.AreEqual(HttpStatusCode.NotAcceptable, result.StatusCode);
// when request with 0 locations.
var request = new Domain.Request()
{
locations = new double[][] {
new double[] {1, 1}
},
profile = new Domain.Profile()
{
vehicle = "car"
}
};
result = browser.Get("mock/routing", with =>
{
with.JsonBody(request);
with.HttpRequest();
});
//.........这里部分代码省略.........