Ejemplo n.º 1
0
        public async Task DownloadToStreamAsyncTest()
        {
            string url = "https://render.guildwars2.com/file/test/1234.png";

            using var memoryStream = new MemoryStream();

            var renderUrl = new RenderUrl(this.client, url, null);
            await renderUrl.DownloadToStreamAsync(memoryStream);

            int notReceived = 0;

            try
            { await this.client.WebApi.Render.Received().DownloadToStreamAsync(memoryStream, Arg.Any <string>()); }
            catch (ReceivedCallsException) { notReceived++; }
            try
            { await this.client.WebApi.Render.Received().DownloadToStreamAsync(memoryStream, Arg.Any <string>(), Arg.Any <CancellationToken>()); }
            catch (ReceivedCallsException) { notReceived++; }
            try
            { await this.client.WebApi.Render.Received().DownloadToStreamAsync(memoryStream, Arg.Any <Uri>()); }
            catch (ReceivedCallsException) { notReceived++; }
            try
            { await this.client.WebApi.Render.Received().DownloadToStreamAsync(memoryStream, Arg.Any <Uri>(), Arg.Any <CancellationToken>()); }
            catch (ReceivedCallsException) { notReceived++; }
            Assert.NotEqual(4, notReceived);
        }
Ejemplo n.º 2
0
        public void ConstructorTest(string url, string?hostnameReplacement, string expected)
        {
            var renderUrl = new RenderUrl(this.client, url, hostnameReplacement);

            Assert.Equal(expected, renderUrl.Url.ToString());
            Assert.Equal(expected, renderUrl.ToString());
            Assert.Equal(expected, renderUrl);
            Assert.Equal(this.client, renderUrl.Gw2Client);
        }
Ejemplo n.º 3
0
        public void ConstructorTest()
        {
            string url       = "https://render.guildwars2.com/file/test/1234.png";
            var    renderUrl = new RenderUrl(this.client, url);

            Assert.Equal(url, renderUrl.Url.ToString());
            Assert.Equal(url, renderUrl.ToString());
            Assert.Equal(url, renderUrl);
            Assert.Equal(this.client, renderUrl.Gw2Client);
        }
Ejemplo n.º 4
0
        public async Task DownloadToByteArrayAsyncTest()
        {
            string url = "https://render.guildwars2.com/file/test/1234.png";

            byte[] expected = new byte[] { 0, 1, 2, 3, 4, 5 };
            this.client.WebApi.Render.DownloadToByteArrayAsync(Arg.Any <string>()).Returns(expected);
            this.client.WebApi.Render.DownloadToByteArrayAsync(Arg.Any <string>(), Arg.Any <CancellationToken>()).Returns(expected);
            this.client.WebApi.Render.DownloadToByteArrayAsync(Arg.Any <Uri>()).Returns(expected);
            this.client.WebApi.Render.DownloadToByteArrayAsync(Arg.Any <Uri>(), Arg.Any <CancellationToken>()).Returns(expected);

            var renderUrl = new RenderUrl(this.client, url, null);

            byte[] actual = await renderUrl.DownloadToByteArrayAsync();

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 5
0
 private void OnRequestRenderUrl(StringBuilder html)
 {
     RenderUrl?.Invoke(html);
 }