示例#1
0
        public async Task StopTunnel_StopATunnelThatIsRunning_True()
        {
            // ARRANGE
            if (!Directory.Exists(_downloadFolder))
            {
                Directory.CreateDirectory(_downloadFolder);
            }
            File.WriteAllBytes($"{_downloadFolder}ngrok-stable-amd64.zip", _ngrokBytes);

            var fastZip = new FastZip();

            fastZip.ExtractZip($"{_downloadFolder}ngrok-stable-amd64.zip", _downloadFolder, null);

            SetNgrokYml();

            var ngrokManager = new NgrokManager();

            ngrokManager.StartNgrok();
            //Wait for ngrok to start, it can be slow on some systems.
            Thread.Sleep(1000);

            var startTunnelDto = new StartTunnelDTO
            {
                name     = "foundryvtt",
                proto    = "http",
                addr     = "30000",
                bind_tls = "false"
            };

            await ngrokManager.StartTunnelAsync(startTunnelDto);

            //Wait for ngrok to start, it can be slow on some systems.
            Thread.Sleep(1000);

            // ACT
            var stopTunnel = await ngrokManager.StopTunnelAsync("foundryvtt");

            // ASSERT
            Assert.Equal(HttpStatusCode.NoContent,
                         stopTunnel.StatusCode); // Should return 204 status code with no content
        }
示例#2
0
        public async Task StopTunnel_StopTunnelNameIsNullArgumentNullException_True()
        {
            // ARRANGE
            if (!Directory.Exists(_downloadFolder))
            {
                Directory.CreateDirectory(_downloadFolder);
            }
            File.WriteAllBytes($"{_downloadFolder}ngrok-stable-amd64.zip", _ngrokBytes);

            var fastZip = new FastZip();

            fastZip.ExtractZip($"{_downloadFolder}ngrok-stable-amd64.zip", _downloadFolder, null);

            SetNgrokYml();

            var ngrokManager = new NgrokManager();

            ngrokManager.StartNgrok();
            //Wait for ngrok to start, it can be slow on some systems.
            Thread.Sleep(1000);

            var startTunnelDto = new StartTunnelDTO
            {
                name     = "foundryvtt",
                proto    = "http",
                addr     = "30000",
                bind_tls = "false"
            };
            await ngrokManager.StartTunnelAsync(startTunnelDto);

            // ACT

            var ex = await Assert.ThrowsAsync <ArgumentException>(async() => await ngrokManager.StopTunnelAsync(""));

            // ASSERT

            Assert.Equal("Value cannot be null or whitespace. (Parameter 'name')", ex.Message);
        }