question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IsInstanceOfType fails on COM-objects

See original GitHub issue

I was using the Microsoft.VisualStudio.QualityTools.UnitTestFramework in Visual Studio 2015 so far.

Here is a TestMethod that worked until now:

<TestMethod> Public Sub GetStringParameterTest()
     Dim rootParamSet As ParameterSet = XXXUtilities.GetOrCreateRootParameterSet(_workDocument, ROOT_PARAM_SET_NAME)
     Dim paramSubSet As ParameterSet = XXXUtilities.GetOrCreateParameterSubSet(rootParamSet, PARAM_SUBSET_NAME, False)
     Dim stringParameter As StrParam = XXXUtilities.GetOrCreateStringParameter(paramSubSet, "UNITTEST_STRING_PARAM", False)

     Dim actual As StrParam = XXXUtilities.GetStringParameter(paramSubSet, "UNITTEST_STRING_PARAM")

     Assert.IsNotNull(actual)
     Assert.IsInstanceOfType(actual, GetType(StrParam))
     Dim name As String = XXXUtilities.GetParameterShortName(actual.Name)
     Assert.AreEqual("UNITTEST_STRING_PARAM", name)
 End Sub

Expected behaviour: Assert.IsInstanceOfType(actual, GetType(StrParam)) returns true. StrParam is a Type defined in a COM-DLL.

Today, I tried to use the Microsoft.VisualStudio.TestPlatform.TestFramework instead, because I need to use data-driven TestMethods with DataRows.

Actual behavior: the same test now fails with this error:

Result Message: Assert.IsInstanceOfType failed. Expected type:<KnowledgewareTypeLib.StrParam>. Actual type:<System.__ComObject>.

Obviously, the type StrParam was lost in favor of the completely generic System.ComObject. This feels like a regression compared to the “old” behaviour.

What am I missing here?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:18 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
HardCode4Allcommented, Jun 20, 2019

Unfortunately no, as the COM DLLs in question are intellectual property, but I will try to create a DLL that behaves alike which I can then share publicly. This might take a while, so please give me some time…

0reactions
singhsarabcommented, Aug 5, 2019

I am glad that you are unblocked, but it’s unfortunate that we were not able to resolve the issue for you. I am going ahead and closing this issue for now. Please share a project if you’d still like to pursue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Assert.IsInstanceOfType fails even though it says both ...
My guess (and I stress it is just a guess) is that the test assembly and the assembly under test either reference different...
Read more >
Assert.IsInstanceOfType Method (Object, Type, String)
Verifies that the specified object is an instance of the specified type. The assertion fails if the type is not found in the...
Read more >
IsInstanceOfType fails for some base classes if it is used in ...
If the IsInstanceOfType operator is used in the projection of an XPQuery<> the result is not reliable. Firstly I thought is was related...
Read more >
The Assert.IsInstanceOfType Headache - Developer Aspirin
GetType() method returns System.RuntimeType instead of the type of the object. target itself is a specific base class and the instance is ...
Read more >
Tips - Fluent Assertions
now fails on empty collection; actual.Should().OnlyContain(x => x. ... Expected collection to contain only items matching (x. ... IsInstanceOfType failed.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found