如何在编写测试用例时获得object ICloneable.Clone()方法的覆盖率。
#region ICloneable Members
object ICloneable.Clone()
{
return this.Clone();
}
public new Blue Clone()
{
Blue _temp = (Blue)this.MemberwiseClone();
_temp.Node = Node.Clone();
return _temp;
}
#endregion当前的覆盖范围如下

。
发布于 2021-12-03 03:35:29
虽然这些可以是单独的情况,但下面是一个真正简化的测试/覆盖显示代码的示例。
//Arrange
Blue expected = new(); //populate as needed
//Act
Blue a = expected.Clone();
Blue b = (Blue)((ICloneable)expected).Clone();
//Assert - using FluentAsertions - cases should be self explanatory
a.Should().BeEquivalentTo(b);
a.Should().BeEquivalentTo(expected);
b.Should().BeEquivalentTo(expected);https://stackoverflow.com/questions/70208190
复制相似问题