From 6c5374db0d9c48a4e389dbf97a96384e5e4e5be2 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 24 Jun 2019 16:14:46 -0700 Subject: [PATCH] Changes per PR --- .../Mvc.FunctionalTests/ApiBehaviorTest.cs | 53 ++----------------- .../SystemTextJsonOutputFormatterTest.cs | 18 +------ 2 files changed, 5 insertions(+), 66 deletions(-) diff --git a/src/Mvc/test/Mvc.FunctionalTests/ApiBehaviorTest.cs b/src/Mvc/test/Mvc.FunctionalTests/ApiBehaviorTest.cs index 11ec57891f..0de827952f 100644 --- a/src/Mvc/test/Mvc.FunctionalTests/ApiBehaviorTest.cs +++ b/src/Mvc/test/Mvc.FunctionalTests/ApiBehaviorTest.cs @@ -340,57 +340,10 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests { } - [Fact] - public override async Task ActionsReturnBadRequest_WhenModelStateIsInvalid() + [Fact(Skip = "https://github.com/aspnet/AspNetCore/pull/11460")] + public override Task ActionsReturnBadRequest_WhenModelStateIsInvalid() { - // Arrange - using var _ = new ActivityReplacer(); - - var contactModel = new Contact - { - Name = "Abc", - City = "Redmond", - State = "WA", - Zip = "Invalid", - }; - var contactString = JsonConvert.SerializeObject(contactModel); - - // Act - var response = await Client.PostAsJsonAsync("/contact", contactModel); - - // Assert - await response.AssertStatusCodeAsync(HttpStatusCode.BadRequest); - Assert.Equal("application/problem+json", response.Content.Headers.ContentType.MediaType); - var problemDetails = JsonConvert.DeserializeObject( - await response.Content.ReadAsStringAsync(), - new JsonSerializerSettings - { - Converters = { new ValidationProblemDetailsConverter() } - }); - Assert.Collection( - problemDetails.Errors.OrderBy(kvp => kvp.Key), - kvp => - { - Assert.Equal("Name", kvp.Key); - var error = Assert.Single(kvp.Value); - Assert.Equal("The field Name must be a string with a minimum length of 5 and a maximum length of 30.", error); - }, - kvp => - { - Assert.Equal("Zip", kvp.Key); - var error = Assert.Single(kvp.Value); - Assert.Equal("The field Zip must match the regular expression '\\d{5}'.", error); - } - ); - - Assert.Collection( - problemDetails.Extensions, - kvp => - { - Assert.Equal("extensions", kvp.Key); - var jObject = Assert.IsType(kvp.Value); - Assert.Equal("traceId", Assert.Single(jObject.Properties()).Name); - }); + return base.ActionsReturnBadRequest_WhenModelStateIsInvalid(); } [Fact(Skip = "https://github.com/dotnet/corefx/issues/38769")] diff --git a/src/Mvc/test/Mvc.FunctionalTests/SystemTextJsonOutputFormatterTest.cs b/src/Mvc/test/Mvc.FunctionalTests/SystemTextJsonOutputFormatterTest.cs index eb1b9493c5..14ab2b4845 100644 --- a/src/Mvc/test/Mvc.FunctionalTests/SystemTextJsonOutputFormatterTest.cs +++ b/src/Mvc/test/Mvc.FunctionalTests/SystemTextJsonOutputFormatterTest.cs @@ -33,22 +33,8 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests [Fact] public override Task Formatting_DictionaryType() => base.Formatting_DictionaryType(); - [Fact] - public override async Task Formatting_ProblemDetails() - { - using var _ = new ActivityReplacer(); - - // Act - var response = await Client.GetAsync($"/JsonOutputFormatter/{nameof(JsonOutputFormatterController.ProblemDetailsResult)}"); - - // Assert - await response.AssertStatusCodeAsync(HttpStatusCode.NotFound); - - var obj = JObject.Parse(await response.Content.ReadAsStringAsync()); - Assert.Equal("https://tools.ietf.org/html/rfc7231#section-6.5.4", obj.Value("type")); - Assert.Equal("Not Found", obj.Value("title")); - Assert.Equal("404", obj.Value("status")); - } + [Fact(Skip = "https://github.com/aspnet/AspNetCore/issues/11522")] + public override Task Formatting_ProblemDetails() => base.Formatting_ProblemDetails(); [Fact] public override Task Formatting_PolymorphicModel() => base.Formatting_PolymorphicModel();