how to get coverage for object ICloneable.Clone()
method while writing test cases.
#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
The current coverage looks like
.
CodePudding user response:
While these can be separate cases, here is a really simplified example of testing/covering the shown code.
//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);