• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# TestHelper.DiagnosticResult类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中TestHelper.DiagnosticResult的典型用法代码示例。如果您正苦于以下问题:C# DiagnosticResult类的具体用法?C# DiagnosticResult怎么用?C# DiagnosticResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DiagnosticResult类属于TestHelper命名空间,在下文中一共展示了DiagnosticResult类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: DoNotUseValuesWhenMultipleIsFalse

		public void DoNotUseValuesWhenMultipleIsFalse()
		{
			var testContent = @"
				using Bridge.React;

				namespace TestCase
				{
					public class Example
					{
						public void Go()
						{
							new SelectAttributes { Multiple = false, Values = new[] { ""1"" } };
						}
					}
				}";

			var expected = new DiagnosticResult
			{
				Id = SelectAttributesAnalyzer.DiagnosticId,
				Message = SelectAttributesAnalyzer.DoNotUseValuesWhenMultipleIsFalseRule.MessageFormat.ToString(),
				Severity = DiagnosticSeverity.Warning,
				Locations = new[]
				{
					new DiagnosticResultLocation("Test0.cs", 10, 29)
				}
			};

			VerifyCSharpDiagnostic(testContent, expected);
		}
开发者ID:ProductiveRage,项目名称:Bridge.React,代码行数:29,代码来源:SelectAttributesTests.cs


示例2: AccessWithoutChecking

        public void AccessWithoutChecking()
        {
            var code = @"
                        using System;
                        using System.Linq;

                        namespace ConsoleApp1
                        {
                            public class Test0
                            {
                                public void Tested()
                                {
                                    var obj = new Object();
                                    
                                    var s = obj as String;

                                    var toString = s.ToString();
                                }
                            }
                        }
                        ";

            var expected = new DiagnosticResult
            {
                Id = "AV1570",
                Message = "Always check the result of an as operation",
                Severity = DiagnosticSeverity.Warning,
                Locations =
                    new[] {
                            new DiagnosticResultLocation("Test0.cs", 15, 52)
                        }
            };

            VerifyCSharpDiagnostic(code, expected);
        }
开发者ID:mytinyfast,项目名称:CSharpCodingGuidelines,代码行数:35,代码来源:AV1570Tests.cs


示例3: Test1

        public void Test1()
        {
            var test = @"
class C
{
    public void M1()
    {
    }

    public virtual void M2()
    {
    }

    public int M3()
    {
    }
}";
            var expected = new DiagnosticResult
            {
                Id = DiagnosticIds.CodeBlockAnalyzerRuleId,
                Message = string.Format(Resources.CodeBlockAnalyzerMessageFormat, "M1"),
                Severity = DiagnosticSeverity.Warning,
                Locations =
                    new[]
                    {
                        new DiagnosticResultLocation("Test0.cs", 4, 17)
                    }
            };

            VerifyCSharpDiagnostic(test, expected);
        }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:31,代码来源:CodeBlockAnalyzerUnitTests.cs


示例4: UnHandle

        public void UnHandle()
        {
            var source = @"
using System;
   
class Test
{
    IObservable<int> GetObservable() => null;

    void Hoge()
    {
        GetObservable();
    }
}";
            var expected = new DiagnosticResult
            {
                Id = UniRxAnalyzer.HandleObservableAnalyzer.DiagnosticId,
                Message = "This call does not handle IObservable<T>.",
                Severity = DiagnosticSeverity.Warning,
                Locations = new[]
                {
                    new DiagnosticResultLocation("Test0.cs", 10, 9)
                }
            };

            this.VerifyCSharpDiagnostic(source, expected);
        }
开发者ID:createdbyx,项目名称:UniRx,代码行数:27,代码来源:HandleObservableAnalyzerTest.cs


