-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #172 from MindscapeHQ/Xamarin.Mac
Xamarin.mac
- Loading branch information
Showing
24 changed files
with
1,537 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
Mindscape.Raygun4Net.Xamarin.Mac.Tests/Mindscape.Raygun4Net.Xamarin.Mac.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{5DB13CB2-BF32-4ADD-98B0-F863478C29BE}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<RootNamespace>Mindscape.Raygun4Net.Xamarin.Mac.Tests</RootNamespace> | ||
<AssemblyName>Mindscape.Raygun4Net.Xamarin.Mac.Tests</AssemblyName> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug</OutputPath> | ||
<DefineConstants>DEBUG;</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<ConsolePause>false</ConsolePause> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>full</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release</OutputPath> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<ConsolePause>false</ConsolePause> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="nunit.framework" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="RaygunErrorMessageTests.cs" /> | ||
<Compile Include="Model\FakeRaygunErrorMessage.cs" /> | ||
<Compile Include="Model\FakeRaygunClient.cs" /> | ||
<Compile Include="RaygunClientTests.cs" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> | ||
<ItemGroup> | ||
<Folder Include="Model\" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\Mindscape.Raygun4Net.Xamarin.Mac\Mindscape.Raygun4Net.Xamarin.Mac.csproj"> | ||
<Project>{B78E58F3-853F-4991-BFF6-5AECE0C04B91}</Project> | ||
<Name>Mindscape.Raygun4Net.Xamarin.Mac</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
</Project> |
32 changes: 32 additions & 0 deletions
32
Mindscape.Raygun4Net.Xamarin.Mac.Tests/Model/FakeRaygunClient.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
using System.Collections.Generic; | ||
using System.Collections; | ||
using Mindscape.Raygun4Net.Messages; | ||
|
||
namespace Mindscape.Raygun4Net.Xamarin.Mac.Tests | ||
{ | ||
public class FakeRaygunClient : RaygunClient | ||
{ | ||
public FakeRaygunClient() | ||
:this("tempkey") | ||
{ | ||
} | ||
|
||
public FakeRaygunClient(string apiKey) | ||
: base(apiKey) | ||
{ | ||
} | ||
|
||
public RaygunMessage ExposeBuildMessage(Exception exception, [Optional] IList<string> tags, [Optional] IDictionary userCustomData) | ||
{ | ||
return BuildMessage(exception, tags, userCustomData); | ||
} | ||
|
||
public bool ExposeOnSendingMessage(RaygunMessage raygunMessage) | ||
{ | ||
return OnSendingMessage(raygunMessage); | ||
} | ||
} | ||
} | ||
|
14 changes: 14 additions & 0 deletions
14
Mindscape.Raygun4Net.Xamarin.Mac.Tests/Model/FakeRaygunErrorMessage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
using Mindscape.Raygun4Net.Messages; | ||
|
||
namespace Mindscape.Raygun4Net.Xamarin.Mac.Tests | ||
{ | ||
public class FakeRaygunErrorMessage : RaygunErrorMessage | ||
{ | ||
public RaygunErrorStackTraceLineMessage[] ExposeParseStackTrace(string stackTrace) | ||
{ | ||
return ParseStackTrace(stackTrace); | ||
} | ||
} | ||
} | ||
|
131 changes: 131 additions & 0 deletions
131
Mindscape.Raygun4Net.Xamarin.Mac.Tests/RaygunClientTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
using System; | ||
using NUnit.Framework; | ||
using Mindscape.Raygun4Net.Messages; | ||
|
||
namespace Mindscape.Raygun4Net.Xamarin.Mac.Tests | ||
{ | ||
[TestFixture] | ||
public class RaygunClientTests | ||
{ | ||
private FakeRaygunClient _client; | ||
private Exception _exception = new NullReferenceException("The thing is null"); | ||
|
||
[SetUp] | ||
public void SetUp() | ||
{ | ||
_client = new FakeRaygunClient(); | ||
} | ||
|
||
// Cancel send tests | ||
|
||
[Test] | ||
public void NoHandlerSendsAll() | ||
{ | ||
Assert.IsTrue(_client.ExposeOnSendingMessage(_client.ExposeBuildMessage(_exception))); | ||
} | ||
|
||
[Test] | ||
public void HandlerIsChecked() | ||
{ | ||
bool filterCalled = false; | ||
_client.SendingMessage += (object o, RaygunSendingMessageEventArgs e) => | ||
{ | ||
Assert.AreEqual("NullReferenceException: The thing is null", e.Message.Details.Error.Message); | ||
filterCalled = true; | ||
e.Cancel = true; | ||
}; | ||
Assert.IsFalse(_client.ExposeOnSendingMessage(_client.ExposeBuildMessage(_exception))); | ||
Assert.IsTrue(filterCalled); | ||
} | ||
|
||
[Test] | ||
public void HandlerCanAllowSend() | ||
{ | ||
_client.SendingMessage += (object o, RaygunSendingMessageEventArgs e) => | ||
{ | ||
// Allow send by not setting e.Cancel | ||
}; | ||
Assert.IsTrue(_client.ExposeOnSendingMessage(_client.ExposeBuildMessage(_exception))); | ||
} | ||
|
||
[Test] | ||
public void AllHandlersAreChecked() | ||
{ | ||
bool filter1Called = false; | ||
bool filter2Called = false; | ||
_client.SendingMessage += (object o, RaygunSendingMessageEventArgs e) => | ||
{ | ||
Assert.AreEqual("NullReferenceException: The thing is null", e.Message.Details.Error.Message); | ||
filter1Called = true; | ||
e.Cancel = true; | ||
}; | ||
_client.SendingMessage += (object o, RaygunSendingMessageEventArgs e) => | ||
{ | ||
Assert.AreEqual("NullReferenceException: The thing is null", e.Message.Details.Error.Message); | ||
filter2Called = true; | ||
e.Cancel = true; | ||
}; | ||
Assert.IsFalse(_client.ExposeOnSendingMessage(_client.ExposeBuildMessage(_exception))); | ||
Assert.IsTrue(filter1Called); | ||
Assert.IsTrue(filter2Called); | ||
} | ||
|
||
[Test] | ||
public void DontSendIfFirstHandlerCancels() | ||
{ | ||
_client.SendingMessage += (object o, RaygunSendingMessageEventArgs e) => | ||
{ | ||
e.Cancel = true; | ||
}; | ||
_client.SendingMessage += (object o, RaygunSendingMessageEventArgs e) => | ||
{ | ||
// Allow send by not setting e.Cancel | ||
}; | ||
Assert.IsFalse(_client.ExposeOnSendingMessage(_client.ExposeBuildMessage(_exception))); | ||
} | ||
|
||
[Test] | ||
public void DontSendIfSecondHandlerCancels() | ||
{ | ||
_client.SendingMessage += (object o, RaygunSendingMessageEventArgs e) => | ||
{ | ||
// Allow send by not setting e.Cancel | ||
}; | ||
_client.SendingMessage += (object o, RaygunSendingMessageEventArgs e) => | ||
{ | ||
e.Cancel = true; | ||
}; | ||
Assert.IsFalse(_client.ExposeOnSendingMessage(_client.ExposeBuildMessage(_exception))); | ||
} | ||
|
||
[Test] | ||
public void AllowSendIfNoHandlerCancels() | ||
{ | ||
_client.SendingMessage += (object o, RaygunSendingMessageEventArgs e) => | ||
{ | ||
// Allow send by not setting e.Cancel | ||
}; | ||
_client.SendingMessage += (object o, RaygunSendingMessageEventArgs e) => | ||
{ | ||
// Allow send by not setting e.Cancel | ||
}; | ||
Assert.IsTrue(_client.ExposeOnSendingMessage(_client.ExposeBuildMessage(_exception))); | ||
} | ||
|
||
[Test] | ||
public void HandlerCanModifyMessage() | ||
{ | ||
RaygunMessage message = _client.ExposeBuildMessage(_exception); | ||
Assert.AreEqual("NullReferenceException: The thing is null", message.Details.Error.Message); | ||
|
||
_client.SendingMessage += (object o, RaygunSendingMessageEventArgs e) => | ||
{ | ||
e.Message.Details.Error.Message = "Custom error message"; | ||
}; | ||
|
||
Assert.IsTrue(_client.ExposeOnSendingMessage(message)); | ||
Assert.AreEqual("Custom error message", message.Details.Error.Message); | ||
} | ||
} | ||
} | ||
|
118 changes: 118 additions & 0 deletions
118
Mindscape.Raygun4Net.Xamarin.Mac.Tests/RaygunErrorMessageTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
using NUnit.Framework; | ||
using System; | ||
using Mindscape.Raygun4Net.Messages; | ||
|
||
namespace Mindscape.Raygun4Net.Xamarin.Mac.Tests | ||
{ | ||
[TestFixture()] | ||
public class Test | ||
{ | ||
private FakeRaygunErrorMessage _raygunErrorMessage; | ||
|
||
[SetUp()] | ||
public void SetUp() | ||
{ | ||
_raygunErrorMessage = new FakeRaygunErrorMessage (); | ||
} | ||
|
||
[Test()] | ||
public void ParseStackTrace() | ||
{ | ||
string stackTrace = "at Xamarin_Mac_ErrorHarness.MainWindowController.<AwakeFromNib>m__0 (object,System.EventArgs) [0x00006] in /Xamarin_Mac_ErrorHarness/MainWindowController.cs:44\n" + | ||
"at MonoMac.AppKit.ActionDispatcher.OnActivated (MonoMac.Foundation.NSObject) [0x00015] in /source/xamcore/src/AppKit/ActionDispatcher.cs:49\n" + | ||
"at MonoMac.AppKit.NSApplication.Main (string[]) [0x00041] in /source/xamcore/src/AppKit/NSApplication.cs:105\n" + | ||
"at Xamarin_Mac_ErrorHarness.MainClass.Main (string[]) [0x00011] in /Xamarin_Mac_ErrorHarness/Main.cs:17"; | ||
|
||
RaygunErrorStackTraceLineMessage[] result = _raygunErrorMessage.ExposeParseStackTrace (stackTrace); | ||
|
||
Assert.AreEqual(4, result.Length); | ||
|
||
// Note that the leading "at" gets stripped. | ||
// The memory address gets stripped in this scenario, might want to add this back in somewhere. | ||
// Also, the space between the method name and opening parenthesis is removed. | ||
Assert.AreEqual ("Xamarin_Mac_ErrorHarness.MainWindowController", result [0].ClassName); | ||
Assert.AreEqual ("/Xamarin_Mac_ErrorHarness/MainWindowController.cs", result [0].FileName); | ||
Assert.AreEqual ("<AwakeFromNib>m__0(object,System.EventArgs)", result [0].MethodName); | ||
Assert.AreEqual (44, result [0].LineNumber); | ||
|
||
Assert.AreEqual ("MonoMac.AppKit.ActionDispatcher", result [1].ClassName); | ||
Assert.AreEqual ("/source/xamcore/src/AppKit/ActionDispatcher.cs", result [1].FileName); | ||
Assert.AreEqual ("OnActivated(MonoMac.Foundation.NSObject)", result [1].MethodName); | ||
Assert.AreEqual (49, result [1].LineNumber); | ||
|
||
Assert.AreEqual ("MonoMac.AppKit.NSApplication", result [2].ClassName); | ||
Assert.AreEqual ("/source/xamcore/src/AppKit/NSApplication.cs", result [2].FileName); | ||
Assert.AreEqual ("Main(string[])", result [2].MethodName); | ||
Assert.AreEqual (105, result [2].LineNumber); | ||
|
||
Assert.AreEqual ("Xamarin_Mac_ErrorHarness.MainClass", result [3].ClassName); | ||
Assert.AreEqual ("/Xamarin_Mac_ErrorHarness/Main.cs", result [3].FileName); | ||
Assert.AreEqual ("Main(string[])", result [3].MethodName); | ||
Assert.AreEqual (17, result [3].LineNumber); | ||
} | ||
|
||
[Test()] | ||
public void ParseStackTraceWithNoFileNameOrLineNumber() | ||
{ | ||
string stackTrace = "at Xamarin_Mac_ErrorHarness.MainWindowController.<AwakeFromNib>m__0 (object,System.EventArgs) <0x00037>\n" + | ||
"at MonoMac.AppKit.ActionDispatcher.OnActivated (MonoMac.Foundation.NSObject) <0x00021>\n" + | ||
"at MonoMac.AppKit.NSApplication.Main (string[]) <0x00097>\n" + | ||
"at Xamarin_Mac_ErrorHarness.MainClass.Main (string[]) <0x00027>"; | ||
|
||
RaygunErrorStackTraceLineMessage[] result = _raygunErrorMessage.ExposeParseStackTrace (stackTrace); | ||
|
||
Assert.AreEqual(4, result.Length); | ||
|
||
// Note that the leading "at" gets stripped, and the memory address gets dumped in the FileName property so that it doesn't affect the exception-grouping. | ||
// Also, the space between the method name and opening parenthesis is removed. | ||
Assert.AreEqual ("Xamarin_Mac_ErrorHarness.MainWindowController", result [0].ClassName); | ||
Assert.AreEqual ("<0x00037>", result [0].FileName); | ||
Assert.AreEqual ("<AwakeFromNib>m__0(object,System.EventArgs)", result [0].MethodName); | ||
Assert.AreEqual (0, result [0].LineNumber); | ||
|
||
Assert.AreEqual ("MonoMac.AppKit.ActionDispatcher", result [1].ClassName); | ||
Assert.AreEqual ("<0x00021>", result [1].FileName); | ||
Assert.AreEqual ("OnActivated(MonoMac.Foundation.NSObject)", result [1].MethodName); | ||
Assert.AreEqual (0, result [1].LineNumber); | ||
|
||
Assert.AreEqual ("MonoMac.AppKit.NSApplication", result [2].ClassName); | ||
Assert.AreEqual ("<0x00097>", result [2].FileName); | ||
Assert.AreEqual ("Main(string[])", result [2].MethodName); | ||
Assert.AreEqual (0, result [2].LineNumber); | ||
|
||
Assert.AreEqual ("Xamarin_Mac_ErrorHarness.MainClass", result [3].ClassName); | ||
Assert.AreEqual ("<0x00027>", result [3].FileName); | ||
Assert.AreEqual ("Main(string[])", result [3].MethodName); | ||
Assert.AreEqual (0, result [3].LineNumber); | ||
} | ||
|
||
[Test()] | ||
public void ParseStackTraceWithWrapperMessages() | ||
{ | ||
string stackTrace = "at (wrapper dynamic-method) object.[MonoMac.AppKit.ActionDispatcher.Void OnActivated(MonoMac.Foundation.NSObject)] (MonoMac.Foundation.NSObject,MonoMac.ObjCRuntime.Selector,MonoMac.Foundation.NSObject) <0x00033>\n" + | ||
"at (wrapper native-to-managed) object.[MonoMac.AppKit.ActionDispatcher.Void OnActivated(MonoMac.Foundation.NSObject)] (MonoMac.Foundation.NSObject,MonoMac.ObjCRuntime.Selector,MonoMac.Foundation.NSObject) <0x000db>\n" + | ||
"at (wrapper managed-to-native) MonoMac.AppKit.NSApplication.NSApplicationMain (int,string[]) <0x00012>"; | ||
|
||
RaygunErrorStackTraceLineMessage[] result = _raygunErrorMessage.ExposeParseStackTrace (stackTrace); | ||
|
||
Assert.AreEqual (3, result.Length); | ||
|
||
// Note that the leading "at" gets stripped | ||
Assert.IsNull (result [0].ClassName); | ||
Assert.AreEqual ("(wrapper dynamic-method) object.[MonoMac.AppKit.ActionDispatcher.Void OnActivated(MonoMac.Foundation.NSObject)] (MonoMac.Foundation.NSObject,MonoMac.ObjCRuntime.Selector,MonoMac.Foundation.NSObject) <0x00033>", result [0].FileName); | ||
Assert.IsNull (result [0].MethodName); | ||
Assert.AreEqual (0, result [0].LineNumber); | ||
|
||
Assert.IsNull (result [1].ClassName); | ||
Assert.AreEqual ("(wrapper native-to-managed) object.[MonoMac.AppKit.ActionDispatcher.Void OnActivated(MonoMac.Foundation.NSObject)] (MonoMac.Foundation.NSObject,MonoMac.ObjCRuntime.Selector,MonoMac.Foundation.NSObject) <0x000db>", result [1].FileName); | ||
Assert.IsNull (result [1].MethodName); | ||
Assert.AreEqual (0, result [1].LineNumber); | ||
|
||
Assert.IsNull (result [2].ClassName); | ||
Assert.AreEqual ("(wrapper managed-to-native) MonoMac.AppKit.NSApplication.NSApplicationMain (int,string[]) <0x00012>", result [2].FileName); | ||
Assert.IsNull (result [2].MethodName); | ||
Assert.AreEqual (0, result [2].LineNumber); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 2012 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mindscape.Raygun4Net.Xamarin.Mac", "Mindscape.Raygun4Net.Xamarin.Mac\Mindscape.Raygun4Net.Xamarin.Mac.csproj", "{B78E58F3-853F-4991-BFF6-5AECE0C04B91}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mindscape.Raygun4Net.Xamarin.Mac.Tests", "Mindscape.Raygun4Net.Xamarin.Mac.Tests\Mindscape.Raygun4Net.Xamarin.Mac.Tests.csproj", "{5DB13CB2-BF32-4ADD-98B0-F863478C29BE}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{5DB13CB2-BF32-4ADD-98B0-F863478C29BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{5DB13CB2-BF32-4ADD-98B0-F863478C29BE}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{5DB13CB2-BF32-4ADD-98B0-F863478C29BE}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{5DB13CB2-BF32-4ADD-98B0-F863478C29BE}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{B78E58F3-853F-4991-BFF6-5AECE0C04B91}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{B78E58F3-853F-4991-BFF6-5AECE0C04B91}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{B78E58F3-853F-4991-BFF6-5AECE0C04B91}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{B78E58F3-853F-4991-BFF6-5AECE0C04B91}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(MonoDevelopProperties) = preSolution | ||
StartupItem = Mindscape.Raygun4Net.Xamarin.Mac\Mindscape.Raygun4Net.Xamarin.Mac.csproj | ||
EndGlobalSection | ||
EndGlobal |
Oops, something went wrong.