Example #1
0
        public void Exercise_WhenEnteredWrongDigit_StatusError()
        {
            var cl = new CombinationLock(new[] { 1, 2, 3, 4, 5 });

            cl.EnterDigit(1);
            Assert.That(cl.Status, Is.EqualTo("1"));
            cl.EnterDigit(1);
            Assert.That(cl.Status, Is.EqualTo("ERROR"));
        }
Example #2
0
        static void Main(string[] args)
        {
            var cl = new CombinationLock(new[] { 1, 2, 3, 4 });

            WriteLine("Enter code to unlock");
            while (cl.Status != CombinationLock.Open)
            {
                var digit = int.Parse(ReadKey().KeyChar.ToString());
                cl.EnterDigit(digit);
                CursorLeft = 0;
                Write(cl.Status);
            }
        }
Example #3
0
        public void Exercise_WhenEnteredCorrect_StatusOpen()
        {
            var cl = new CombinationLock(new[] { 1, 2, 3, 4, 5 });

            cl.EnterDigit(1);
            Assert.That(cl.Status, Is.EqualTo("1"));
            cl.EnterDigit(2);
            Assert.That(cl.Status, Is.EqualTo("12"));
            cl.EnterDigit(3);
            Assert.That(cl.Status, Is.EqualTo("123"));
            cl.EnterDigit(4);
            Assert.That(cl.Status, Is.EqualTo("1234"));
            cl.EnterDigit(5);
            Assert.That(cl.Status, Is.EqualTo("OPEN"));
        }
Example #4
0
        public static void Main()
        {
            var cl = new CombinationLock(new[] { 1, 2, 3, 4, 5 });

            WriteLine($"STATUS: {cl.Status}"); //Assert.That(cl.Status, Is.EqualTo("LOCKED"));
            cl.EnterDigit(1);
            WriteLine($"STATUS: {cl.Status}"); //Assert.That(cl.Status, Is.EqualTo("1"));
            cl.EnterDigit(2);
            WriteLine($"STATUS: {cl.Status}"); //Assert.That(cl.Status, Is.EqualTo("2"));
            cl.EnterDigit(3);
            WriteLine($"STATUS: {cl.Status}"); //Assert.That(cl.Status, Is.EqualTo("3"));
            cl.EnterDigit(4);
            WriteLine($"STATUS: {cl.Status}"); //Assert.That(cl.Status, Is.EqualTo("4"));
            cl.EnterDigit(5);
            WriteLine($"STATUS: {cl.Status}"); //Assert.That(cl.Status, Is.EqualTo("OPEN"));
        }
Example #5
0
        static void Main(string[] args)
        {
            var cl = new CombinationLock(new int[] { 1, 5, 3, 4 });

            Console.WriteLine(cl.Status);

            cl.EnterDigit(1);

            Console.WriteLine(cl.Status);

            cl.EnterDigit(5);

            Console.WriteLine(cl.Status);

            cl.EnterDigit(6);

            Console.WriteLine(cl.Status);

            cl.EnterDigit(4);

            Console.WriteLine(cl.Status);
        }
Example #6
0
        public void Exercise_WhenCreated_StatusLocked()
        {
            var cl = new CombinationLock(new[] { 1, 2, 3, 4, 5 });

            Assert.That(cl.Status, Is.EqualTo("LOCKED"));
        }