Return T from Assert.IsInstanceOfType<T>()
See original GitHub issueThis PR introduced the generic version of the Assert.IsInstanceOfType<T>()
. It will be much more useful to return the T
from the method, so the two lines of code
Assert.IsInstanceOfType<MyType>(obj);
var myTypeObj = (MyType)obj;
can be replaced with a single line
var myTypeObj = Assert.IsInstanceOfType<MyType>(obj);
Issue Analytics
- State:
- Created 8 months ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
Why does Assert.IsInstanceOfType(0.GetType(), typeof(int)) ...
I'm kind of new to unit testing, using Microsoft.VisualStudio.TestTools.UnitTesting ;. The 0.GetType() is actually System.RuntimeType , so what ...
Read more >Assert.IsInstanceOfType Method
Tests whether the specified object is an instance of the expected type and throws an exception if the expected type is not in...
Read more >Add Assert.IsType<T>(object obj) · Issue #413
xUnit has a nice Assert method: public static T IsType<T>(object @object) that is lacking from MS Test. MS Test has an "old" method:...
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 >Assert.IsInstanceOf
IsInstanceOf succeeds if the object provided as an actual value is an instance of the expected type. Assert.IsInstanceOf(Type expected, object actual); Assert.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Removing
UwpMinimum
andWinUiMinimum
helped. Thanks! For some reason, VS didn’t recognize the dotnet 8 sdk installed by theBuild.cmd
and I had to install it from here. But now I can build the code.Sure. Will do it by the end of the week.