/// <summary> /// Displaies the temperature reading. /// </summary> /// <param name="temperature">Temperature.</param> /// <param name="autoRecord"></param> private void DisplayTemperatureReading(double temperature, bool autoRecord) { var mintemp = HACCPUtil.ConvertToDouble(SelectedItem.Min); var maxtemp = HACCPUtil.ConvertToDouble(SelectedItem.Max); if (TemperatureUnit == TemperatureUnit.Celcius) { mintemp = HACCPUtil.ConvertFahrenheitToCelsius(mintemp); maxtemp = HACCPUtil.ConvertFahrenheitToCelsius(maxtemp); } if (temperature < mintemp) { OptimumTemperatureIndicator = false; HighTemperatureIndicator = false; LowTemperatureIndicator = true; } else if (temperature > maxtemp) { OptimumTemperatureIndicator = false; HighTemperatureIndicator = true; LowTemperatureIndicator = false; } else { OptimumTemperatureIndicator = true; HighTemperatureIndicator = false; LowTemperatureIndicator = false; } var diff = Math.Round(temperature - prevtemp, 1); if (diff > 2.8) { diff = 2.8; } else if (diff < -2.8) { diff = -2.8; } Rotation = HACCPUtil.GetSlope(diff); Blue2Temperature = temperature; prevtemp = temperature; DisplayBlue2Temperature = string.Format("{0}{1}", Blue2Temperature.ToString("0.0"), UnitString); LineBreakMode = LineBreakMode.NoWrap; if (autoRecord) { Device.BeginInvokeOnMainThread(() => { RecordCommand.Execute(null); }); } }
public void WhenCommandIsExecutedThenNotificationIsSended() { var inputMessenger = new MessengerFake(); var expectedMessage = new Record(Recording.Start, Lightman.Lightman1); var startRecordCommand = new RecordCommand(inputMessenger, Recording.Start); startRecordCommand.Execute(Lightman.Lightman1); Assert.IsNotNull(inputMessenger.SendedMessage); Assert.AreEqual(expectedMessage, inputMessenger.SendedMessage.First()); }
public void TestExecute() { var exitSend = new AutoResetEvent(false); Task.Factory.StartNew(() => { _recordCommand.Execute(); exitSend.Set(); }); _stdinWriter.Write("\x3"); exitSend.WaitOne(); StringAssert.Contains("PowerShell", File.ReadAllText(_filePath), "Record result should contain keyword"); }
public void TestRecordCommand_Successful() { // Preconditions Debug.Assert(managerMock != null); Debug.Assert(outputMock != null); Debug.Assert(commandLineMock != null); Debug.Assert(messageLoopMock != null); /* GIVEN */ var mockSequence = new MockSequence(); managerMock.InSequence(mockSequence)?.Setup(manager => manager.StartRecording()); managerMock.InSequence(mockSequence)?.Setup(manager => manager.StopRecording()); commandLineMock .Setup(cli => cli.Launch(It.IsAny <Action>()))? .Callback((Action action) => action?.Invoke())? .Verifiable(); var command = new RecordCommand(managerMock.Object, outputMock.Object, commandLineMock.Object, messageLoopMock.Object); var options = new RecordOptions { IsVerbose = false, ConfigPath = Assembly.GetExecutingAssembly().Location }; /* WHEN */ var returnCode = command.Execute(options); /* THEN */ // We test if the command was successful and returned code 0. Assert.AreEqual(successCode, returnCode); managerMock.VerifyAll(); managerMock.Verify(manager => manager.StartRecording(), Times.Once); managerMock.Verify(manager => manager.StopRecording(), Times.Once); messageLoopMock.Verify(loop => loop.Start(), Times.Once); messageLoopMock.Verify(loop => loop.Stop(), Times.Once); }
public void TestRecordCommand_NullOptions() { // Preconditions Debug.Assert(managerMock != null); Debug.Assert(outputMock != null); Debug.Assert(commandLineMock != null); Debug.Assert(messageLoopMock != null); /* GIVEN */ var command = new RecordCommand(managerMock.Object, outputMock.Object, commandLineMock.Object, messageLoopMock.Object); /* WHEN */ var returnCode = command.Execute(null); /* THEN */ // We test if the command was unsuccessful and returned code -1. Assert.AreEqual(-1, returnCode); managerMock.Verify(manager => manager.StartRecording(), Times.Never); managerMock.Verify(manager => manager.StopRecording(), Times.Never); }
public void TestRecordCommand_OnStartError() { // Preconditions Debug.Assert(managerMock != null); Debug.Assert(outputMock != null); Debug.Assert(commandLineMock != null); Debug.Assert(messageLoopMock != null); /* GIVEN */ managerMock .Setup(manager => manager.StartRecording())? .Throws(new InvalidOperationException()); var command = new RecordCommand(managerMock.Object, outputMock.Object, commandLineMock.Object, messageLoopMock.Object); var options = new RecordOptions { IsVerbose = false, ConfigPath = Assembly.GetExecutingAssembly().Location }; /* WHEN */ var returnCode = command.Execute(options); /* THEN */ // We test if the command failed and returned code -1. Assert.AreEqual(failCode, returnCode); managerMock.Verify(manager => manager.StartRecording(), Times.Once); managerMock.Verify(manager => manager.StopRecording(), Times.Never); outputMock.Verify(output => output.PrintError(It.IsAny <InvalidOperationException>()), Times.Once); messageLoopMock.Verify(loop => loop.Start(), Times.Never); messageLoopMock.Verify(loop => loop.Stop(), Times.Never); }
public void TestRecordCommand_IsVerbosePropagation() { // Preconditions Debug.Assert(managerMock != null); Debug.Assert(outputMock != null); Debug.Assert(commandLineMock != null); Debug.Assert(messageLoopMock != null); /* GIVEN */ outputMock.SetupSet(output => output.IsVerbose = true); var command = new RecordCommand(managerMock.Object, outputMock.Object, commandLineMock.Object, messageLoopMock.Object); var options = new RecordOptions { IsVerbose = true, ConfigPath = "" }; /* WHEN */ command.Execute(options); /* THEN */ outputMock.VerifySet(output => output.IsVerbose = true); }
private static void Main(string[] args) { var record = new Command("rec") { new Argument <FileInfo>("file") { Description = "The filename to save the record" }, new Option(new [] { "--command", "-c" }, "The command to record, default to be powershell.exe", typeof(string)) }; record.Description = "Record and save a session"; record.Handler = CommandHandler.Create((FileInfo file, string command) => { var recordCmd = new RecordCommand(new RecordArgs { Filename = file.FullName, Command = command }); recordCmd.Execute(); }); var play = new Command("play") { new Argument <FileInfo>("file") { Description = "The record session" } }; play.Description = "Play a recorded session"; play.Handler = CommandHandler.Create((FileInfo file) => { var playCommand = new PlayCommand(new PlayArgs { Filename = file.FullName, EnableAnsiEscape = true }); playCommand.Execute(); }); var auth = new Command("auth") { Handler = CommandHandler.Create(() => { var authCommand = new AuthCommand(); authCommand.Execute(); }), Description = "Auth with asciinema.org" }; var upload = new Command("upload") { new Argument <FileInfo>("file") { Description = "The file to be uploaded" } }; upload.Description = "Upload a session to ascinema.org"; upload.Handler = CommandHandler.Create((FileInfo file) => { var uploadCommand = new UploadCommand(file.FullName); uploadCommand.Execute(); }); var rooCommand = new RootCommand { record, play, auth, upload }; rooCommand.Description = "Record, Play and Share your PowerShell Session."; rooCommand.InvokeAsync(args).Wait(); }
public void StartRecording() { RecordCommand.Execute(null); }