public void CommandSetHourIntervalMiddleTest() { CommandSet com = new CommandSet(); ClockEventArgs args = new ClockEventArgs(11, 0, 0); // com.Clock = MockClock.Instance; com.Execute(args); Assert.AreEqual(11, com.Clock.Hour); args = new ClockEventArgs(12, 0, 0); com.Execute(args); Assert.AreEqual(12, com.Clock.Hour); args = new ClockEventArgs(13, 0, 0); com.Execute(args); Assert.AreEqual(13, com.Clock.Hour); }
public void CommandSetSecondIntervalMiddleTest() { CommandSet com = new CommandSet(); ClockEventArgs args = new ClockEventArgs(0, 0, 29); // com.Clock = MockClock.Instance; com.Execute(args); Assert.AreEqual(29, com.Clock.Second); args = new ClockEventArgs(0, 0, 30); com.Execute(args); Assert.AreEqual(30, com.Clock.Second); args = new ClockEventArgs(0, 0, 31); com.Execute(args); Assert.AreEqual(31, com.Clock.Second); }
static async Task Main(string[] args) { if (args.Length < 1) { throw new ArgumentOutOfRangeException("args", "You must use at least one argument"); } //if (args.Length > 3) // throw new ArgumentOutOfRangeException("args", "Too much arguments"); var commandSet = new CommandSet(args) { { "-?|--help|-h", "Show help information", () => _showHelp = true }, { "init|-i", "Set an unique identifier", (Guid _) => { UniqueId = _; Console.WriteLine(UniqueId); } }, { "set|-s", "Set a key value pair", (IEnumerable <string> _) => { _.ToList().ForEach(Console.WriteLine); } }, { "remove|-r", "Remove a key value pair", (string _) => { Console.WriteLine(_); } }, { "clear|-clr", "Clear the screen", Console.Clear } }; commandSet.Execute(); if (_showHelp) { ShowHelp(commandSet); } Console.ReadLine(); }
public void CommandSetHourIntervalBeginTest() { CommandSet com = new CommandSet(); ClockEventArgs args = new ClockEventArgs(int.MinValue, 0, 0); // com.Clock = MockClock.Instance; com.Execute(args); Assert.AreNotEqual(int.MinValue, com.Clock.Hour); args = new ClockEventArgs(-1, 0, 0); com.Execute(args); Assert.AreNotEqual(-1, com.Clock.Hour); args = new ClockEventArgs(0, 0, 0); com.Execute(args); Assert.AreEqual(0, com.Clock.Hour); args = new ClockEventArgs(1, 0, 0); com.Execute(args); Assert.AreEqual(1, com.Clock.Hour); }
public void CommandSetSecondIntervalEndTest() { CommandSet com = new CommandSet(); ClockEventArgs args = new ClockEventArgs(0, 0, 59); // com.Clock = MockClock.Instance; com.Execute(args); Assert.AreEqual(59, com.Clock.Second); args = new ClockEventArgs(0, 0, 60); com.Execute(args); Assert.AreNotEqual(60, com.Clock.Second); Assert.AreEqual(0, com.Clock.Second); args = new ClockEventArgs(0, 0, 61); com.Execute(args); Assert.AreNotEqual(61, com.Clock.Second); args = new ClockEventArgs(0, 0, int.MaxValue); com.Execute(args); Assert.AreNotEqual(int.MaxValue, com.Clock.Second); }
public void CommandSetHourIntervalEndTest() { CommandSet com = new CommandSet(); ClockEventArgs args = new ClockEventArgs(23, 0, 0); // com.Clock = MockClock.Instance; com.Execute(args); Assert.AreEqual(23, com.Clock.Hour); args = new ClockEventArgs(24, 0, 0); com.Execute(args); Assert.AreNotEqual(24, com.Clock.Hour); Assert.AreEqual(0, com.Clock.Hour); args = new ClockEventArgs(25, 0, 0); com.Execute(args); Assert.AreNotEqual(25, com.Clock.Hour); args = new ClockEventArgs(int.MaxValue, 0, 0); com.Execute(args); Assert.AreNotEqual(int.MaxValue, com.Clock.Hour); }
public void Hide() { if (!IsVisible) { return; } Logger.Debug("Hiding orbits"); CreateHideVesselCommands(m_hideOrbitCommands); CreateHideBodiesCommands(m_hideOrbitCommands); m_hideOrbitCommands.Execute(); IsVisible = false; OnVisibilityChanged?.Invoke(false); }
public void CommandSetExecutesCorrectly() { CommandSet set = new CommandSet(); ClockEventArgs args = new ClockEventArgs(9, 9, 9); Clock.Instance.Set(0, 0, 0); set.Clock = MockClock.Instance; set.Execute(args); Assert.AreEqual(true, MockClock.Instance.SetExecuted); Assert.AreEqual(0, args.Hour); Assert.AreEqual(0, args.Minute); Assert.AreEqual(0, args.Second); MockClock.Instance.ResetMock(); }