public async Task ShouldBePossibleToCreateSerie() { SerieBuilder serieData = new SerieBuilder().CreateSerieForTest(); var httpResponse = await this.restApi .PostAsJsonAsync(this.baseUrl, serieData.Build()); _ = httpResponse.StatusCode .Should() .Be(HttpStatusCode.Created); Serie response = JsonConvert.DeserializeObject <Serie>(await httpResponse.Content.ReadAsStringAsync()); response .Should() .BeEquivalentTo(serieData.Build()); }
public async Task ShouldBePossibleToUpdateAnSerie() { SerieBuilder serieDataExpected = new SerieBuilder().CreateSerieForTest(); var httpResponse = await this.restApi .PostAsJsonAsync(this.baseUrl, serieDataExpected.Build()); Serie response = JsonConvert.DeserializeObject <Serie>(await httpResponse.Content.ReadAsStringAsync()); serieDataExpected = serieDataExpected.WithName("New Serie") .WithYear("New Year") .WithSeason("New Season") .WithGenre("New Genre"); httpResponse = await this.restApi .PutAsJsonAsync($"{this.baseUrl}/{response._Id}", serieDataExpected.Build()); _ = httpResponse.StatusCode .Should() .Be(HttpStatusCode.NoContent); _ = await this.restApi.DeleteAsync($"{this.baseUrl}/{response._Id}"); }
public async Task ShouldNotBePossibleToCreateSerieWithoutRequiredInformations(SerieBuilder serieData) { var httpResponse = await this.restApi .PostAsJsonAsync(this.baseUrl, serieData.Build()); var response = JObject.Parse(await httpResponse.Content.ReadAsStringAsync()); _ = httpResponse.StatusCode .Should() .Be(HttpStatusCode.BadRequest); ((string)response.SelectToken("message")) .Should() .Be("Missing required property: name/year/season or genre"); }
public async Task ShouldNotBePossibleToUpdateAnSerie() { SerieBuilder serieData = new SerieBuilder().CreateSerieForTest() .WithName("New Serie") .WithYear("New Year") .WithSeason("New Season") .WithGenre("New Genre"); var httpResponse = await this.restApi .PutAsJsonAsync($"{this.baseUrl}/WrongID", serieData.Build()); _ = httpResponse.StatusCode .Should() .Be(HttpStatusCode.NotFound); var response = JObject.Parse(await httpResponse.Content.ReadAsStringAsync()); ((string)response.SelectToken("message")) .Should() .Be("Not Found"); }
public async Task ShouldBePossibleToObtainAnSerie() { var id = "77e0373c6f35bd826f47e977"; SerieBuilder serieData = new SerieBuilder().CreateSerieForTest() .WithName("The Flash") .WithYear("2014") .WithSeason("4") .WithGenre("action"); var httpResponse = await this.restApi .GetAsync($"{this.baseUrl}/{id}"); _ = httpResponse.StatusCode .Should() .Be(HttpStatusCode.OK); Serie response = JsonConvert.DeserializeObject <Serie>(await httpResponse.Content.ReadAsStringAsync()); response .Should() .BeEquivalentTo(serieData.Build(), options => options.Excluding(serie => serie._Id)); }