Beispiel #1
0
    public void ExecuteAsync_ThrowsArgumentNullException_WhenHttpContextIsNull()
    {
        // Arrange
        var         result      = new FileStreamHttpResult(new MemoryStream(), null);
        HttpContext httpContext = null;

        // Act & Assert
        Assert.ThrowsAsync <ArgumentNullException>("httpContext", () => result.ExecuteAsync(httpContext));
    }
Beispiel #2
0
    public void Constructor_SetsFileName()
    {
        // Arrange
        var stream = Stream.Null;

        // Act
        var result = new FileStreamHttpResult(stream, "text/plain");

        // Assert
        Assert.Equal(stream, result.FileStream);
    }
Beispiel #3
0
    public void Constructor_SetsContentTypeAndParameters()
    {
        // Arrange
        var stream            = Stream.Null;
        var contentType       = "text/plain; charset=us-ascii; p1=p1-value";
        var expectedMediaType = contentType;

        // Act
        var result = new FileStreamHttpResult(stream, contentType);

        // Assert
        Assert.Equal(stream, result.FileStream);
        Assert.Equal(expectedMediaType, result.ContentType);
    }
Beispiel #4
0
    protected override Task ExecuteAsync(
        HttpContext httpContext,
        Stream stream,
        string contentType,
        DateTimeOffset?lastModified    = null,
        EntityTagHeaderValue entityTag = null,
        bool enableRangeProcessing     = false)
    {
        var fileStreamResult = new FileStreamHttpResult(stream, contentType)
        {
            LastModified          = lastModified,
            EntityTag             = entityTag,
            EnableRangeProcessing = enableRangeProcessing
        };

        return(fileStreamResult.ExecuteAsync(httpContext));
    }
Beispiel #5
0
    public void Constructor_SetsLastModifiedAndEtag()
    {
        // Arrange
        var stream            = Stream.Null;
        var contentType       = "text/plain";
        var expectedMediaType = contentType;
        var lastModified      = new DateTimeOffset();
        var entityTag         = new EntityTagHeaderValue("\"Etag\"");

        // Act
        var result = new FileStreamHttpResult(stream, contentType)
        {
            LastModified = lastModified,
            EntityTag    = entityTag,
        };

        // Assert
        Assert.Equal(lastModified, result.LastModified);
        Assert.Equal(entityTag, result.EntityTag);
        Assert.Equal(expectedMediaType, result.ContentType);
    }