Beispiel #1
0
        public void MonoBehaviourWithEmptyEventMethodIsReported(CodeOptimization codeOptimization)
        {
            var prevCodeOptimization = AssemblyCompilationPipeline.CodeOptimization;

            AssemblyCompilationPipeline.CodeOptimization = codeOptimization;

            var scriptIssues = Utility.AnalyzeAndFindAssetIssues(m_MonoBehaviourWithEmptyEventMethod);

            AssemblyCompilationPipeline.CodeOptimization = prevCodeOptimization; // restore previous value

            Assert.AreEqual(1, scriptIssues.Count());

            var issue = scriptIssues.FirstOrDefault();

            Assert.NotNull(issue);
            Assert.NotNull(issue.descriptor);

            Assert.AreEqual(Rule.Severity.Default, issue.descriptor.severity);
            Assert.AreEqual(EmptyMethodAnalyzer.GetDescriptor().id, issue.descriptor.id);
            Assert.True(string.IsNullOrEmpty(issue.descriptor.type));
            Assert.True(string.IsNullOrEmpty(issue.descriptor.method));

            Assert.True(issue.name.Equals("MonoBehaviourWithEmptyEventMethod.Update"));
            Assert.True(issue.filename.Equals(m_MonoBehaviourWithEmptyEventMethod.fileName));
            Assert.True(issue.description.Equals("System.Void MonoBehaviourWithEmptyEventMethod::Update()"));
            Assert.True(issue.GetCallingMethod().Equals("System.Void MonoBehaviourWithEmptyEventMethod::Update()"));
            Assert.AreEqual(1, issue.line);
            Assert.AreEqual(IssueCategory.Code, issue.category);
        }
        public void MonoBehaviourWithEmptyMagicMethodIsReported()
        {
            var scriptIssues = ScriptIssueTestHelper.AnalyzeAndFindScriptIssues(m_MonoBehaviourWithEmptyMagicMethod);

            Assert.AreEqual(1, scriptIssues.Count());

            var issue = scriptIssues.FirstOrDefault();

            Assert.NotNull(issue);
            Assert.NotNull(issue.descriptor);

            Assert.AreEqual(Rule.Severity.Default, issue.descriptor.severity);
            Assert.AreEqual(EmptyMethodAnalyzer.GetDescriptor().id, issue.descriptor.id);
            Assert.True(string.IsNullOrEmpty(issue.descriptor.type));
            Assert.True(string.IsNullOrEmpty(issue.descriptor.method));

            Assert.True(issue.name.Equals("MonoBehaviourWithEmptyMagicMethod.Update"));
            Assert.True(issue.filename.Equals(m_MonoBehaviourWithEmptyMagicMethod.scriptName));
            Assert.True(issue.description.Equals("System.Void MonoBehaviourWithEmptyMagicMethod::Update()"));
            Assert.True(issue.GetCallingMethod().Equals("System.Void MonoBehaviourWithEmptyMagicMethod::Update()"));
            Assert.AreEqual(1, issue.line);
            Assert.AreEqual(IssueCategory.Code, issue.category);
        }