Exemplo n.º 1
0
        public void TrySetArgument_Returns_InvalidArgumentValue_When_Value_Expected_But_Not_Set()
        {
            const string argumentName = "someArg";
            var testObject = new IntArgument(_argument, _stringParser);

            int parsedValue;
            _stringParser.Expect(s => s.TryParse(null, out parsedValue)).Return(false);
            _argument.Expect(a => a.TrySetArgumentName(argumentName)).Return(SetArgumentDataResult.Success);

            var actual = testObject.TrySetArgumentNameAndValue(argumentName, null);
            Assert.That(actual, Is.EqualTo(SetArgumentDataResult.InvalidArgumentValue));
            Assert.That(testObject.ParsedSuccessfully, Is.False);
            Assert.That(testObject.ParsedArgumentValue, Is.EqualTo(default(int)));
        }
Exemplo n.º 2
0
        public void TrySetArgument_Returns_Success_And_Sets_Parsing_Related_Properties_When_No_Problems_Encountered()
        {
            const string argumentName = "someArg";
            const string argumentValue = "some argument";
            const int expectedArgumentValue = 2;
            var testObject = new IntArgument(_argument, _stringParser);

            int parsedValue;
            _stringParser.Expect(s => s.TryParse(argumentValue, out parsedValue)).OutRef(expectedArgumentValue).Return(true);
            _argument.Expect(a => a.TrySetArgumentName(argumentName)).Return(SetArgumentDataResult.Success);

            var actual = testObject.TrySetArgumentNameAndValue(argumentName, argumentValue);
            Assert.That(actual, Is.EqualTo(SetArgumentDataResult.Success));
            Assert.That(testObject.ParsedSuccessfully, Is.True);
            Assert.That(testObject.ParsedArgumentValue, Is.EqualTo(expectedArgumentValue));
        }