Ejemplo n.º 1
0
        public async Task HwiProcessBridgeTestAsync()
        {
            HwiProcessBridge pb = new HwiProcessBridge();

            using var cts = new CancellationTokenSource(ReasonableRequestTimeout);
            var res = await pb.SendCommandAsync("enumerate", false, cts.Token);

            Assert.NotEmpty(res.response);
        }
Ejemplo n.º 2
0
        public async void HwiHelpTestAsync()
        {
            using var cts = new CancellationTokenSource(ReasonableRequestTimeout);

            var processBridge = new HwiProcessBridge(new ProcessInvoker());

            (string response, int exitCode)result = await processBridge.SendCommandAsync("--help", openConsole : false, cts.Token);

            Assert.Equal(0, result.exitCode);
            Assert.Equal(@"{""error"": ""Help text requested"", ""code"": -17}" + Environment.NewLine, result.response);
        }
Ejemplo n.º 3
0
        public async Task OpenConsoleDoesntThrowAsync()
        {
            var pb = new HwiProcessBridge(new ProcessInvoker());

            using var cts = new CancellationTokenSource(ReasonableRequestTimeout);
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                var res = await pb.SendCommandAsync("version", openConsole : true, cts.Token);

                Assert.Contains("success", res.response);
            }
            else
            {
                await Assert.ThrowsAsync <PlatformNotSupportedException>(async() => await pb.SendCommandAsync("enumerate", openConsole: true, cts.Token));
            }
        }
        public async Task HwiProcessBridgeTestAsync()
        {
            HwiProcessBridge pb = new HwiProcessBridge();

            using var cts = new CancellationTokenSource(ReasonableRequestTimeout);
            var res = await pb.SendCommandAsync("version", false, cts.Token);

            Assert.NotEmpty(res.response);

            bool stdInputActionCalled = false;

            res = await pb.SendCommandAsync("version", false, cts.Token, (sw) => stdInputActionCalled = true);

            Assert.NotEmpty(res.response);
            Assert.True(stdInputActionCalled);
        }
Ejemplo n.º 5
0
        public async Task HwiVersionTestAsync()
        {
            using var cts = new CancellationTokenSource(ReasonableRequestTimeout);

            var pb = new HwiProcessBridge(new ProcessInvoker());

            // Start HWI with "version" argument and test that we get non-empty response.
            (string response, int exitCode)result = await pb.SendCommandAsync("--version", openConsole : false, cts.Token);

            Assert.Contains(Constants.HwiVersion.ToString(), result.response);

            // Start HWI with "version" argument and test that we get non-empty response + verify that "standardInputWriter" is actually called.
            bool stdInputActionCalled = false;

            result = await pb.SendCommandAsync("--version", openConsole : false, cts.Token, (sw) => stdInputActionCalled = true);

            Assert.Contains(Constants.HwiVersion.ToString(), result.response);
            Assert.True(stdInputActionCalled);
        }