Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 206334c

Browse files
committed
Add tests for IsGitHubApiException
1 parent 824bab4 commit 206334c

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System.Collections.Generic;
2+
using System.Collections.Immutable;
3+
using Octokit;
4+
using NSubstitute;
5+
using NUnit.Framework;
6+
using GitHub.Extensions;
7+
8+
public class ApiExceptionExtensionsTests
9+
{
10+
public class TheIsGitHubApiExceptionMethod
11+
{
12+
[TestCase("Not-GitHub-Request-Id", false)]
13+
[TestCase("X-GitHub-Request-Id", true)]
14+
public void NoGitHubRequestId(string key, bool expect)
15+
{
16+
var ex = CreateApiException(new Dictionary<string, string> { { key, "ANYTHING" } });
17+
18+
var result = ApiExceptionExtensions.IsGitHubApiException(ex);
19+
20+
Assert.That(result, Is.EqualTo(expect));
21+
}
22+
23+
static ApiException CreateApiException(Dictionary<string, string> headers)
24+
{
25+
var response = Substitute.For<IResponse>();
26+
response.Headers.Returns(headers.ToImmutableDictionary());
27+
var ex = new ApiException(response);
28+
return ex;
29+
}
30+
}
31+
}

0 commit comments

Comments
 (0)