-
Notifications
You must be signed in to change notification settings - Fork 4.6k
/
DebuggerDisplayAttributeTests.cs
67 lines (60 loc) · 2.25 KB
/
DebuggerDisplayAttributeTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Xunit;
namespace System.Diagnostics.Tests
{
public class DebuggerDisplayAttributeTests
{
[Theory]
[InlineData(null)]
[InlineData("")]
[InlineData("Value")]
public void Ctor_Value(string value)
{
var attribute = new DebuggerDisplayAttribute(value);
Assert.Equal(string.Empty, attribute.Name);
Assert.Equal(value ?? string.Empty, attribute.Value);
Assert.Equal(string.Empty, attribute.Type);
Assert.Null(attribute.Target);
Assert.Null(attribute.TargetTypeName);
}
[Theory]
[InlineData(null)]
[InlineData("Name")]
public void Name_Set_GetReturnsExpected(string name)
{
var attribute = new DebuggerDisplayAttribute("Value") { Name = name };
Assert.Equal(name, attribute.Name);
}
[Theory]
[InlineData(null)]
[InlineData("Type")]
public void Type_Set_GetReturnsExpected(string type)
{
var attribute = new DebuggerDisplayAttribute("Value") { Type = type };
Assert.Equal(type, attribute.Type);
}
[Theory]
[InlineData(typeof(int))]
public void Target_Set_GetReturnsExpected(Type target)
{
var attribute = new DebuggerDisplayAttribute("Value") { Target = target };
Assert.Equal(target, attribute.Target);
Assert.Equal(target.AssemblyQualifiedName, attribute.TargetTypeName);
}
[Fact]
public void Target_SetNull_ThrowsArgumentNullException()
{
var attribute = new DebuggerDisplayAttribute("Value");
AssertExtensions.Throws<ArgumentNullException>("value", () => attribute.Target = null);
}
[Theory]
[InlineData(null)]
[InlineData("TargetTypeName")]
public void TargetTypeName_Set_GetReturnsExpected(string targetTypeName)
{
var attribute = new DebuggerDisplayAttribute("Value") { TargetTypeName = targetTypeName };
Assert.Equal(targetTypeName, attribute.TargetTypeName);
}
}
}