public void Test1(string input, string expected) { var sut = new Homework06(); var result = sut.DisplayLEDOnScreen(input); result.Should().Be(expected); }
public void DisplayLEDOnScreen_Success(string ledNo, string expected) { var ledControl = new Homework06(); var result = ledControl.DisplayLEDOnScreen(ledNo); Assert.Equal(expected, result); }
static void Main(string[] args) { var svc = new Homework06(); Console.WriteLine(svc.LoadState()); while (true) { Console.Write("Please choose LED to turn On/Off: "); var ledNo = Console.ReadLine(); var isCorrectNumber = int.TryParse(ledNo, out var ledNoText) && ledNoText >= 1 && ledNoText <= 9; var isA = ledNo == "A"; var isSave = ledNo == "save"; if (isCorrectNumber || isA) { Console.WriteLine(svc.DisplayLEDOnScreen(ledNo)); } else if (isSave) { svc.SaveCurrentState(); Console.WriteLine("Current state had been saved!"); Console.WriteLine(svc.LoadState()); } else { Console.WriteLine("Type 1-9 or A to turn on/off switch and Type 'save' to save state"); } } }
public void DisplayLEDOnScreen_Fail(string ledNo) { var ledControl = new Homework06(); var result = ledControl.DisplayLEDOnScreen(ledNo); var expected = $"[ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ]{Environment.NewLine} 1 2 3 4 5 6 7 8 9 A"; Assert.Equal(expected, result); }
public void TestDisplayLEDOnScreen(Dictionary <string, string> oldLED, string ledNo, Dictionary <string, string> expectNewLED) { var sut = new Homework06(); sut.LED = oldLED; sut.DisplayLEDOnScreen(ledNo); sut.LED.Should().BeEquivalentTo(expectNewLED); }
static void Main(string[] args) { var svc = new Homework06(); while (true) { Console.Write("Please choose LED to turn On/Off: "); var led = svc.DisplayLEDOnScreen(Console.ReadLine()); Console.WriteLine(led); } }
static void Main(string[] args) { var ledOnScreenControl = new Homework06(); var announceText = $"Hello Welcome to DisplayLEDOnScreen analysis (HomeWork 06)"; var announceRules = $"Rules:{Environment.NewLine}\tInput: 1 - 9 and 'A' or 'a' only{Environment.NewLine}\tInput: 'exit' for exit program{Environment.NewLine}\tInput: 'save' for save state (if unsaved, It will disppear when close the program{Environment.NewLine}\tInput: 'load' for load state file{Environment.NewLine}\tInput: 'rule' for display rules again"; var ledScreen = $"Current Led Screen:{Environment.NewLine}{ledOnScreenControl.LoadState()}"; var displayAnnounces = new StringBuilder().AppendLine(announceText).AppendLine(announceRules).AppendLine(ledScreen); System.Console.Write(displayAnnounces); var isContinueInputLedOnScreen = true; while (isContinueInputLedOnScreen) { System.Console.Write($"{Environment.NewLine}Please choose LED to turn On/Off: "); var input = Console.ReadLine(); switch (input) { case "exit": isContinueInputLedOnScreen = false; break; case "save": ledOnScreenControl.SaveCurrentState(); break; case "rule": var ruleText = $"{new String('=', 60)}{Environment.NewLine}{announceRules}{Environment.NewLine}{ledScreen}"; System.Console.WriteLine(ruleText); break; case "load": ledScreen = $"Current Led Screen:{Environment.NewLine}{ledOnScreenControl.LoadState()}"; System.Console.WriteLine(ledScreen); break; default: var currentLedScreen = ledOnScreenControl.DisplayLEDOnScreen(input); System.Console.WriteLine(currentLedScreen); break; } } System.Console.WriteLine("Exit program!"); }