Skip to content

Commit

Permalink
Merge pull request #6032 from tommy9/SequenceEqualsTests#5827
Browse files Browse the repository at this point in the history
Sequence equals tests#5827
  • Loading branch information
retailcoder committed Oct 17, 2022
2 parents c78459a + ad4886f commit 9168dbf
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Rubberduck.Main/ComClientLibrary/UnitTesting/AssertClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ protected void TestArraySequenceEquity(Array expected, Array actual, string mess
return;
}
AssertHandler.OnAssertSucceeded();
return;
}

for (var rank = 0; rank < expected.Rank; rank++)
Expand All @@ -287,6 +288,7 @@ protected void TestArraySequenceEquity(Array expected, Array actual, string mess
return;
}
AssertHandler.OnAssertSucceeded();
return;
}

expectedBound = expected.GetUpperBound(rank);
Expand All @@ -300,6 +302,7 @@ protected void TestArraySequenceEquity(Array expected, Array actual, string mess
return;
}
AssertHandler.OnAssertSucceeded();
return;
}
}

Expand Down
34 changes: 34 additions & 0 deletions RubberduckTests/UnitTesting/AssertTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,40 @@ public void OnAssertInconclusive_ReturnsResultInconclusive()
Assert.AreEqual(TestOutcome.Inconclusive, _args.Outcome);
}

[Category("Unit Testing")]
[Test]
public void NotSequenceEqualShouldSucceedWithDifferentRanks()
{
var assert = new AssertClass();

int[] lengthsArray2D = new int[2] { 2, 2 };
Array myArray2D = Array.CreateInstance(typeof(Int32), lengthsArray2D);
int length1Darray = 4;
Array myArray1D = Array.CreateInstance(typeof(Int32), length1Darray);

assert.NotSequenceEquals(myArray2D, myArray1D);

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

[Category("Unit Testing")]
[Test]
public void NotSequenceEqualShouldSucceedWithDifferentLowerBounds()
{
var assert = new AssertClass();

int[] lengthsArray1 = new int[1] { 2 };
int[] boundsArray1 = new int[1] { 0 };
Array arrayZeroBased = Array.CreateInstance(typeof(Int32),lengthsArray1, boundsArray1);
int[] lengthsArray2 = new int[1] { 2 };
int[] boundsArray2 = new int[1] { -1 };
Array arrayNegative1Based = Array.CreateInstance(typeof(Int32), lengthsArray2, boundsArray2);

assert.NotSequenceEquals(arrayZeroBased, arrayNegative1Based);

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

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

0 comments on commit 9168dbf

Please sign in to comment.