|
| 1 | +#region License |
| 2 | + |
| 3 | +// Copyright (c) 2016 The Sentry Team and individual contributors. |
| 4 | +// All rights reserved. |
| 5 | +// |
| 6 | +// Redistribution and use in source and binary forms, with or without modification, are permitted |
| 7 | +// provided that the following conditions are met: |
| 8 | +// |
| 9 | +// 1. Redistributions of source code must retain the above copyright notice, this list of |
| 10 | +// conditions and the following disclaimer. |
| 11 | +// |
| 12 | +// 2. Redistributions in binary form must reproduce the above copyright notice, this list of |
| 13 | +// conditions and the following disclaimer in the documentation and/or other materials |
| 14 | +// provided with the distribution. |
| 15 | +// |
| 16 | +// 3. Neither the name of the Sentry nor the names of its contributors may be used to |
| 17 | +// endorse or promote products derived from this software without specific prior written |
| 18 | +// permission. |
| 19 | +// |
| 20 | +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR |
| 21 | +// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
| 22 | +// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR |
| 23 | +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 24 | +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 | +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 26 | +// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
| 27 | +// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | + |
| 29 | +#endregion |
| 30 | + |
| 31 | +using System; |
| 32 | +using System.Diagnostics; |
| 33 | +using System.Reflection; |
| 34 | + |
| 35 | +using NUnit.Framework; |
| 36 | + |
| 37 | +using SharpRaven.Data; |
| 38 | +using SharpRaven.UnitTests.Utilities; |
| 39 | + |
| 40 | +namespace SharpRaven.UnitTests.Data |
| 41 | +{ |
| 42 | + internal class StackFrameWithNullMethod: StackFrame |
| 43 | + { |
| 44 | + public override MethodBase GetMethod() |
| 45 | + { |
| 46 | + return null; |
| 47 | + } |
| 48 | + } |
| 49 | + |
| 50 | + [TestFixture] |
| 51 | + public class ExceptionFrameTests |
| 52 | + { |
| 53 | + [Test] |
| 54 | + public void Constructor_NullFrameMethod_DoesNotThrow() |
| 55 | + { |
| 56 | + // on some platforms (e.g. on mono), StackFrame.GetMethod() may return null |
| 57 | + // e.g. for this stack frame: |
| 58 | + // at (wrapper dynamic-method) System.Object:lambda_method (System.Runtime.CompilerServices.Closure,object,object)) |
| 59 | + |
| 60 | + var stackFrame = new StackFrameWithNullMethod(); |
| 61 | + var frame = new ExceptionFrame(stackFrame); |
| 62 | + |
| 63 | + Assert.AreEqual("(unknown)", frame.Module); |
| 64 | + Assert.AreEqual("(unknown)", frame.Function); |
| 65 | + Assert.AreEqual("(unknown)", frame.Source); |
| 66 | + } |
| 67 | + } |
| 68 | +} |
0 commit comments