Changes per PR
This commit is contained in:
parent
6b36c377f6
commit
6c5374db0d
|
|
@ -340,57 +340,10 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact(Skip = "https://github.com/aspnet/AspNetCore/pull/11460")]
|
||||||
public override async Task ActionsReturnBadRequest_WhenModelStateIsInvalid()
|
public override Task ActionsReturnBadRequest_WhenModelStateIsInvalid()
|
||||||
{
|
{
|
||||||
// Arrange
|
return base.ActionsReturnBadRequest_WhenModelStateIsInvalid();
|
||||||
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<ValidationProblemDetails>(
|
|
||||||
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<JObject>(kvp.Value);
|
|
||||||
Assert.Equal("traceId", Assert.Single(jObject.Properties()).Name);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact(Skip = "https://github.com/dotnet/corefx/issues/38769")]
|
[Fact(Skip = "https://github.com/dotnet/corefx/issues/38769")]
|
||||||
|
|
|
||||||
|
|
@ -33,22 +33,8 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
|
||||||
[Fact]
|
[Fact]
|
||||||
public override Task Formatting_DictionaryType() => base.Formatting_DictionaryType();
|
public override Task Formatting_DictionaryType() => base.Formatting_DictionaryType();
|
||||||
|
|
||||||
[Fact]
|
[Fact(Skip = "https://github.com/aspnet/AspNetCore/issues/11522")]
|
||||||
public override async Task Formatting_ProblemDetails()
|
public override Task Formatting_ProblemDetails() => base.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<string>("type"));
|
|
||||||
Assert.Equal("Not Found", obj.Value<string>("title"));
|
|
||||||
Assert.Equal("404", obj.Value<string>("status"));
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public override Task Formatting_PolymorphicModel() => base.Formatting_PolymorphicModel();
|
public override Task Formatting_PolymorphicModel() => base.Formatting_PolymorphicModel();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue