Example #1
0
        public void Should_Throw_NullArgumentException_When_Null_Source_Given()
        {
            _tokenizerMock.TryParseDelimiter(Arg.Is("1"), out Arg.Any <string>(), out Arg.Any <string>()).Returns(false);
            _tokenizerMock.TryParseDelimiter(Arg.Is("1,"), out Arg.Any <string>(), out Arg.Any <string>()).Returns(arg => { arg[1] = ","; arg[2] = "1"; return(true); });
            _tokenizerMock.TryParseDelimiter(Arg.Is("-"), out Arg.Any <string>(), out Arg.Any <string>()).Returns(false);
            _tokenizerMock.TryParseDelimiter(Arg.Is("-1"), out Arg.Any <string>(), out Arg.Any <string>()).Returns(false);
            _tokenizerMock.Identify(Arg.Is("1")).Returns(new Token(TokenType.Number, "1", 1));
            _tokenizerMock.Identify(Arg.Is(",")).Returns(new Token(TokenType.PlusOperator, ","));
            _tokenizerMock.Identify(Arg.Is("-1")).Returns(new Token(TokenType.Number, "-1", -1));

            Assert.Throws <ArgumentNullException>("source", () => _lexer.Scan(null));

            _tokenizerMock.DidNotReceiveWithAnyArgs().TryParseDelimiter(Arg.Any <string>(), out Arg.Any <string>(), out Arg.Any <string>());
            _tokenizerMock.DidNotReceiveWithAnyArgs().Identify(Arg.Any <string>());
        }