コード例 #1
0
        public void TestDecrement()
        {
            Assert.AreEqual(0, target.CountValue);

            target.Decrement();

            Assert.AreEqual(-1, target.CountValue);
        }
コード例 #2
0
        public void AcceptCommand()
        {
            Console.Write("Type Command : ");
            var command = Console.ReadLine();

            if (command.Equals("--help"))
            {
                ShowCommands();
                AcceptCommand();
                return;
            }
            ICounter counter = PickCounterFromCommand(command);

            if (counter == null)
            {
                Console.WriteLine(command + " is not command.");
                AcceptCommand();
                return;
            }

            switch (command.Split(' ').First().First())
            {
            case '+':
                counterService.Increment(counter, command.Split(' ').First().Length);
                break;

            case '-':
                counterService.Decrement(counter, command.Split(' ').First().Length);
                break;

            case 'a':
                counterService.Add(counter);
                break;

            case 'd':
                counterService.Delete(counter);
                break;

            default:
                Console.WriteLine(command + " is not command.");
                AcceptCommand();
                return;
            }
        }