Пример #1
0
 public UsingCookies(IAnalyzerConfiguration analyzerConfiguration)
 {
     PropertyAccessTracker = new CSharpPropertyAccessTracker(analyzerConfiguration, rule);
     ElementAccessTracker  = new CSharpElementAccessTracker(analyzerConfiguration, rule);
     ObjectCreationTracker = new CSharpObjectCreationTracker(analyzerConfiguration, rule);
     InvocationTracker     = new CSharpInvocationTracker(analyzerConfiguration, rule);
 }
Пример #2
0
 public UsingCookies(IAnalyzerConfiguration analyzerConfiguration) : base(RspecStrings.ResourceManager)
 {
     PropertyAccessTracker = new CSharpPropertyAccessTracker(analyzerConfiguration, Rule);
     ElementAccessTracker  = new CSharpElementAccessTracker(analyzerConfiguration, Rule);
     ObjectCreationTracker = new CSharpObjectCreationTracker(analyzerConfiguration, Rule);
     InvocationTracker     = new CSharpInvocationTracker(analyzerConfiguration, Rule);
 }
        public void ArgumentAtIndexIs_CS()
        {
            var context = CreateContext <CSharpSyntax.ElementAccessExpressionSyntax>(TestInputCS, 0, AnalyzerLanguage.CSharp);
            var tracker = new CSharpElementAccessTracker();

            tracker.ArgumentAtIndexIs(0, KnownType.System_String)(context).Should().BeTrue();
            tracker.ArgumentAtIndexIs(0, KnownType.System_Int32)(context).Should().BeFalse();
            tracker.ArgumentAtIndexIs(42, KnownType.System_String)(context).Should().BeFalse();

            context = CreateContext <CSharpSyntax.ElementAccessExpressionSyntax>(TestInputCS, 3, AnalyzerLanguage.CSharp);
            tracker.ArgumentAtIndexIs(0, KnownType.System_String)(context).Should().BeFalse();
        }
        public void ArgumentAtIndexIs_VB()
        {
            var context = CreateContext <VBSyntax.InvocationExpressionSyntax>(TestInputVB, 0, AnalyzerLanguage.VisualBasic);
            var tracker = new CSharpElementAccessTracker();

            tracker.ArgumentAtIndexIs(0, KnownType.System_String)(context).Should().BeTrue();
            tracker.ArgumentAtIndexIs(0, KnownType.System_Int32)(context).Should().BeFalse();
            tracker.ArgumentAtIndexIs(42, KnownType.System_String)(context).Should().BeFalse();

            context = CreateContext <VBSyntax.InvocationExpressionSyntax>(TestInputVB, 4, AnalyzerLanguage.VisualBasic);
            tracker.ArgumentAtIndexIs(0, KnownType.System_String)(context).Should().BeFalse();
        }
        public void ArgumentAtIndexEquals_CS()
        {
            var context = CreateContext <CSharpSyntax.ElementAccessExpressionSyntax>(TestInputCS, 0, AnalyzerLanguage.CSharp);
            var tracker = new CSharpElementAccessTracker();

            tracker.ArgumentAtIndexEquals(0, "key")(context).Should().BeTrue();
            tracker.ArgumentAtIndexEquals(0, "foo")(context).Should().BeFalse();
            tracker.ArgumentAtIndexEquals(42, "key")(context).Should().BeFalse();

            context = CreateContext <CSharpSyntax.ElementAccessExpressionSyntax>(TestInputCS, 1, AnalyzerLanguage.CSharp);
            tracker.ArgumentAtIndexEquals(0, "key")(context).Should().BeTrue();
            tracker.ArgumentAtIndexEquals(0, "foo")(context).Should().BeFalse();
            tracker.ArgumentAtIndexEquals(42, "key")(context).Should().BeFalse();

            context = CreateContext <CSharpSyntax.ElementAccessExpressionSyntax>(TestInputCS, 2, AnalyzerLanguage.CSharp);
            tracker.ArgumentAtIndexEquals(0, "key")(context).Should().BeFalse();
            tracker.ArgumentAtIndexEquals(0, "foo")(context).Should().BeFalse();
            tracker.ArgumentAtIndexEquals(42, "key")(context).Should().BeFalse();
        }