-
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 #377 from MindscapeHQ/xray-1359-netcore2-provider
XRAY-1359 Raygun4Net .NetCore2/.NetStandard2 Support
- Loading branch information
Showing
41 changed files
with
4,499 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
Mindscape.Raygun4Net.NetCore.Tests/Mindscape.Raygun4Net.NetCore.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,18 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>netcoreapp2.0</TargetFramework> | ||
<IsPackable>false</IsPackable> | ||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="nunit" Version="3.10.1" /> | ||
<PackageReference Include="NUnit3TestAdapter" Version="3.10.0" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.6.1" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\Mindscape.Raygun4Net.NetCore\Mindscape.Raygun4Net.NetCore.csproj" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Remove="Model\FakeRaygunRequestMessageBuilder.cs" /> | ||
</ItemGroup> | ||
</Project> |
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,44 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace Mindscape.Raygun4Net.NetCore.Tests | ||
{ | ||
public class CyclicObject | ||
{ | ||
private CyclicObject _child; | ||
private CyclicObject[] _array = new CyclicObject[1]; | ||
private readonly IDictionary _dictionary = new Dictionary<object, object>(); | ||
private readonly IDictionary<string, object> _genericDictionary = new Dictionary<string, object>(); | ||
|
||
public CyclicObject Child | ||
{ | ||
get { return _child; } | ||
set | ||
{ | ||
_child = value; | ||
} | ||
} | ||
|
||
public CyclicObject[] Array | ||
{ | ||
get { return _array; } | ||
set | ||
{ | ||
_array = value; | ||
} | ||
} | ||
|
||
public IDictionary Dictionary | ||
{ | ||
get { return _dictionary; } | ||
} | ||
|
||
public IDictionary<string, object> GenericDictionary | ||
{ | ||
get { return _genericDictionary; } | ||
} | ||
} | ||
} |
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 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace Mindscape.Raygun4Net.NetCore.Tests | ||
{ | ||
public class FakeException : Exception | ||
{ | ||
private IDictionary _data; | ||
|
||
public FakeException(IDictionary data) | ||
{ | ||
_data = data; | ||
} | ||
|
||
public override System.Collections.IDictionary Data | ||
{ | ||
get | ||
{ | ||
return _data; | ||
} | ||
} | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
Mindscape.Raygun4Net.NetCore.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,59 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using NUnit.Framework.Internal; | ||
|
||
namespace Mindscape.Raygun4Net.NetCore.Tests | ||
{ | ||
public class FakeRaygunClient : RaygunClient | ||
{ | ||
public FakeRaygunClient() | ||
: base(string.Empty) | ||
{ | ||
|
||
} | ||
public FakeRaygunClient(string apiKey) | ||
: base(apiKey) | ||
{ | ||
} | ||
|
||
public RaygunMessage ExposeBuildMessage(Exception exception, [Optional] IList<string> tags, [Optional] IDictionary userCustomData) | ||
{ | ||
var task = BuildMessage(exception, tags, userCustomData); | ||
|
||
task.Wait(); | ||
|
||
return task.Result; | ||
} | ||
|
||
public bool ExposeValidateApiKey() | ||
{ | ||
return ValidateApiKey(); | ||
} | ||
|
||
public bool ExposeOnSendingMessage(RaygunMessage raygunMessage) | ||
{ | ||
return OnSendingMessage(raygunMessage); | ||
} | ||
|
||
public bool ExposeCanSend(Exception exception) | ||
{ | ||
return CanSend(exception); | ||
} | ||
|
||
public void ExposeFlagAsSent(Exception exception) | ||
{ | ||
FlagAsSent(exception); | ||
} | ||
|
||
public IEnumerable<Exception> ExposeStripWrapperExceptions(Exception exception) | ||
{ | ||
return StripWrapperExceptions(exception); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Mindscape.Raygun4Net.NetCore.Tests/Model/GenericException.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,11 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace Mindscape.Raygun4Net.NetCore.Tests | ||
{ | ||
public class GenericException<T> : Exception | ||
{ | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
Mindscape.Raygun4Net.NetCore.Tests/Model/WrapperException.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,15 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace Mindscape.Raygun4Net.NetCore.Tests | ||
{ | ||
public class WrapperException : Exception | ||
{ | ||
public WrapperException(Exception innerException) | ||
: base("Something went wrong", innerException) | ||
{ | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
Mindscape.Raygun4Net.NetCore.Tests/Properties/AssemblyInfo.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,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("Raygun4Net.NetCore.Tests")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("Raygun")] | ||
[assembly: AssemblyProduct("Raygun4Net")] | ||
[assembly: AssemblyCopyright("Copyright © Raygun 2012-2018")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("9db58be3-04f8-4afd-a97b-dc3ff962c544")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
61 changes: 61 additions & 0 deletions
61
Mindscape.Raygun4Net.NetCore.Tests/RaygunClientBaseTests.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,61 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using NUnit.Framework; | ||
|
||
namespace Mindscape.Raygun4Net.NetCore.Tests | ||
{ | ||
[TestFixture] | ||
public class RaygunClientBaseTests | ||
{ | ||
private FakeRaygunClient _client = new FakeRaygunClient(); | ||
|
||
[Test] | ||
public void FlagAsSentDoesNotCrash_DataDoesNotSupportStringKeys() | ||
{ | ||
Assert.That(() => _client.ExposeFlagAsSent(new FakeException(new Dictionary<int, object>())), Throws.Nothing); | ||
} | ||
|
||
[Test] | ||
public void FlagAsSentDoesNotCrash_NullData() | ||
{ | ||
Assert.That(() => _client.ExposeFlagAsSent(new FakeException(null)), Throws.Nothing); | ||
} | ||
|
||
[Test] | ||
public void CanSendIfDataIsNull() | ||
{ | ||
Assert.IsTrue(_client.ExposeCanSend(new FakeException(null))); | ||
} | ||
|
||
[Test] | ||
public void CannotSendSentException_StringDictionary() | ||
{ | ||
Exception exception = new FakeException(new Dictionary<string, object>()); | ||
_client.ExposeFlagAsSent(exception); | ||
Assert.IsFalse(_client.ExposeCanSend(exception)); | ||
} | ||
|
||
[Test] | ||
public void CannotSendSentException_ObjectDictionary() | ||
{ | ||
Exception exception = new FakeException(new Dictionary<object, object>()); | ||
_client.ExposeFlagAsSent(exception); | ||
Assert.IsFalse(_client.ExposeCanSend(exception)); | ||
} | ||
|
||
[Test] | ||
public void ExceptionInsideSendingMessageHAndlerDoesNotCrash() | ||
{ | ||
FakeRaygunClient client = new FakeRaygunClient(); | ||
client.SendingMessage += (sender, args) => | ||
{ | ||
throw new Exception("Oops..."); | ||
}; | ||
|
||
Assert.That(() => client.ExposeOnSendingMessage(new RaygunMessage()), Throws.Nothing); | ||
Assert.IsTrue(client.ExposeOnSendingMessage(new RaygunMessage())); | ||
} | ||
} | ||
} |
Oops, something went wrong.