Ejemplo n.º 1
0
    public void ValidationProblem_WithValidationProblemArg_ResultHasCorrectValues()
    {
        // Arrange
        var errors = new Dictionary <string, string[]>()
        {
            { "testField", new[] { "test error" } }
        };
        var detail     = "test detail";
        var instance   = "test instance";
        var title      = "test title";
        var type       = "test type";
        var extensions = new Dictionary <string, object>()
        {
            { "testExtension", "test value" }
        };

        // Act
        var result = TypedResults.ValidationProblem(errors, detail, instance, title, type, extensions);

        // Assert
        Assert.Equal(errors, result.ProblemDetails.Errors);
        Assert.Equal(detail, result.ProblemDetails.Detail);
        Assert.Equal(instance, result.ProblemDetails.Instance);
        Assert.Equal(StatusCodes.Status400BadRequest, result.ProblemDetails.Status);
        Assert.Equal(StatusCodes.Status400BadRequest, result.StatusCode);
        Assert.Equal(title, result.ProblemDetails.Title);
        Assert.Equal(type, result.ProblemDetails.Type);
        Assert.Equal("application/problem+json", result.ContentType);
        Assert.Equal(extensions, result.ProblemDetails.Extensions);
    }
Ejemplo n.º 2
0
 public void ValidationProblem_WithNullErrors_ThrowsArgNullException()
 {
     Assert.Throws <ArgumentNullException>("errors", () => TypedResults.ValidationProblem(default(IDictionary <string, string[]>)));
 }