IsType and IsType(object, object) throwing IsTypeException

后端 未结 1 789
星月不相逢
星月不相逢 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);
    var actual = Method();
    
    Assert.IsType>(actual);
    Assert.IsType(expected, actual);
    

    0 讨论(0)
提交回复
热议问题