Beispiel #1
0
        private void Init(ITextSnapshot textSnapshot)
        {
            var methods = methodsExtractor.Extract(textSnapshot.GetText())
                          .OfType <ISyntaxNode>();

            syntaxNodes = methods.ToDictionary(method => method, method => method);
        }
Beispiel #2
0
        private void Init(ITextSnapshot textSnapshot)
        {
            IEnumerable <IMethod> methods = methodsExtractor.Extract(textSnapshot.GetText())
                                            .Where(method => method.BodyEnd.Line >= 0);

            methodToText = methods.ToDictionary(method => method, method => GetText(textSnapshot, method));
        }
Beispiel #3
0
        public void Calculate_SingleInterfaceWithSingleMethod_ShouldReturnDefaultValue()
        {
            const string fileCode = @"using System;

namespace SomeNamespace
{
    public interface ISomeInterface
    {
        void SomeMethod(object input);
    }
}";

            var syntaxNodes = extractor.Extract(fileCode);
            var syntaxNode  = syntaxNodes.OfType <ISyntaxNode>().FirstOrDefault();

            var complexity = calculator.Calculate(syntaxNode);

            Assert.That(complexity.Value, Is.EqualTo(1));
        }
Beispiel #4
0
 protected IEnumerable <ISyntaxNode> ExtractSyntaxNodes(string fileCode)
 {
     return(extractor.Extract(fileCode).OfType <ISyntaxNode>());
 }