Skip to content

Commit

Permalink
Unignore tests and provide a COM objects to support tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
bclothier committed Oct 11, 2019
1 parent db52bdb commit 67e205e
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions RubberduckTests/UnitTesting/AssertTests.cs
@@ -1,3 +1,4 @@
using System;
using NUnit.Framework;
using Rubberduck.UnitTesting;

Expand Down Expand Up @@ -68,11 +69,10 @@ public void IsFalseFailsWithTrueExpression()

[Category("Unit Testing")]
[Test]
[Ignore("Would require passing COM objects for proper verification")]
public void AreSameShouldSucceedWithSameReferences()
{
var assert = new AssertClass();
var obj1 = new object();
var obj1 = GetComObject();
var obj2 = obj1;
assert.AreSame(obj1, obj2);

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

[Category("Unit Testing")]
[Test]
[Ignore("Would require passing COM objects for proper verification")]
public void AreSameShouldFailWithDifferentReferences()
{
var assert = new AssertClass();
var obj1 = new object();
var obj2 = new object();
var obj1 = GetComObject();
var obj2 = GetComObject();
assert.AreSame(obj1, obj2);

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

[Category("Unit Testing")]
[Test]
[Ignore("Would require passing COM objects for proper verification")]
public void AreSameShouldFailWithActualNullReference()
{
var assert = new AssertClass();
assert.AreSame(new object(), null);
assert.AreSame(GetComObject(), null);

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

[Category("Unit Testing")]
[Test]
[Ignore("Would require passing COM objects for proper verification")]
public void AreSameShouldFailWithExpectedNullReference()
{
var assert = new AssertClass();
assert.AreSame(null, new object());
assert.AreSame(null, GetComObject());

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

[Category("Unit Testing")]
[Test]
[Ignore("Would require passing COM objects for proper verification")]
public void AreNotSameShouldSucceedWithDifferentReferences()
{
var assert = new AssertClass();
var obj1 = new object();
var obj2 = new object();
var obj1 = GetComObject();
var obj2 = GetComObject();
assert.AreNotSame(obj1, obj2);

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

[Category("Unit Testing")]
[Test]
[Ignore("Would require passing COM objects for proper verification")]
public void AreNotSameShouldSuccedWithOneNullReference()
{
var assert = new AssertClass();
assert.AreNotSame(new object(), null);
assert.AreNotSame(GetComObject(), null);

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

[Category("Unit Testing")]
[Test]
[Ignore("Would require passing COM objects for proper verification")]
public void AreNotSameShouldFailWithSameReferences()
{
var assert = new AssertClass();
var obj1 = new object();
var obj1 = GetComObject();
var obj2 = obj1;
assert.AreNotSame(obj1, obj2);

Expand Down Expand Up @@ -355,5 +349,8 @@ public void OnAssertInconclusive_ReturnsResultInconclusive()

Assert.AreEqual(TestOutcome.Inconclusive, _args.Outcome);
}

private static Type GetComObjectType() => Type.GetTypeFromProgID("Scripting.FileSystemObject");
private object GetComObject() => Activator.CreateInstance(GetComObjectType());
}
}

0 comments on commit 67e205e

Please sign in to comment.