コード例 #1
0
        // NOTE: BrowserKind argument must be first
        public async Task DownloadFileFromAnchor(BrowserKind browserKind)
        {
            if (ShouldSkip(browserKind))
            {
                return;
            }

            // Arrange
            var initialUrl   = TestPage.Url;
            var downloadTask = TestPage.WaitForEventAsync(PageEvent.Download);

            // Act
            await Task.WhenAll(
                downloadTask,
                TestPage.ClickAsync("a[download]"));

            // Assert URL should still be same as before click
            Assert.Equal(initialUrl, TestPage.Url);

            // Assert that the resource was downloaded
            var download = downloadTask.Result.Download;

            Assert.Equal($"{_serverFixture.RootUri}subdir/images/blazor_logo_1000x.png", download.Url);
            Assert.Equal("blazor_logo_1000x.png", download.SuggestedFilename);
        }
コード例 #2
0
        // NOTE: BrowserKind argument must be first
        public async Task CanSendAndReceiveBytes(BrowserKind browserKind)
        {
            if (ShouldSkip(browserKind))
            {
                return;
            }

            var targetUri = new Uri(_apiServerFixture.RootUri, "/subdir/api/data");
            await TestPage.TypeAsync("#request-uri", targetUri.AbsoluteUri);

            await TestPage.ClickAsync("#send-request");

            var status = await TestPage.GetTextContentAsync("#response-status");

            var statusText = await TestPage.GetTextContentAsync("#response-status-text");

            var testOutcome = await TestPage.GetTextContentAsync("#test-outcome");

            Assert.Equal("OK", status);
            Assert.Equal("OK", statusText);
            Assert.Equal("", testOutcome);
        }