Beispiel #1
0
        public async Task TestGetNgrokDownloadUrl32Bit()
        {
            var installer = new NgrokInstaller(_mockHttpClient, false);
            var url       = await installer.GetNgrokDownloadUrl();

            Assert.AreEqual("https://fakedomain.io/ngrok32.zip", url);
        }
Beispiel #2
0
 public async Task TestGetNgrokDownloadUrlTextNotFound()
 {
     _mockHttpMessageHandler = new MockHttpMessageHandler();
     _mockHttpMessageHandler.When("https://ngrok.com/download")
     .Respond("text/html", "<h1>some html without expected download links</h1>");
     var installer = new NgrokInstaller(_mockHttpMessageHandler.ToHttpClient(), false);
     await installer.GetNgrokDownloadUrl();
 }
Beispiel #3
0
 public async Task TestGetNgrokDownloadUrlHttpError()
 {
     _mockHttpMessageHandler = new MockHttpMessageHandler();
     _mockHttpMessageHandler.When("https://ngrok.com/download")
     .Respond(x => new HttpResponseMessage(HttpStatusCode.NotFound));
     var installer = new NgrokInstaller(_mockHttpMessageHandler.ToHttpClient(), false);
     await installer.GetNgrokDownloadUrl();
 }
Beispiel #4
0
        public async Task TestInstallNgrok()
        {
            var installer = new NgrokInstaller(_mockHttpClient, true);
            var path      = await installer.InstallNgrok();

            Assert.IsTrue(Regex.IsMatch(path, @"^.*\\ngrok\.exe$"));
            Assert.IsTrue(File.Exists(path));
            File.Delete(path);
        }
Beispiel #5
0
        public async Task TestDownloadNgrokFailed()
        {
            _mockHttpMessageHandler = new MockHttpMessageHandler();
            _mockHttpMessageHandler.When("https://fakedomain.io/ngrok.zip")
            .Respond(x => new HttpResponseMessage(HttpStatusCode.NotFound));
            var installer = new NgrokInstaller(_mockHttpMessageHandler.ToHttpClient(), false);

            await installer.DownloadNgrok("https://fakedomain.io/ngrok.zip");
        }
Beispiel #6
0
        public async Task TestDownloadNgrok()
        {
            var installer = new NgrokInstaller(_mockHttpClient, true);
            var stream    = await installer.DownloadNgrok();

            var buffer = new byte[SampleZip.Length];
            await stream.ReadAsync(buffer, 0, SampleZip.Length);

            Assert.IsTrue(buffer.SequenceEqual(SampleZip));
        }