Ejemplo n.º 1
0
        public async Task BeDeletedSuccessfully()
        {
            var model        = AuthorBuilder.NewAuthor();
            var postResponse = await this.HttpClient.SendAsync("/api/authors", HttpMethod.Post, Json.ToJson(model));

            postResponse.StatusCode.Should().Be(HttpStatusCode.Created);

            var body = await postResponse.Content.ReadAsStringAsync();

            var author = Json.ToObject <Author>(body);

            var deleteResponse = await this.HttpClient.SendAsync($"/api/authors/{author.Id}", HttpMethod.Delete);

            deleteResponse.StatusCode.Should().Be(HttpStatusCode.NoContent);
        }
Ejemplo n.º 2
0
        public async Task BeCreatedSuccessfully()
        {
            var model    = AuthorBuilder.NewAuthor();
            var response = await this.HttpClient.SendAsync("/api/authors", HttpMethod.Post, Json.ToJson(model));

            response.StatusCode.Should().Be(HttpStatusCode.Created);

            var body = await response.Content.ReadAsStringAsync();

            var author = Json.ToObject <Author>(body);

            author.Should().Match <Author>(x =>
                                           x.Name == $"{model.FirstName} {model.LastName}" &&
                                           x.Genre == model.Genre);
        }