public void HandlesAdditionSuccessful_InsertBeforeComment()
        {
            var insertionBuffer = new List <string>()
            {
                "FunctionA();",
            };
            var lastContextLine = string.Empty;
            var nextContextLine = "// My comment";

            var styleProvider = new BaseCodeStyleProvider();
            var output        = styleProvider.AdaptInsertionBlock(insertionBuffer, lastContextLine, nextContextLine);

            Assert.Equal(string.Empty, output.Last());
        }
Esempio n. 2
0
        private int TryAddBufferContent()
        {
            if (_insertionBuffer.Any() && !BlockExists(_insertionBuffer, _result, _lastContextLineIndex))
            {
                var insertIndex = GetInsertLineIndex(_currentContextLineIndex, _lastContextLineIndex, insertBefore);

                if (insertIndex <= _result.Count && insertIndex > -1)
                {
                    var lastContextLine = insertIndex != 0 ? _result[insertIndex - 1] : string.Empty;
                    var nextContextLine = insertIndex != _result.Count() ? _result[insertIndex] : string.Empty;

                    if (_codeStyleProvider != null)
                    {
                        _insertionBuffer = _codeStyleProvider.AdaptInsertionBlock(_insertionBuffer, lastContextLine, nextContextLine);
                    }

                    _result.InsertRange(insertIndex, _insertionBuffer);
                    return(_insertionBuffer.Count);
                }
            }

            return(0);
        }