コード例 #1
0
        public void GetStringRepresentation_ThrowsFormatException_OnClassNestedInItself()
        {
            var example = new CircularReferenceExampleClass();

            example.otherObject = example;
            Action action = () => example.PrintToString();

            action.Should().Throw <FormatException>();
        }
コード例 #2
0
        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>();
        }