예제 #1
0
        // ReSharper disable once UnusedMember.Global
        // ReSharper disable once MemberCanBePrivate.Global
        protected IEnumerable <CommandResponse> EnabledMode()
        {
            var tokenList = (List <string>) this.Arguments;
            var stalkName = tokenList.PopFromFront();

            if (!this.channelConfiguration[this.CommandSource].Stalks.ContainsKey(stalkName))
            {
                throw new CommandErrorException(string.Format("Can't find the stalk '{0}'!", stalkName));
            }

            bool enabled;
            var  possibleBoolean = tokenList.PopFromFront();

            if (!BooleanParser.TryParse(possibleBoolean, out enabled))
            {
                throw new CommandErrorException(
                          string.Format(
                              "{0} is not a value of boolean I recognise. Try 'true', 'false' or ERR_FILE_NOT_FOUND.",
                              possibleBoolean));
            }

            yield return(new CommandResponse
            {
                Message = string.Format("Set enabled attribute on stalk {0} to {1}", stalkName, enabled)
            });

            this.channelConfiguration[this.CommandSource].Stalks[stalkName].IsEnabled = enabled;

            this.channelConfiguration.Save();
        }
        public bool ShouldParseCorrectly(string input)
        {
            bool result;
            bool success = BooleanParser.TryParse(input, out result);

            Assert.IsTrue(success);
            return(result);
        }
        public void ShouldParseIncorrectly(string input)
        {
            bool result;

            Assert.IsFalse(BooleanParser.TryParse(input, out result));
        }