コード例 #1
0
        public async Task ReturnsOutputFromProcess()
        {
            //arrange
            var commandService = Substitute.For <ICommandService>();

            commandService.Run(Arg.Any <ProcessStartInfo>()).Returns("file contents");
            var reader = new LinuxSignalReader(commandService);

            //act
            var results = await reader.Read();

            //assert
            Assert.Equal("file contents", results);
        }
コード例 #2
0
        public async Task ReturnsDecentMessageWhenNotFound()
        {
            //arrange
            var exception      = new Win32Exception(2, "x");
            var commandService = Substitute.For <ICommandService>();

            commandService.When(c => c.Run(Arg.Any <ProcessStartInfo>())).Throw(exception);
            var reader = new LinuxSignalReader(commandService);

            try
            {
                //act
                var results = await reader.Read();
            }
            catch (Exception e)
            {
                //assert
                Assert.Contains("\"wireless-tools\" is installed", e.Message);
                Assert.Contains("running as root", e.Message);
            }
        }