Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 8ca44f6

Browse files
committed
Merge pull request #2566 from Priya91/diagnostictools
Add tests for SuppressMessageAttribute in System.Diagnostics.Tools contract.
2 parents 4966ab7 + 167d06c commit 8ca44f6

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

src/System.Diagnostics.Tools/tests/System.Diagnostics.Tools.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
1616
<ItemGroup>
1717
<Compile Include="System\CodeDom\Compiler\GeneratedCodeAttributeTests.cs" />
18+
<Compile Include="System\Diagnostics\CodeAnalysis\SuppressMessageAttributeTests.cs" />
1819
</ItemGroup>
1920
<ItemGroup>
2021
<!-- Compile tests against the contract, but copy our local-built implementation for testing -->

src/System.Diagnostics.Tools/tests/System/CodeDom/Compiler/GeneratedCodeAttributeTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33

44
using Xunit;
55

6-
namespace System.CodeDom.Compiler
6+
namespace System.CodeDom.Compiler.Tests
77
{
8-
public static class GeneratedCodeAttributeTests
8+
public class GeneratedCodeAttributeTests
99
{
1010
[Theory]
1111
[InlineData(null, null)]
1212
[InlineData("Tool", "Version")]
13-
public static void Constructor(string tool, string version)
13+
public void TestConstructor(string tool, string version)
1414
{
1515
GeneratedCodeAttribute gca = new GeneratedCodeAttribute(tool, version);
1616

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using Xunit;
5+
6+
namespace System.Diagnostics.CodeAnalysis.Tests
7+
{
8+
public class SuppressMessageAttributeTests
9+
{
10+
[Theory]
11+
[InlineData("Category", "CheckId", "Justification", "MessageId", "Scope", "Target")]
12+
[InlineData("", "", "", "", "", "")]
13+
[InlineData(null, null, null, null, null, null)]
14+
[InlineData("", null, "Justification", null, "Scope", "")]
15+
public void TestConstructor(string category, string id, string justification, string messageId, string scope, string target)
16+
{
17+
SuppressMessageAttribute sma = new SuppressMessageAttribute(category, id)
18+
{
19+
Justification = justification,
20+
MessageId = messageId,
21+
Scope = scope,
22+
Target = target
23+
};
24+
25+
Assert.Equal(category, sma.Category);
26+
Assert.Equal(id, sma.CheckId);
27+
Assert.Equal(justification, sma.Justification);
28+
Assert.Equal(messageId, sma.MessageId);
29+
Assert.Equal(scope, sma.Scope);
30+
Assert.Equal(target, sma.Target);
31+
}
32+
}
33+
}

0 commit comments

Comments
 (0)