Skip to content
This repository was archived by the owner on Nov 8, 2018. It is now read-only.

Commit 2fd4b28

Browse files
committed
Add tests for simple helper types
1 parent 5cbfd10 commit 2fd4b28

File tree

5 files changed

+78
-1
lines changed

5 files changed

+78
-1
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2+
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
3+
4+
namespace AsyncUsageAnalyzers.Test
5+
{
6+
using Xunit;
7+
8+
public class AnalyzerConstantsUnitTests
9+
{
10+
[Fact]
11+
public void TestEnabledByDefault()
12+
{
13+
Assert.True(AnalyzerConstants.EnabledByDefault);
14+
}
15+
16+
[Fact]
17+
public void TestDisabledByDefault()
18+
{
19+
Assert.False(AnalyzerConstants.DisabledByDefault);
20+
}
21+
22+
[Fact]
23+
public void TestDisabledAlternative()
24+
{
25+
Assert.False(AnalyzerConstants.DisabledAlternative);
26+
}
27+
28+
[Fact]
29+
public void TestDisabledNoTests()
30+
{
31+
#if DEBUG
32+
Assert.True(AnalyzerConstants.DisabledNoTests);
33+
#else
34+
Assert.False(AnalyzerConstants.DisabledNoTests);
35+
#endif
36+
}
37+
}
38+
}

AsyncUsageAnalyzers/AsyncUsageAnalyzers.Test/AsyncUsageAnalyzers.Test.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,11 @@
117117
</Reference>
118118
</ItemGroup>
119119
<ItemGroup>
120+
<Compile Include="AnalyzerConstantsUnitTests.cs" />
121+
<Compile Include="AttributesUnitTests.cs" />
120122
<Compile Include="Helpers\DiagnosticResultLocation.cs" />
121123
<Compile Include="Helpers\MetadataReferences.cs" />
124+
<Compile Include="Helpers\SpecializedTasksUnitTests.cs" />
122125
<Compile Include="Helpers\TestDiagnosticProvider.cs" />
123126
<Compile Include="Naming\AvoidAsyncSuffixUnitTests.cs" />
124127
<Compile Include="Naming\UseAsyncSuffixUnitTests.cs" />
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2+
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
3+
4+
namespace AsyncUsageAnalyzers.Test
5+
{
6+
using Xunit;
7+
8+
public class AttributesUnitTests
9+
{
10+
[Fact]
11+
public void TestNoCodeFixAttribute()
12+
{
13+
var attribute = new NoCodeFixAttribute("Message");
14+
Assert.Equal("Message", attribute.Reason);
15+
}
16+
}
17+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2+
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
3+
4+
namespace AsyncUsageAnalyzers.Test.Helpers
5+
{
6+
using System.Threading.Tasks;
7+
using AsyncUsageAnalyzers.Helpers;
8+
using Xunit;
9+
10+
public class SpecializedTasksUnitTests
11+
{
12+
[Fact]
13+
public void TestCompletedTask()
14+
{
15+
Assert.NotNull(SpecializedTasks.CompletedTask);
16+
Assert.Equal(TaskStatus.RanToCompletion, SpecializedTasks.CompletedTask.Status);
17+
Assert.Same(SpecializedTasks.CompletedTask, SpecializedTasks.CompletedTask);
18+
}
19+
}
20+
}

AsyncUsageAnalyzers/AsyncUsageAnalyzers/AnalyzerConstants.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ static AnalyzerConstants()
2828
/// <see cref="DiagnosticDescriptor(string, string, string, string, DiagnosticSeverity, bool, string, string, string[])"/>
2929
/// to disable a diagnostic which is currently untested.
3030
/// </value>
31-
[ExcludeFromCodeCoverage]
3231
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1623:Property summary documentation must match accessors.", Justification = "This property behaves more like an opaque value than a Boolean.")]
3332
internal static bool DisabledNoTests { get; }
3433

0 commit comments

Comments
 (0)