private Token ParseIfVariableToken(string searchedArea) { if (!searchedArea.Contains('=')) { throw new ArgumentException("Invalid config syntax: invalid variable definition"); } int valueAssignmentPosition = searchedArea.IndexOf('='); string variableName = searchedArea.Remove(valueAssignmentPosition); string variableValue = searchedArea.Remove(0, valueAssignmentPosition + 1); if (variableName.Contains('"')) { throw new ArgumentException("Invalid config syntax: invalid variable definition"); } object value = FetchVariableFromString(variableValue); _reader.ConsumeBuffer(); return(new VariableToken(variableName, value)); }
public void ConsumeBuffer_ClearsBuffer() { // Arrange string testText = "#consumed part/not consumed part"; _stringReader = new StringReader(testText); _peekableStringReaderAdapter = new PeekableStringReaderAdapter(_stringReader); var peekedPart = _peekableStringReaderAdapter.PeekWithBufferingUntil('/'); Assert.AreEqual(peekedPart[0], _peekableStringReaderAdapter.Peek()); //Act _peekableStringReaderAdapter.ConsumeBuffer(); //Assert Assert.AreNotEqual(peekedPart[0], _peekableStringReaderAdapter.Peek()); }