-
Notifications
You must be signed in to change notification settings - Fork 4.6k
/
LabelEquals.cs
54 lines (47 loc) · 1.63 KB
/
LabelEquals.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
// 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.Reflection.Emit.Tests
{
public class LabelEquals
{
[Fact]
public void Equals_SameInstance_ReturnsTrue()
{
Label label = new Label();
Assert.True(label.Equals(label));
Assert.True(label.Equals((object)label));
Assert.True(label.Equals((IEquatable<Label>)label));
}
[Fact]
public void Equals_DifferentLabel_ReturnsFalse()
{
TypeBuilder type = Helpers.DynamicType(TypeAttributes.NotPublic);
MethodBuilder method = type.DefineMethod("Method", MethodAttributes.Public);
ILGenerator ilGenerator = method.GetILGenerator();
Label label1 = ilGenerator.DefineLabel();
Label label2 = ilGenerator.DefineLabel();
Assert.False(label1.Equals(label2));
Assert.False(label1.Equals((object)label2));
Assert.False(label1.Equals((IEquatable<Label>)label2));
}
[Theory]
[InlineData(1)]
[InlineData("label")]
[InlineData(" ")]
[InlineData(null)]
public void Equals_ObjectNotLabel_ReturnsFalse(object obj)
{
Label label = new Label();
Assert.False(label.Equals(obj));
}
[Fact]
public void Equals_EqualityOperators()
{
Label lb1 = new Label();
Label lb2 = new Label();
Assert.True(lb1 == lb2);
Assert.False(lb1 != lb2);
}
}
}