public void Created_WithUri_ResultHasCorrectValues()
    {
        // Arrange
        var uri = new Uri("https://example.com/entity");

        // Act
        var result = TypedResults.Created(uri);

        // Assert
        Assert.Equal(StatusCodes.Status201Created, result.StatusCode);
        Assert.Equal(uri.ToString(), result.Location);
    }
    public void Created_WithStringUriAndValue_ResultHasCorrectValues()
    {
        // Arrange
        var uri   = "https://example.com/entity";
        var value = new { };

        // Act
        var result = TypedResults.Created(uri, value);

        // Assert
        Assert.Equal(StatusCodes.Status201Created, result.StatusCode);
        Assert.Equal(uri, result.Location);
        Assert.Equal(value, result.Value);
    }
Exemple #3
0
 /// <summary>
 /// Produces a <see cref="StatusCodes.Status201Created"/> response.
 /// </summary>
 /// <param name="uri">The URI at which the content has been created.</param>
 /// <param name="value">The value to be included in the HTTP response body.</param>
 /// <returns>The created <see cref="IResult"/> for the response.</returns>
 public static IResult Created(Uri uri, object?value)
 => value is null?TypedResults.Created(uri) : TypedResults.Created(uri, value);
 public void CreatedOfT_WithNullUri_ThrowsArgNullException()
 {
     Assert.Throws <ArgumentNullException>("uri", () => TypedResults.Created(default(Uri), default(object)));
 }
 public void CreatedOfT_WithEmptyStringUri_ThrowsArgException()
 {
     Assert.Throws <ArgumentException>("uri", () => TypedResults.Created(string.Empty, default(object)));
 }
 public void Created_WithNullStringUri_ThrowsArgException()
 {
     Assert.Throws <ArgumentException>("uri", () => TypedResults.Created(default(string)));
 }
Exemple #7
0
 /// <summary>
 /// Produces a <see cref="StatusCodes.Status201Created"/> response.
 /// </summary>
 /// <param name="uri">The URI at which the content has been created.</param>
 /// <param name="value">The value to be included in the HTTP response body.</param>
 /// <returns>The created <see cref="IResult"/> for the response.</returns>
 public static IResult Created <TValue>(Uri uri, TValue?value)
 => value is null?TypedResults.Created(uri) : TypedResults.Created(uri, value);