示例5: TestCSharpAtrributesPresentButEmpty

        public void TestCSharpAtrributesPresentButEmpty()
        {
            var expected = new DiagnosticResult[4];
            expected[0] = CompanyAttributeResult;
            expected[1] = CopyrightAttributeResult;
            expected[2] = DescriptionAttributeResult;
            expected[3] = TitleAttributeResult;

            VerifyCSharpDiagnostic(@"
using System;
using System.Reflection;

[assembly: AssemblyTitle("""")]
[assembly: AssemblyDescription("""")]
[assembly: AssemblyCompany("""")]
[assembly: AssemblyCopyright("""")]

namespace SomeTests
{
    public class BasicClass
    {
        public void SomeWork(String message)
        {
            Console.WriteLine(message);
        }
    }
}
", expected);
        }
开发者ID:vuder,项目名称:Wintellect.Analyzers,代码行数:29,代码来源:AssemblyAttributesUnitTests.cs


示例6: ForeachSimpleStatementAssignment

        public void ForeachSimpleStatementAssignment()
        {
            var code = @"
                        using System;
                        using System.Linq;

                        namespace ConsoleApp1
                        {
                            public class Test0
                            {
                                public void Tested()
                                {
                                    var list = new List<int>();
                                    foreach(var item in list)
                                        item = null;
                                }
                            }
                        }
                        ";

            var expected = new DiagnosticResult
            {
                Id = "AV1530",
                Message = "Don’t change a loop variable inside a for or foreach loop",
                Severity = DiagnosticSeverity.Warning,
                Locations =
                    new[] {
                            new DiagnosticResultLocation("Test0.cs", 13, 41)
                        }
            };

            VerifyCSharpDiagnostic(code, expected);
        }
开发者ID:mytinyfast,项目名称:CSharpCodingGuidelines,代码行数:33,代码来源:AV1530Tests.cs


示例7: TestMethod2

        public void TestMethod2()
        {
            var test = @"using System;
using FluentArithmetic;

class Program
{
    static void Main(string[] args)
    {
        var x = 1.Add(2).Mul(3).Sub(1).Div(0);
        Console.WriteLine(x);
    }
}
";
            var expected = new DiagnosticResult
            {
                Id = DivByZeroAnalyzer.DiagnosticId,
                Message = DivByZeroAnalyzer.MessageFormat.ToString(),
                Severity = DiagnosticSeverity.Error,
                Locations = new[]
                {
                    new DiagnosticResultLocation("Test0.cs", 8, 44)
                }
            };

            VerifyCSharpDiagnostic(test, expected);
        }
开发者ID:ufcpp,项目名称:UfcppSample,代码行数:27,代码来源:DivByZeroUnitTest.cs


示例8: ValidateDiagnosticFires

        public void ValidateDiagnosticFires()
        {
            var test = @"
            using System;
            using System.Collections.Generic;

            namespace ConsoleApplication1
            {
            class TypeName
            {
               var a = new System.Collections.ArrayList();
            }
            }";
            var expected = new DiagnosticResult
            {
                Id = DontUseArrayList.DiagnosticId,
                Message = "The type ArrayList should not be used",
                Severity = DiagnosticSeverity.Warning,
                Locations =
                    new[] {
                            new DiagnosticResultLocation("Test0.cs", 9, 20)
                        }
            };

            VerifyCSharpDiagnostic(test, expected);
        }
开发者ID:johnkoerner,项目名称:AnalyzerSamples,代码行数:26,代码来源:DontUseArrayListTests.cs


示例9: MethodNamesTest

        public void MethodNamesTest()
        {
            string test = System.IO.File.ReadAllText(@"TestCodes\AsyncTestCode_1.cs");
            var expected1 = new DiagnosticResult
            {
                Id = AsyncAnalyzerAnalyzer.DiagnosticId,
                Message = String.Format("Async method name '{0}' does not end with Async", "Test"),
                Severity = DiagnosticSeverity.Warning,
                Locations =
                    new[]
                    {
                        new DiagnosticResultLocation("Test0.cs", 12, 27),
                    }
            };

            var expected2 = new DiagnosticResult
            {
                Id = AsyncAnalyzerAnalyzer.DiagnosticId,
                Message = String.Format("Async method name '{0}' does not end with Async", "Something"),
                Severity = DiagnosticSeverity.Warning,
                Locations =
                    new[]
                    {
                        new DiagnosticResultLocation("Test0.cs", 28, 33),
                    }
            };

            VerifyCSharpDiagnostic(test, expected1, expected2);

            string fixtest = System.IO.File.ReadAllText(@"TestCodes\AsyncTestCode_1_fix.cs");
            VerifyCSharpFix(test, fixtest);
        }
开发者ID:jernejk,项目名称:Roslyn-simple-demos,代码行数:32,代码来源:JkAsyncTests.cs


示例10: TestBasicEmptyComment

        public void TestBasicEmptyComment()
        {
            var testCode = @"
            class Foo
            {
            public void Bar()
            {
            //
            }
            }";

            var expected = new DiagnosticResult
            {
                Id = EmptyCommentAnalyzer.DiagnosticId,
                Message = EmptyCommentAnalyzer.MessageFormat.ToString(),
                Severity = DiagnosticSeverity.Warning,
                Locations =
                    new[] {
                            new DiagnosticResultLocation("Test0.cs", 6, 9)
                        }
            };
            this.VerifyCSharpDiagnostic(testCode, expected);

            var expectedFixedCode = @"
            class Foo
            {
            public void Bar()
            {
            }
            }";
            this.VerifyCSharpFix(testCode, expectedFixedCode);
        }
开发者ID:johnkoerner,项目名称:AnalyzerSamples,代码行数:32,代码来源:EmptyCommentCodeFix.cs


示例11: AssertEquals_IfActualValueIsAStringLiteral_ThenItTriggersTheDiagnostic

        public void AssertEquals_IfActualValueIsAStringLiteral_ThenItTriggersTheDiagnostic()
        {
            var test = @"
    using System;
    using System.Linq;
    using Xunit;

    namespace WongaTests
    {
        class WongaTest
        {
            [Fact]
            public void MyTest()
            {
                var result = Testee.GetSomeData();
                Assert.Equal(result.Id, ""someId"");
            }
        }
    }";
            var expected = new DiagnosticResult
            {
                Id = "AssertExpectedActualAnalyser",
                Message = "Possible incorrect argument order in 'Assert.Equal': '\"someId\"' is likely to be the expected value",
                Severity = DiagnosticSeverity.Warning,
                Locations =
                    new[] {
                            new DiagnosticResultLocation("Test0.cs", 14, 17)
                        }
            };

            VerifyCSharpDiagnostic(test, expected);
        }
开发者ID:itowlson,项目名称:unexpected,代码行数:32,代码来源:UnitTests.cs


示例12: TestMethod2

        public void TestMethod2()
        {
            const String test = @"
            using System;

            namespace ConsoleApplication1
            {
            class TypeName
            {
            }
            }";
            var expected = new DiagnosticResult
            {
                Id = "CSharpCodeFixes",
                Message = $"Type name '{"TypeName"}' contains lowercase letters",
                Severity = DiagnosticSeverity.Warning,
                Locations =
                    new[] {
                            new DiagnosticResultLocation("Test0.cs", 6, 15)
                        }
            };

            VerifyCSharpDiagnostic(test, expected);

            const String fixtest = @"
            using System;

            namespace ConsoleApplication1
            {
            class TYPENAME
            {
            }
            }";
            VerifyCSharpFix(test, fixtest);
        }
开发者ID:damieng,项目名称:CSharpCodeFixes,代码行数:35,代码来源:UnitTests.cs


示例13: CorrectDiagnosticWhenAnonymousTypeInProjection

        public void CorrectDiagnosticWhenAnonymousTypeInProjection()
        {
            // Fixture setup
            var test = @"
            using System;
            using System.Linq;

            namespace N
            {
            class C
            {
            void M()
            {
            var q = Enumerable.Range(0, 5)
                .Select(i => new { Qux = i });
            }
            }
            }";
            var expected = new DiagnosticResult
            {
                Id = "ExtractAnonymousType",
                Message = "Anonymous type used",
                Severity = DiagnosticSeverity.Info,
                Locations =
                    new[] {
                            new DiagnosticResultLocation("Test0.cs", 12, 30)
                        }
            };
            // Exercise system & Verify outcome
            VerifyCSharpDiagnostic(test, expected);
            // Teardown
        }
开发者ID:Pvlerick,项目名称:ExtractAnonymousType,代码行数:32,代码来源:ExtractAnonymousTypeAnalyzerTests.cs


示例14: Test1

        public void Test1()
        {
            var test = @"
class C
{
    public void M()
    {
        var implicitTypedLocal = 0;
        int explicitTypedLocal = 1;
    }
}";
            var expected = new DiagnosticResult
            {
                Id = DiagnosticIds.SyntaxNodeAnalyzerRuleId,
                Message = string.Format(Resources.SyntaxNodeAnalyzerMessageFormat, "implicitTypedLocal"),
                Severity = DiagnosticSeverity.Warning,
                Locations =
                    new[]
                    {
                        new DiagnosticResultLocation("Test0.cs", 6, 13)
                    }
            };

            VerifyCSharpDiagnostic(test, expected);
        }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:25,代码来源:SyntaxNodeAnalyzerUnitTests.cs


示例15: Test1

        public void Test1()
        {
            var test = @"
namespace MyInterfaces
{
    public interface Interface {}

    class MyInterfaceImpl : Interface
    {
    }

    class MyInterfaceImpl2 : Interface
    {
    }
}";
            var expected = new DiagnosticResult
            {
                Id = DiagnosticIds.CompilationStartedAnalyzerRuleId,
                Message = string.Format(Resources.CompilationStartedAnalyzerMessageFormat, "MyInterfaceImpl2", CompilationStartedAnalyzer.DontInheritInterfaceTypeName),
                Severity = DiagnosticSeverity.Warning,
                Locations =
                    new[]
                    {
                        new DiagnosticResultLocation("Test0.cs", 10, 11)
                    }
            };

            VerifyCSharpDiagnostic(test, expected);
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:29,代码来源:CompilationStartedAnalyzerUnitTests.cs


示例16: InstantiationOfNestedGenericTypeThatReferencesReactElementWillFail

		public void InstantiationOfNestedGenericTypeThatReferencesReactElementWillFail()
		{
			var testContent = @"
				using System.Collections.Generic;
				using Bridge.React;

				namespace TestCase
				{
					public class Example
					{
						public void Go()
						{
							var x = new List<KeyValuePair<string, ReactElement>>();
						}
					}
				}";

			var expected = new DiagnosticResult
			{
				Id = ReactElementAnalyser.DiagnosticId,
				Message = ReactElementAnalyser.InstantiationsThatReferToTypesNotAvailableAtRuntimeRule.MessageFormat.ToString(),
				Severity = DiagnosticSeverity.Error,
				Locations = new[]
				{
					new DiagnosticResultLocation("Test0.cs", 11, 46)
				}
			};

			VerifyCSharpDiagnostic(testContent, expected);
		}
开发者ID:ProductiveRage,项目名称:Bridge.React,代码行数:30,代码来源:ReactElementTests.cs


示例17: Test1

        public void Test1()
        {
            var test = @"
class BadOne
{
    public void BadOne() {}
}

class GoodOne
{
}";
            var expected = new DiagnosticResult
            {
                Id = DiagnosticIds.SymbolAnalyzerRuleId,
                Message = string.Format(Resources.SymbolAnalyzerMessageFormat, "BadOne"),
                Severity = DiagnosticSeverity.Warning,
                Locations =
                    new[]
                    {
                        new DiagnosticResultLocation("Test0.cs", 2, 7)
                    }
            };

            VerifyCSharpDiagnostic(test, expected);
        }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:25,代码来源:SymbolAnalyzerUnitTests.cs


示例18: NestedExplicitPrivateClassInStruct

 public void NestedExplicitPrivateClassInStruct()
 {
     const string Test = @"
     namespace N
     {
     struct S
     {
     private class NC
     { }
     }
     }";
     const string Fixed = @"
     namespace N
     {
     struct S
     {
     class NC
     { }
     }
     }";
     var expected = new DiagnosticResult
     {
         Id = ExplicitDefaultAccessModifiersAnalyzer.DiagnosticId,
         Severity = DiagnosticSeverity.Warning,
         Locations = new[]
         {
             new DiagnosticResultLocation("Test0.cs", 6, 3)
         }
     };
     VerifyCSharpDiagnostic(Test, expected);
     VerifyCSharpFix(Test, Fixed);
 }
开发者ID:cincuranet,项目名称:ExplicitDefaultAccessModifiersAnalyzer,代码行数:32,代码来源:ClassStructInterfaceEnumTests.cs


示例19: ExplicitPrivateMethod

 public void ExplicitPrivateMethod()
 {
     const string Test = @"
     namespace N
     {
     class C
     {
     private int M() { };
     }
     }";
     const string Fixed = @"
     namespace N
     {
     class C
     {
     int M() { };
     }
     }";
     var expected = new DiagnosticResult
     {
         Id = ExplicitDefaultAccessModifiersAnalyzer.DiagnosticId,
         Severity = DiagnosticSeverity.Warning,
         Locations = new[]
         {
             new DiagnosticResultLocation("Test0.cs", 6, 3)
         }
     };
     VerifyCSharpDiagnostic(Test, expected);
     VerifyCSharpFix(Test, Fixed);
 }
开发者ID:cincuranet,项目名称:ExplicitDefaultAccessModifiersAnalyzer,代码行数:30,代码来源:MethodConstructorTests.cs


示例20: Test1

        public void Test1()
        {
            var test = @"
class C
{
    public int M1(int p1, int p2)
    {
        return M2(p1, p1);
    }

    public int M2(int p1, int p2)
    {
        return p1 + p2;
    }
}";
            var expected = new DiagnosticResult
            {
                Id = DiagnosticIds.CodeBlockStartedAnalyzerRuleId,
                Message = string.Format(Resources.CodeBlockStartedAnalyzerMessageFormat, "p2", "M1"),
                Severity = DiagnosticSeverity.Warning,
                Locations =
                    new[]
                    {
                        new DiagnosticResultLocation("Test0.cs", 4, 31)
                    }
            };

            VerifyCSharpDiagnostic(test, expected);
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:29,代码来源:CodeBlockStartedAnalyzerUnitTests.cs



注:本文中的TestHelper.DiagnosticResult类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# WindowItems.Window类代码示例发布时间:2022-05-26
下一篇:
C# TestClasses.TestViewModel类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap