public void DisplayLEDOnScreen_Success(string ledNo, string expected)
        {
            var ledControl = new Homework05();
            var result     = ledControl.DisplayLEDOnScreen(ledNo);

            Assert.Equal(expected, result);
        }
예제 #2
0
        static void Main(string[] args)
        {
            var svc = new Homework05();

            Console.WriteLine(@"[ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ]
 1   2   3   4   5   6   7   8   9   A");

            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.ToUpper() == "A";

                if (isCorrectNumber || isA)
                {
                    Console.WriteLine(svc.DisplayLEDOnScreen(ledNo));
                }
                else
                {
                    Console.WriteLine("Please enter 1-9 or a/A ");
                }
            }
        }
예제 #3
0
        static void Main(string[] args)
        {
            var displayMessage = new List <string>();
            var announceText   = $"Hello Welcome to DisplayLEDOnScreen analysis (HomeWork 05)";
            var rulesText      = $"Rules:{Environment.NewLine}\tInput: 1 - 9 and 'A' or 'a' only{Environment.NewLine}\tInput: 0 for exit program";
            var ledScreen      = $"Led Screen:{Environment.NewLine}\t[ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ]{Environment.NewLine}\t 1   2   3   4   5   6   7   8   9   A";

            displayMessage.Add(announceText);
            displayMessage.Add(rulesText);
            displayMessage.Add(ledScreen);
            var message = string.Join(Environment.NewLine, displayMessage);

            System.Console.Write(message);

            var ledOnScreen = new Homework05();
            var isContinueInputLedOnScreen = true;

            while (isContinueInputLedOnScreen)
            {
                System.Console.Write($"{Environment.NewLine}Which number would you want to toggle Led?: ");
                var input = Console.ReadLine();
                if (input.Equals("0"))
                {
                    isContinueInputLedOnScreen = false;
                }
                else
                {
                    var displayLed = ledOnScreen.DisplayLEDOnScreen(input);
                    System.Console.WriteLine(displayLed);
                }
            }
            System.Console.WriteLine("Exit program!");
        }
예제 #4
0
        public void Test1(string input, string expected)
        {
            var sut    = new Homework05();
            var result = sut.DisplayLEDOnScreen(input);

            result.Should().Be(expected);
        }
        public void DisplayLEDOnScreen_Fail(string ledNo)
        {
            var ledControl = new Homework05();
            var result     = ledControl.DisplayLEDOnScreen(ledNo);
            var expected   = $"[ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ]{Environment.NewLine} 1   2   3   4   5   6   7   8   9   A";

            Assert.Equal(expected, result);
        }
예제 #6
0
        public void TestDisplayLEDOnScreen(Dictionary <string, string> oldLED, string ledNo, Dictionary <string, string> expectNewLED)
        {
            var sut = new Homework05();

            sut.LED = oldLED;
            sut.DisplayLEDOnScreen(ledNo);
            sut.LED.Should().BeEquivalentTo(expectNewLED);
        }
예제 #7
0
        public void InputLEDWithStringNumberItMustReturnLEDDisplay(string expected, bool[] currentSwitches, string ledSelect)
        {
            var svc = new Homework05();

            svc.Switches = currentSwitches;
            var actual = svc.DisplayLEDOnScreen(ledSelect);

            Assert.Equal(expected, actual);
        }
예제 #8
0
        static void Main(string[] args)
        {
            var svc = new Homework05();

            Console.WriteLine(svc.DisplayLEDOnScreen(""));
            while (true)
            {
                Console.Write("Please choose LED to turn On/Off: ");
                var led = svc.DisplayLEDOnScreen(Console.ReadLine());
                Console.WriteLine(led);
            }
        }
예제 #9
0
        static void Main(string[] args)
        {
            var LED = new Homework05();

            LED.listLED   = new List <string>(new string[] { "[ ]", "[ ]", "[ ]", "[ ]", "[ ]", "[ ]", "[ ]", "[ ]", "[ ]", "[ ]" });
            LED.listNoLED = new List <string>(new string[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "A" });
            var ledNo = "start";

            do
            {
                var displayLED = LED.DisplayLEDOnScreen(ledNo);
                Console.WriteLine(displayLED);
                Console.Write("Please choose LED to turn On/Off: ");
                ledNo = Console.ReadLine();
            } while (!(string.IsNullOrWhiteSpace(ledNo)));
        }
예제 #10
0
        static void Main(string[] args)
        {
            var hw5 = new Homework05();

            hw5.listLED   = new List <string>(new string[] { "[ ]", "[ ]", "[ ]", "[ ]", "[ ]", "[ ]", "[ ]", "[ ]", "[ ]", "[ ]" });
            hw5.listNoLED = new List <string>(new string[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "A" });
            var noLed = "close";

            while (true)
            {
                var disPlayLED = hw5.DisplayLEDOnScreen(noLed);
                Console.WriteLine(disPlayLED);
                Console.Write("Please choose LED to turn On/Off: ");
                noLed = Console.ReadLine();
                if (string.IsNullOrEmpty(noLed))
                {
                    break;
                }
            }
        }