This repository has been archived by the owner on Aug 30, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feature/test-refactoring: Wrap async in !net40 regions Adjusted namespace and removed the RavenClient prefix of the RavenClient test classes Moved RavenClient tests into a RavenClientTests folder Added CaptureException tests Tidied up async tests Added Capture tests Added CaptureAsync() tests Merge tags in Capture(SentryEvent) Fixed InvokesSendAndJsonPacketFactoryOnCreate async test Set LastPacket in async as well Add CaptureMessageAsync tests Rename RavenClientTests to RavenClientTester
- Loading branch information
Showing
9 changed files
with
920 additions
and
97 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
148 changes: 148 additions & 0 deletions
148
src/tests/SharpRaven.UnitTests/RavenClientTests/CaptureAsyncTests.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,148 @@ | ||
#region License | ||
|
||
// Copyright (c) 2014 The Sentry Team and individual contributors. | ||
// All rights reserved. | ||
// | ||
// Redistribution and use in source and binary forms, with or without modification, are permitted | ||
// provided that the following conditions are met: | ||
// | ||
// 1. Redistributions of source code must retain the above copyright notice, this list of | ||
// conditions and the following disclaimer. | ||
// | ||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of | ||
// conditions and the following disclaimer in the documentation and/or other materials | ||
// provided with the distribution. | ||
// | ||
// 3. Neither the name of the Sentry nor the names of its contributors may be used to | ||
// endorse or promote products derived from this software without specific prior written | ||
// permission. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR | ||
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR | ||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
#endregion | ||
|
||
#if (!net40) | ||
|
||
using System; | ||
using System.Threading.Tasks; | ||
|
||
using NUnit.Framework; | ||
|
||
using SharpRaven.Data; | ||
|
||
namespace SharpRaven.UnitTests.RavenClientTests | ||
{ | ||
[TestFixture] | ||
public class CaptureAsyncTests | ||
{ | ||
#region SetUp/Teardown | ||
|
||
[SetUp] | ||
public void SetUp() | ||
{ | ||
this.tester = new RavenClientTester(); | ||
} | ||
|
||
#endregion | ||
|
||
[Test] | ||
public void ClientEnvironmentIsIgnored() | ||
{ | ||
this.tester.ClientEnvironmentIsIgnored(client => client.CaptureAsync(new SentryEvent("Test"))); | ||
} | ||
|
||
|
||
[Test] | ||
public void ClientLoggerIsIgnored() | ||
{ | ||
this.tester.ClientLoggerIsIgnored(async client => await client.CaptureAsync(new SentryEvent("Test"))); | ||
} | ||
|
||
|
||
[Test] | ||
public void ClientReleaseIsIgnored() | ||
{ | ||
this.tester.ClientReleaseIsIgnored(async client => await client.CaptureAsync(new SentryEvent("Test"))); | ||
} | ||
|
||
|
||
[Test] | ||
public async Task InvokesSendAndJsonPacketFactoryOnCreate() | ||
{ | ||
var project = Guid.NewGuid().ToString(); | ||
var client = this.tester.GetTestableRavenClient(project); | ||
var result = await client.CaptureAsync(new SentryEvent("Test")); | ||
|
||
Assert.That(result, Is.EqualTo(project)); | ||
} | ||
|
||
|
||
[Test] | ||
public void OnlyDefaultTags() | ||
{ | ||
this.tester.OnlyDefaultTags(async client => await client.CaptureAsync(new SentryEvent("Test"))); | ||
} | ||
|
||
|
||
[Test] | ||
public void OnlyMessageTags() | ||
{ | ||
this.tester.OnlyMessageTags(async (client, tags) => await client.CaptureAsync(new SentryEvent("Test") | ||
{ | ||
Level = ErrorLevel.Info, | ||
Tags = tags | ||
})); | ||
} | ||
|
||
|
||
[Test] | ||
public void ScrubberIsInvoked() | ||
{ | ||
this.tester.ScrubberIsInvoked(async (client, message) => await client.CaptureAsync(new SentryEvent(message))); | ||
} | ||
|
||
|
||
[Test] | ||
public void SendsEnvironment() | ||
{ | ||
this.tester.SendsEnvironment(async client => await client.CaptureAsync(new SentryEvent("Test"))); | ||
} | ||
|
||
|
||
[Test] | ||
public void SendsLogger() | ||
{ | ||
this.tester.SendsLogger(async client => await client.CaptureAsync(new SentryEvent("Test"))); | ||
} | ||
|
||
|
||
[Test] | ||
public void SendsRelease() | ||
{ | ||
this.tester.SendsRelease(async client => await client.CaptureAsync(new SentryEvent("Test"))); | ||
} | ||
|
||
|
||
[Test] | ||
public void TagHandling() | ||
{ | ||
this.tester.TagHandling(async (client, tags) => await client.CaptureAsync(new SentryEvent("Test") | ||
{ | ||
Level = ErrorLevel.Info, | ||
Tags = tags | ||
})); | ||
} | ||
|
||
|
||
private RavenClientTester tester; | ||
} | ||
} | ||
|
||
#endif |
142 changes: 142 additions & 0 deletions
142
src/tests/SharpRaven.UnitTests/RavenClientTests/CaptureExceptionAsyncTests.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,142 @@ | ||
#region License | ||
|
||
// Copyright (c) 2014 The Sentry Team and individual contributors. | ||
// All rights reserved. | ||
// | ||
// Redistribution and use in source and binary forms, with or without modification, are permitted | ||
// provided that the following conditions are met: | ||
// | ||
// 1. Redistributions of source code must retain the above copyright notice, this list of | ||
// conditions and the following disclaimer. | ||
// | ||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of | ||
// conditions and the following disclaimer in the documentation and/or other materials | ||
// provided with the distribution. | ||
// | ||
// 3. Neither the name of the Sentry nor the names of its contributors may be used to | ||
// endorse or promote products derived from this software without specific prior written | ||
// permission. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR | ||
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR | ||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
#endregion | ||
|
||
#if (!net40) | ||
|
||
using System; | ||
using System.Threading.Tasks; | ||
|
||
using NUnit.Framework; | ||
|
||
using SharpRaven.Data; | ||
|
||
namespace SharpRaven.UnitTests.RavenClientTests | ||
{ | ||
[TestFixture] | ||
public class CaptureExceptionAsyncTests | ||
{ | ||
#region SetUp/Teardown | ||
|
||
[SetUp] | ||
public void SetUp() | ||
{ | ||
this.tester = new RavenClientTester(); | ||
} | ||
|
||
#endregion | ||
|
||
[Test] | ||
public void ClientEnvironmentIsIgnored() | ||
{ | ||
this.tester.ClientEnvironmentIsIgnored(async client => await client.CaptureExceptionAsync(new Exception("Test"))); | ||
} | ||
|
||
|
||
[Test] | ||
public void ClientLoggerIsIgnored() | ||
{ | ||
this.tester.ClientLoggerIsIgnored(async client => await client.CaptureExceptionAsync(new Exception("Test"))); | ||
} | ||
|
||
|
||
[Test] | ||
public void ClientReleaseIsIgnored() | ||
{ | ||
this.tester.ClientReleaseIsIgnored(async client => await client.CaptureExceptionAsync(new Exception("Test"))); | ||
} | ||
|
||
|
||
[Test] | ||
public async Task InvokesSendAndJsonPacketFactoryOnCreate() | ||
{ | ||
var project = Guid.NewGuid().ToString(); | ||
var client = this.tester.GetTestableRavenClient(project); | ||
var result = await client.CaptureExceptionAsync(new Exception("Test")); | ||
|
||
Assert.That(result, Is.EqualTo(project)); | ||
} | ||
|
||
|
||
[Test] | ||
public void OnlyDefaultTags() | ||
{ | ||
this.tester.OnlyDefaultTags(async client => await client.CaptureExceptionAsync(new Exception("Test"))); | ||
} | ||
|
||
|
||
[Test] | ||
public void OnlyMessageTags() | ||
{ | ||
this.tester.OnlyMessageTags( | ||
async (client, tags) => await client.CaptureExceptionAsync(new Exception("Test"), level : ErrorLevel.Info, tags : tags)); | ||
} | ||
|
||
|
||
[Test] | ||
public void ScrubberIsInvoked() | ||
{ | ||
this.tester.ScrubberIsInvoked(async (client, message) => await client.CaptureExceptionAsync(new Exception(message))); | ||
} | ||
|
||
|
||
[Test] | ||
public void SendsEnvironment() | ||
{ | ||
this.tester.SendsEnvironment(async client => await client.CaptureExceptionAsync(new Exception("Test"))); | ||
} | ||
|
||
|
||
[Test] | ||
public void SendsLogger() | ||
{ | ||
this.tester.SendsLogger(async client => await client.CaptureExceptionAsync(new Exception("Test"))); | ||
} | ||
|
||
|
||
[Test] | ||
public void SendsRelease() | ||
{ | ||
this.tester.SendsRelease(async client => await client.CaptureExceptionAsync(new Exception("Test"))); | ||
} | ||
|
||
|
||
[Test] | ||
public void TagHandling() | ||
{ | ||
this.tester.TagHandling( | ||
async (client, tags) => await client.CaptureExceptionAsync(new Exception("Test"), level : ErrorLevel.Info, tags : tags)); | ||
} | ||
|
||
|
||
private RavenClientTester tester; | ||
} | ||
} | ||
|
||
#endif |
Oops, something went wrong.