IsType and IsType(object, object) throwing IsTypeException

后端 未结 1 792
星月不相逢
星月不相逢 2021-02-13 15:18

I am attempting to assert that an object being returned by a method call is of the type List, so using xUnit I have tried the following:



        
相关标签:
1条回答
  • 2021-02-13 16:01

    The first argument for Assert.IsType should be the object itself not its type, the following should not throw:

    var expected = typeof(List<MyClass>);
    var actual = Method();
    
    Assert.IsType<List<MyClass>>(actual);
    Assert.IsType(expected, actual);
    
    0 讨论(0)
提交回复
热议问题