예제 #1
0
 public void should_not_accept_create_topic_request_with_invalid_post_data()
 {
     _app.Path("/topics")
     .Post()
     .ShouldFail(_app.MockUser())
     .WithResponse(res =>
     {
         res.StatusCode.ShouldEqual(HttpStatusCode.BadRequest);
     });
 }
예제 #2
0
 public void should_serve_convert_md2html_api_correctly()
 {
     _app.Path("/api/common/md2html")
     .Post()
     .WithForm(new
     {
         markdown = "# 中文的 title"
     })
     .ShouldSuccess(_app.MockUser())
     .WithApiResult((api, result) =>
                    result["html"].ToString()
                    .ShouldContain("<h2>中文的 title</h2>"))
     .And
     .ShouldFail(_app.NoUser())
     .WithSigninRedirect();
 }
예제 #3
0
 public void should_serve_error_as_error_response()
 {
     _app.Path("/error")
     .Get()
     .ShouldFail()
     .WithResponse(res =>
     {
         res.StatusCode.ShouldEqual(HttpStatusCode.InternalServerError);
         res.ReadAllContent().ShouldContain("An error occured");
     });
 }
        void should_be_able_to_signin_new_user()
        {
            var username = StringUtility.Random();
            var password = "******";

            _app.CreateUser(username, password);

            _app.Path("/signin")
            .Post()
            .WithForm(new
            {
                UserName = username,
                Password = password
            })
            .ShouldSuccessWithRedirect(_app.NoUser())
            .WithResponse(response =>
            {
                var cookieHeaders = response.Headers.GetValues("Set-Cookie").ToList();
                cookieHeaders.ShouldContain(cookie => cookie.Contains(".AspNetCore.Identity.Application"));
            });
        }