public void GetStringRepresentation_ThrowsFormatException_OnClassNestedInItself() { var example = new CircularReferenceExampleClass(); example.otherObject = example; Action action = () => example.PrintToString(); action.Should().Throw <FormatException>(); }
public void GetStringRepresentation_ThrowsFormatException_OnCircularReference() { var firstObject = new CircularReferenceExampleClass(); var secondObject = new CircularReferenceExampleClass(); firstObject.otherObject = secondObject; secondObject.otherObject = firstObject; Action action = () => firstObject.PrintToString(); action.Should().Throw <FormatException>(); }