【问题标题】:FluentAssertions Should().BeOfType() or derived type?FluentAssertions Should().BeOfType() 还是派生类型?
【发布时间】:2021-09-02 02:48:03
【问题描述】:

我有以下情况:

class A
{
}

class B : A
{
}

我想断言 typeof(B) 的变量可以分配给 typeof(A) 变量。如何使用流利的断言来做到这一点?

【问题讨论】:

    标签: fluent-assertions


    【解决方案1】:

    我认为您可以为此使用BeAssignableTo<T>

    var b = new B();
            
    b.Should().BeAssignableTo<A>();
    

    这几乎是你自己写的句子。 :)

    【讨论】:

      猜你喜欢
      • 2018-08-25
      • 2019-01-21
      • 2018-08-09
      • 2013-04-15
      • 2018-08-03
      • 1970-01-01
      • 2018-07-15
      • 2016-01-28
      • 1970-01-01
      相关资源
      最近更新 更多