forked from soygul/NBug
-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GitHub allows submitting issues by navigating a dedicated URL supplying issue data via query string parameters. More info: https://help.github.com/en/articles/about-automation-for-issues-and-pull-requests-with-query-parameters Whenever Git Extensions experiences an issue that is handled by NBug, a user is presented with an option to submit an issue to our GitHub repo. By clicking "Send and quit" button the following occurs: * an issue payload is generated, * the payload gets encoded into a url, and * the user is navigated to the generated url in a browser of their choice Relates to gitextensions/gitextensions#5064
- Loading branch information
Showing
19 changed files
with
505 additions
and
74 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,3 +107,4 @@ UpgradeLog*.XML | |
# NuGet | ||
packages/ | ||
.vs/ | ||
*.received.* |
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
This file was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
...wnBodyBuilderTests.Build_should_build_report_with_system_and_additional_info.approved.txt
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 @@ | ||
## Current behaviour | ||
|
||
``` | ||
System.ApplicationException: Failed ---> System.ArgumentOutOfRangeException: Opps ---> System.DivideByZeroException: Boom! | ||
--- End of inner exception stack trace --- | ||
--- End of inner exception stack trace --- | ||
at NBug.Tests.Unit.Util.Mock.Method1() in C:\Development\gitextensions\Externals\NBug\NBug.Tests\Unit\Util\Mock.cs:line 13 | ||
at NBug.Tests.Unit.Util.Mock.Method2() in C:\Development\gitextensions\Externals\NBug\NBug.Tests\Unit\Util\Mock.cs:line 16 | ||
at NBug.Tests.Unit.Util.Mock.Method3() in C:\Development\gitextensions\Externals\NBug\NBug.Tests\Unit\Util\Mock.cs:line 17 | ||
at NBug.Tests.Unit.Util.Mock.Method4() in C:\Development\gitextensions\Externals\NBug\NBug.Tests\Unit\Util\Mock.cs:line 18 | ||
at NBug.Tests.Unit.Util.Mock.DoWork() in C:\Development\gitextensions\Externals\NBug\NBug.Tests\Unit\Util\Mock.cs:line 7 | ||
at NBug.Tests.Unit.Util.ErrorReportMarkDownBodyBuilderTests.Build_should_build_report_with_system_and_additional_info() in C:\Development\gitextensions\Externals\NBug\NBug.Tests\Unit\Util\ErrorReportMarkDownBodyBuilderTests.cs:line 77 | ||
``` | ||
|
||
|
||
## Additional information | ||
|
||
It happened when I was arguing with someone on the Internet. | ||
I was right and they were absolutely wrong! | ||
I win! But the app crashed! | ||
PLEASE HELP!!! | ||
|
||
|
||
## Environment | ||
|
||
System information is not supplied |
25 changes: 25 additions & 0 deletions
25
...dyBuilderTests.Build_should_build_report_with_system_without_additional_info.approved.txt
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,25 @@ | ||
## Current behaviour | ||
|
||
``` | ||
System.ApplicationException: Failed ---> System.ArgumentOutOfRangeException: Opps ---> System.DivideByZeroException: Boom! | ||
--- End of inner exception stack trace --- | ||
--- End of inner exception stack trace --- | ||
at NBug.Tests.Unit.Util.Mock.Method1() in C:\Development\gitextensions\Externals\NBug\NBug.Tests\Unit\Util\Mock.cs:line 13 | ||
at NBug.Tests.Unit.Util.Mock.Method2() in C:\Development\gitextensions\Externals\NBug\NBug.Tests\Unit\Util\Mock.cs:line 16 | ||
at NBug.Tests.Unit.Util.Mock.Method3() in C:\Development\gitextensions\Externals\NBug\NBug.Tests\Unit\Util\Mock.cs:line 17 | ||
at NBug.Tests.Unit.Util.Mock.Method4() in C:\Development\gitextensions\Externals\NBug\NBug.Tests\Unit\Util\Mock.cs:line 18 | ||
at NBug.Tests.Unit.Util.Mock.DoWork() in C:\Development\gitextensions\Externals\NBug\NBug.Tests\Unit\Util\Mock.cs:line 7 | ||
at NBug.Tests.Unit.Util.ErrorReportMarkDownBodyBuilderTests.Build_should_build_report_with_system_without_additional_info() in C:\Development\gitextensions\Externals\NBug\NBug.Tests\Unit\Util\ErrorReportMarkDownBodyBuilderTests.cs:line 61 | ||
``` | ||
|
||
|
||
## Environment | ||
|
||
|
||
- Git Extensions 0.0.2.5232 | ||
- Build 23b6f51905006ccdde8701591df706284b4155dc | ||
- Git 2.19.0.windows.1 | ||
- Microsoft Windows NT 10.0.17134.0 | ||
- .NET Framework 4.7.3324.0 | ||
- DPI 144dpi (150% scaling) | ||
|
18 changes: 18 additions & 0 deletions
18
...BodyBuilderTests.Build_should_build_report_without_system_or_additional_info.approved.txt
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 @@ | ||
## Current behaviour | ||
|
||
``` | ||
System.ApplicationException: Failed ---> System.ArgumentOutOfRangeException: Opps ---> System.DivideByZeroException: Boom! | ||
--- End of inner exception stack trace --- | ||
--- End of inner exception stack trace --- | ||
at NBug.Tests.Unit.Util.Mock.Method1() in C:\Development\gitextensions\Externals\NBug\NBug.Tests\Unit\Util\Mock.cs:line 13 | ||
at NBug.Tests.Unit.Util.Mock.Method2() in C:\Development\gitextensions\Externals\NBug\NBug.Tests\Unit\Util\Mock.cs:line 16 | ||
at NBug.Tests.Unit.Util.Mock.Method3() in C:\Development\gitextensions\Externals\NBug\NBug.Tests\Unit\Util\Mock.cs:line 17 | ||
at NBug.Tests.Unit.Util.Mock.Method4() in C:\Development\gitextensions\Externals\NBug\NBug.Tests\Unit\Util\Mock.cs:line 18 | ||
at NBug.Tests.Unit.Util.Mock.DoWork() in C:\Development\gitextensions\Externals\NBug\NBug.Tests\Unit\Util\Mock.cs:line 7 | ||
at NBug.Tests.Unit.Util.ErrorReportMarkDownBodyBuilderTests.Build_should_build_report_without_system_or_additional_info() in C:\Development\gitextensions\Externals\NBug\NBug.Tests\Unit\Util\ErrorReportMarkDownBodyBuilderTests.cs:line 36 | ||
``` | ||
|
||
|
||
## Environment | ||
|
||
System information is not supplied |
88 changes: 88 additions & 0 deletions
88
NBug.Tests/Unit/Util/ErrorReportMarkDownBodyBuilderTests.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,88 @@ | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
// <copyright file="GitHubUrlBuilderTests.cs" company="Git Extensions"> | ||
// Copyright (c) 2019 Igor Velikorossov. Licensed under MIT license. | ||
// </copyright> | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
|
||
using System; | ||
using ApprovalTests; | ||
using FluentAssertions; | ||
using NBug.Core.Util; | ||
using Xunit; | ||
|
||
namespace NBug.Tests.Unit.Util | ||
{ | ||
public class ErrorReportMarkDownBodyBuilderTests | ||
{ | ||
private readonly ErrorReportMarkDownBodyBuilder _errorReportMarkDownBodyBuilder; | ||
|
||
public ErrorReportMarkDownBodyBuilderTests() | ||
{ | ||
Settings.GetSystemInfo = null; | ||
_errorReportMarkDownBodyBuilder = new ErrorReportMarkDownBodyBuilder(); | ||
} | ||
|
||
[Fact] | ||
public void Build_should_throw_ArgumentNullException_if_exception_null() | ||
{ | ||
((Action)(() => _errorReportMarkDownBodyBuilder.Build(null, null))).Should().Throw<ArgumentNullException>(); | ||
} | ||
|
||
[Fact] | ||
public void Build_should_build_report_without_system_or_additional_info() | ||
{ | ||
try | ||
{ | ||
Mock.DoWork(); | ||
|
||
Assert.True(false, "Expected an exception to be thrown"); | ||
} | ||
catch (Exception ex) | ||
{ | ||
var report = _errorReportMarkDownBodyBuilder.Build(ex, null); | ||
Approvals.Verify(report); | ||
} | ||
} | ||
|
||
[Fact] | ||
public void Build_should_build_report_with_system_without_additional_info() | ||
{ | ||
Settings.GetSystemInfo = () => @" | ||
- Git Extensions 0.0.2.5232 | ||
- Build 23b6f51905006ccdde8701591df706284b4155dc | ||
- Git 2.19.0.windows.1 | ||
- Microsoft Windows NT 10.0.17134.0 | ||
- .NET Framework 4.7.3324.0 | ||
- DPI 144dpi (150% scaling) | ||
"; | ||
|
||
try | ||
{ | ||
Mock.DoWork(); | ||
|
||
Assert.True(false, "Expected an exception to be thrown"); | ||
} | ||
catch (Exception ex) | ||
{ | ||
var report = _errorReportMarkDownBodyBuilder.Build(ex, null); | ||
Approvals.Verify(report); | ||
} | ||
} | ||
|
||
[Fact] | ||
public void Build_should_build_report_with_system_and_additional_info() | ||
{ | ||
try | ||
{ | ||
Mock.DoWork(); | ||
|
||
Assert.True(false, "Expected an exception to be thrown"); | ||
} | ||
catch (Exception ex) | ||
{ | ||
var report = _errorReportMarkDownBodyBuilder.Build(ex, "It happened when I was arguing with someone on the Internet.\r\nI was right and they were absolutely wrong!\r\nI win! But the app crashed!\r\nPLEASE HELP!!!"); | ||
Approvals.Verify(report); | ||
} | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
NBug.Tests/Unit/Util/GitHubUrlBuilderTests.Build_should_return_full_url.approved.txt
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 @@ | ||
http://localhost/issues/new?title=%5BNBug%5D%20BAU-863%20adding%20settings%20and%20organisations%20if%20they%20are%20not%20a...&body=%23%23%20Current%20behaviour%0D%0A%0D%0A%60%60%60%0D%0ASystem.ApplicationException%3A%20Failed%20---%3E%20System.ArgumentOutOfRangeException%3A%20Opps%20---%3E%20System.DivideByZeroException%3A%20Boom%21%0D%0A%20%20%20---%20End%20of%20inner%20exception%20stack%20trace%20---%0D%0A%20%20%20---%20End%20of%20inner%20exception%20stack%20trace%20---%0D%0A%20%20%20at%20NBug.Tests.Unit.Util.Mock.Method1%28%29%20in%20C%3A%5CDevelopment%5Cgitextensions%5CExternals%5CNBug%5CNBug.Tests%5CUnit%5CUtil%5CMock.cs%3Aline%2013%0D%0A%20%20%20at%20NBug.Tests.Unit.Util.Mock.Method2%28%29%20in%20C%3A%5CDevelopment%5Cgitextensions%5CExternals%5CNBug%5CNBug.Tests%5CUnit%5CUtil%5CMock.cs%3Aline%2016%0D%0A%20%20%20at%20NBug.Tests.Unit.Util.Mock.Method3%28%29%20in%20C%3A%5CDevelopment%5Cgitextensions%5CExternals%5CNBug%5CNBug.Tests%5CUnit%5CUtil%5CMock.cs%3Aline%2017%0D%0A%20%20%20at%20NBug.Tests.Unit.Util.Mock.Method4%28%29%20in%20C%3A%5CDevelopment%5Cgitextensions%5CExternals%5CNBug%5CNBug.Tests%5CUnit%5CUtil%5CMock.cs%3Aline%2018%0D%0A%20%20%20at%20NBug.Tests.Unit.Util.Mock.DoWork%28%29%20in%20C%3A%5CDevelopment%5Cgitextensions%5CExternals%5CNBug%5CNBug.Tests%5CUnit%5CUtil%5CMock.cs%3Aline%207%0D%0A%20%20%20at%20NBug.Tests.Unit.Util.ErrorReportMarkDownBodyBuilderTests.Build_should_build_report_without_system_or_additional_info%28%29%20in%20C%3A%5CDevelopment%5Cgitextensions%5CExternals%5CNBug%5CNBug.Tests%5CUnit%5CUtil%5CErrorReportMarkDownBodyBuilderTests.cs%3Aline%2036%0D%0A%60%60%60%0D%0A%0D%0A%23%23%20Additional%20information%0D%0A%0D%0AIt%20happened%20when%20I%20was%20arguing%20with%20someone%20on%20the%20Internet.%0D%0AI%20was%20right%20and%20they%20were%20absolutely%20wrong%21%0D%0AI%20win%21But%20the%20app%20crashed%21%0D%0APLEASE%20HELP%21%21%21%0D%0A%0D%0A%0D%0A%23%23%20Environment%0D%0A%0D%0A-%20Git%20Extensions%200.0.2.5232%0D%0A-%20Build%2023b6f51905006ccdde8701591df706284b4155dc%0D%0A-%20Git%202.19.0.windows.1%0D%0A-%20Microsoft%20Windows%20NT%2010.0.17134.0%0D%0A-%20.NET%20Framework%204.7.3324.0%0D%0A-%20DPI%20144dpi%20%28150%25%20scaling%29%0D%0A |
1 change: 1 addition & 0 deletions
1
...bUrlBuilderTests.Build_should_return_full_url_trim_subject_if_longer_70_char.approved.txt
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 @@ | ||
|
1 change: 1 addition & 0 deletions
1
...Unit/Util/GitHubUrlBuilderTests.Build_should_return_preserve_url_querystring.approved.txt
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 @@ | ||
http://localhost/issues/new?foo=bar&title=%5BNBug%5D%20BAU-863%20adding%20settings%20and%20organisations%20if%20they%20are%20not%20a...&body=%23%23%20Current%20behaviour |
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,117 @@ | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
// <copyright file="BugReportTests.cs" company="NBug Project"> | ||
// Copyright (c) 2019 Igor Velikorossov. Licensed under MIT license. | ||
// </copyright> | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
|
||
using System; | ||
using System.Linq; | ||
using ApprovalTests; | ||
using FluentAssertions; | ||
using NBug.Core.Util; | ||
using NSubstitute; | ||
using Xunit; | ||
using Xunit.Extensions; | ||
|
||
namespace NBug.Tests.Unit.Util | ||
{ | ||
public class GitHubUrlBuilderTests | ||
{ | ||
private readonly IErrorReportMarkDownBodyBuilder _errorReportMarkDownBodyBuilder; | ||
private readonly GitHubUrlBuilder _gitHubUrlBuilder; | ||
|
||
public GitHubUrlBuilderTests() | ||
{ | ||
_errorReportMarkDownBodyBuilder = Substitute.For<IErrorReportMarkDownBodyBuilder>(); | ||
_gitHubUrlBuilder = new GitHubUrlBuilder(_errorReportMarkDownBodyBuilder); | ||
} | ||
|
||
[Theory] | ||
[InlineData(null)] | ||
[InlineData("")] | ||
[InlineData("\t")] | ||
public void Build_should_return_null_if_url_unset(string url) | ||
{ | ||
_gitHubUrlBuilder.Build(url, null, null).Should().BeNull(); | ||
} | ||
|
||
[Fact] | ||
public void Build_should_return_null_if_exception_unset() | ||
{ | ||
_gitHubUrlBuilder.Build("http://", null, null).Should().BeNull(); | ||
} | ||
|
||
[Theory] | ||
[InlineData("./page/new")] | ||
[InlineData("ftp://api.github.com/issues/new")] | ||
[InlineData("file:////c:/development/file.txt")] | ||
public void Build_should_return_null_if_url_not_absolute_or_http_https(string url) | ||
{ | ||
_gitHubUrlBuilder.Build(url, null, null).Should().BeNull(); | ||
} | ||
|
||
[Fact] | ||
public void Build_should_trim_subject_if_longer_70_char() | ||
{ | ||
_errorReportMarkDownBodyBuilder.Build(Arg.Any<Exception>(), Arg.Any<string>()).Returns(x => @"## Current behaviour"); | ||
var ex = new ApplicationException("BAU-863 adding settings and organisations if they are not already exist in the set"); | ||
|
||
var url = _gitHubUrlBuilder.Build("http://localhost/issues/new?foo=bar", ex, null); | ||
|
||
var subject = url.Split('&', '?').First(x => x.StartsWith("title=")).Substring("title=".Length); | ||
subject.Should().Be(Uri.EscapeDataString("[NBug] BAU-863 adding settings and organisations if they are not a...")); | ||
} | ||
|
||
[Fact] | ||
public void Build_should_return_preserve_url_querystring() | ||
{ | ||
_errorReportMarkDownBodyBuilder.Build(Arg.Any<Exception>(), Arg.Any<string>()).Returns(x => @"## Current behaviour"); | ||
var ex = new ApplicationException("BAU-863 adding settings and organisations if they are not already exist in the set"); | ||
|
||
var url = _gitHubUrlBuilder.Build("http://localhost/issues/new?foo=bar", ex, null); | ||
|
||
Approvals.Verify(url); | ||
} | ||
|
||
[Fact] | ||
public void Build_should_return_full_url() | ||
{ | ||
_errorReportMarkDownBodyBuilder.Build(Arg.Any<Exception>(), Arg.Any<string>()).Returns(x => @"## Current behaviour | ||
``` | ||
System.ApplicationException: Failed ---> System.ArgumentOutOfRangeException: Opps ---> System.DivideByZeroException: Boom! | ||
--- End of inner exception stack trace --- | ||
--- End of inner exception stack trace --- | ||
at NBug.Tests.Unit.Util.Mock.Method1() in C:\Development\gitextensions\Externals\NBug\NBug.Tests\Unit\Util\Mock.cs:line 13 | ||
at NBug.Tests.Unit.Util.Mock.Method2() in C:\Development\gitextensions\Externals\NBug\NBug.Tests\Unit\Util\Mock.cs:line 16 | ||
at NBug.Tests.Unit.Util.Mock.Method3() in C:\Development\gitextensions\Externals\NBug\NBug.Tests\Unit\Util\Mock.cs:line 17 | ||
at NBug.Tests.Unit.Util.Mock.Method4() in C:\Development\gitextensions\Externals\NBug\NBug.Tests\Unit\Util\Mock.cs:line 18 | ||
at NBug.Tests.Unit.Util.Mock.DoWork() in C:\Development\gitextensions\Externals\NBug\NBug.Tests\Unit\Util\Mock.cs:line 7 | ||
at NBug.Tests.Unit.Util.ErrorReportMarkDownBodyBuilderTests.Build_should_build_report_without_system_or_additional_info() in C:\Development\gitextensions\Externals\NBug\NBug.Tests\Unit\Util\ErrorReportMarkDownBodyBuilderTests.cs:line 36 | ||
``` | ||
## Additional information | ||
It happened when I was arguing with someone on the Internet. | ||
I was right and they were absolutely wrong! | ||
I win!But the app crashed! | ||
PLEASE HELP!!! | ||
## Environment | ||
- Git Extensions 0.0.2.5232 | ||
- Build 23b6f51905006ccdde8701591df706284b4155dc | ||
- Git 2.19.0.windows.1 | ||
- Microsoft Windows NT 10.0.17134.0 | ||
- .NET Framework 4.7.3324.0 | ||
- DPI 144dpi (150% scaling) | ||
"); | ||
var ex = new ApplicationException("BAU-863 adding settings and organisations if they are not already exist in the set"); | ||
|
||
var url = _gitHubUrlBuilder.Build("http://localhost/issues/new", ex, null); | ||
|
||
Approvals.Verify(url); | ||
} | ||
} | ||
} |
Oops, something went wrong.