1
+ using System ;
1
2
using NUnit . Framework ;
2
3
using Rubberduck . UnitTesting ;
3
4
@@ -68,11 +69,10 @@ public void IsFalseFailsWithTrueExpression()
68
69
69
70
[ Category ( "Unit Testing" ) ]
70
71
[ Test ]
71
- [ Ignore ( "Would require passing COM objects for proper verification" ) ]
72
72
public void AreSameShouldSucceedWithSameReferences ( )
73
73
{
74
74
var assert = new AssertClass ( ) ;
75
- var obj1 = new object ( ) ;
75
+ var obj1 = GetComObject ( ) ;
76
76
var obj2 = obj1 ;
77
77
assert . AreSame ( obj1 , obj2 ) ;
78
78
@@ -81,12 +81,11 @@ public void AreSameShouldSucceedWithSameReferences()
81
81
82
82
[ Category ( "Unit Testing" ) ]
83
83
[ Test ]
84
- [ Ignore ( "Would require passing COM objects for proper verification" ) ]
85
84
public void AreSameShouldFailWithDifferentReferences ( )
86
85
{
87
86
var assert = new AssertClass ( ) ;
88
- var obj1 = new object ( ) ;
89
- var obj2 = new object ( ) ;
87
+ var obj1 = GetComObject ( ) ;
88
+ var obj2 = GetComObject ( ) ;
90
89
assert . AreSame ( obj1 , obj2 ) ;
91
90
92
91
Assert . AreEqual ( TestOutcome . Failed , _args . Outcome ) ;
@@ -104,46 +103,42 @@ public void AreSameShouldSucceedWithTwoNullReferences()
104
103
105
104
[ Category ( "Unit Testing" ) ]
106
105
[ Test ]
107
- [ Ignore ( "Would require passing COM objects for proper verification" ) ]
108
106
public void AreSameShouldFailWithActualNullReference ( )
109
107
{
110
108
var assert = new AssertClass ( ) ;
111
- assert . AreSame ( new object ( ) , null ) ;
109
+ assert . AreSame ( GetComObject ( ) , null ) ;
112
110
113
111
Assert . AreEqual ( TestOutcome . Failed , _args . Outcome ) ;
114
112
}
115
113
116
114
[ Category ( "Unit Testing" ) ]
117
115
[ Test ]
118
- [ Ignore ( "Would require passing COM objects for proper verification" ) ]
119
116
public void AreSameShouldFailWithExpectedNullReference ( )
120
117
{
121
118
var assert = new AssertClass ( ) ;
122
- assert . AreSame ( null , new object ( ) ) ;
119
+ assert . AreSame ( null , GetComObject ( ) ) ;
123
120
124
121
Assert . AreEqual ( TestOutcome . Failed , _args . Outcome ) ;
125
122
}
126
123
127
124
[ Category ( "Unit Testing" ) ]
128
125
[ Test ]
129
- [ Ignore ( "Would require passing COM objects for proper verification" ) ]
130
126
public void AreNotSameShouldSucceedWithDifferentReferences ( )
131
127
{
132
128
var assert = new AssertClass ( ) ;
133
- var obj1 = new object ( ) ;
134
- var obj2 = new object ( ) ;
129
+ var obj1 = GetComObject ( ) ;
130
+ var obj2 = GetComObject ( ) ;
135
131
assert . AreNotSame ( obj1 , obj2 ) ;
136
132
137
133
Assert . AreEqual ( TestOutcome . Succeeded , _args . Outcome ) ;
138
134
}
139
135
140
136
[ Category ( "Unit Testing" ) ]
141
137
[ Test ]
142
- [ Ignore ( "Would require passing COM objects for proper verification" ) ]
143
138
public void AreNotSameShouldSuccedWithOneNullReference ( )
144
139
{
145
140
var assert = new AssertClass ( ) ;
146
- assert . AreNotSame ( new object ( ) , null ) ;
141
+ assert . AreNotSame ( GetComObject ( ) , null ) ;
147
142
148
143
Assert . AreEqual ( TestOutcome . Succeeded , _args . Outcome ) ;
149
144
}
@@ -160,11 +155,10 @@ public void AreNotSameShouldFailWithBothNullReferences()
160
155
161
156
[ Category ( "Unit Testing" ) ]
162
157
[ Test ]
163
- [ Ignore ( "Would require passing COM objects for proper verification" ) ]
164
158
public void AreNotSameShouldFailWithSameReferences ( )
165
159
{
166
160
var assert = new AssertClass ( ) ;
167
- var obj1 = new object ( ) ;
161
+ var obj1 = GetComObject ( ) ;
168
162
var obj2 = obj1 ;
169
163
assert . AreNotSame ( obj1 , obj2 ) ;
170
164
@@ -355,5 +349,8 @@ public void OnAssertInconclusive_ReturnsResultInconclusive()
355
349
356
350
Assert . AreEqual ( TestOutcome . Inconclusive , _args . Outcome ) ;
357
351
}
352
+
353
+ private static Type GetComObjectType ( ) => Type . GetTypeFromProgID ( "Scripting.FileSystemObject" ) ;
354
+ private object GetComObject ( ) => Activator . CreateInstance ( GetComObjectType ( ) ) ;
358
355
}
359
356
}
0 commit comments