Skip to content

Commit 67e205e

Browse files
committed
Unignore tests and provide a COM objects to support tests.
1 parent db52bdb commit 67e205e

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

RubberduckTests/UnitTesting/AssertTests.cs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using NUnit.Framework;
23
using Rubberduck.UnitTesting;
34

@@ -68,11 +69,10 @@ public void IsFalseFailsWithTrueExpression()
6869

6970
[Category("Unit Testing")]
7071
[Test]
71-
[Ignore("Would require passing COM objects for proper verification")]
7272
public void AreSameShouldSucceedWithSameReferences()
7373
{
7474
var assert = new AssertClass();
75-
var obj1 = new object();
75+
var obj1 = GetComObject();
7676
var obj2 = obj1;
7777
assert.AreSame(obj1, obj2);
7878

@@ -81,12 +81,11 @@ public void AreSameShouldSucceedWithSameReferences()
8181

8282
[Category("Unit Testing")]
8383
[Test]
84-
[Ignore("Would require passing COM objects for proper verification")]
8584
public void AreSameShouldFailWithDifferentReferences()
8685
{
8786
var assert = new AssertClass();
88-
var obj1 = new object();
89-
var obj2 = new object();
87+
var obj1 = GetComObject();
88+
var obj2 = GetComObject();
9089
assert.AreSame(obj1, obj2);
9190

9291
Assert.AreEqual(TestOutcome.Failed, _args.Outcome);
@@ -104,46 +103,42 @@ public void AreSameShouldSucceedWithTwoNullReferences()
104103

105104
[Category("Unit Testing")]
106105
[Test]
107-
[Ignore("Would require passing COM objects for proper verification")]
108106
public void AreSameShouldFailWithActualNullReference()
109107
{
110108
var assert = new AssertClass();
111-
assert.AreSame(new object(), null);
109+
assert.AreSame(GetComObject(), null);
112110

113111
Assert.AreEqual(TestOutcome.Failed, _args.Outcome);
114112
}
115113

116114
[Category("Unit Testing")]
117115
[Test]
118-
[Ignore("Would require passing COM objects for proper verification")]
119116
public void AreSameShouldFailWithExpectedNullReference()
120117
{
121118
var assert = new AssertClass();
122-
assert.AreSame(null, new object());
119+
assert.AreSame(null, GetComObject());
123120

124121
Assert.AreEqual(TestOutcome.Failed, _args.Outcome);
125122
}
126123

127124
[Category("Unit Testing")]
128125
[Test]
129-
[Ignore("Would require passing COM objects for proper verification")]
130126
public void AreNotSameShouldSucceedWithDifferentReferences()
131127
{
132128
var assert = new AssertClass();
133-
var obj1 = new object();
134-
var obj2 = new object();
129+
var obj1 = GetComObject();
130+
var obj2 = GetComObject();
135131
assert.AreNotSame(obj1, obj2);
136132

137133
Assert.AreEqual(TestOutcome.Succeeded, _args.Outcome);
138134
}
139135

140136
[Category("Unit Testing")]
141137
[Test]
142-
[Ignore("Would require passing COM objects for proper verification")]
143138
public void AreNotSameShouldSuccedWithOneNullReference()
144139
{
145140
var assert = new AssertClass();
146-
assert.AreNotSame(new object(), null);
141+
assert.AreNotSame(GetComObject(), null);
147142

148143
Assert.AreEqual(TestOutcome.Succeeded, _args.Outcome);
149144
}
@@ -160,11 +155,10 @@ public void AreNotSameShouldFailWithBothNullReferences()
160155

161156
[Category("Unit Testing")]
162157
[Test]
163-
[Ignore("Would require passing COM objects for proper verification")]
164158
public void AreNotSameShouldFailWithSameReferences()
165159
{
166160
var assert = new AssertClass();
167-
var obj1 = new object();
161+
var obj1 = GetComObject();
168162
var obj2 = obj1;
169163
assert.AreNotSame(obj1, obj2);
170164

@@ -355,5 +349,8 @@ public void OnAssertInconclusive_ReturnsResultInconclusive()
355349

356350
Assert.AreEqual(TestOutcome.Inconclusive, _args.Outcome);
357351
}
352+
353+
private static Type GetComObjectType() => Type.GetTypeFromProgID("Scripting.FileSystemObject");
354+
private object GetComObject() => Activator.CreateInstance(GetComObjectType());
358355
}
359356
}

0 commit comments

Comments
 (0)