Ejemplo n.º 1
0
    public async Task Appends_Done_On_Success()
    {
        // Arrange
        var result  = new StringBuilder();
        var handler = new MockHttpMessageHandler();
        var client  = new HttpClient(handler);
        var uri     = "https://bfren.dev";

        // Act
        await MenuF.LoadUriAsync(result, client, uri, CancellationToken.None);

        // Assert
        Assert.Contains("done", result.ToString());
    }
Ejemplo n.º 2
0
    public async Task Appends_Failed_On_Failure()
    {
        // Arrange
        var result  = new StringBuilder();
        var handler = new MockHttpMessageHandler(System.Net.HttpStatusCode.InternalServerError);
        var client  = new HttpClient(handler);
        var uri     = "https://bfren.dev";

        // Act
        await MenuF.LoadUriAsync(result, client, uri, CancellationToken.None);

        // Assert
        Assert.Contains("failed", result.ToString());
    }
Ejemplo n.º 3
0
    public async Task Returns_Correct_Message()
    {
        // Arrange
        var result   = new StringBuilder();
        var handler  = new MockHttpMessageHandler();
        var client   = new HttpClient(handler);
        var uri      = "https://bfren.dev";
        var expected = $"Loading {uri} .. done<br/>{Environment.NewLine}";

        // Act
        await MenuF.LoadUriAsync(result, client, uri, CancellationToken.None);

        // Assert
        Assert.Equal(expected, result.ToString());
    }