From 56ddff37e259352e3b854d8bfd2a87af9a11c5d5 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Mon, 14 Dec 2015 09:56:41 +1030 Subject: [PATCH] define tests which require basic authentication --- .../BasicAuthenticationTestAttribute.cs | 33 +++++++++++++++++++ .../Octokit.Tests.Integration.csproj | 1 + 2 files changed, 34 insertions(+) create mode 100644 Octokit.Tests.Integration/Helpers/BasicAuthenticationTestAttribute.cs diff --git a/Octokit.Tests.Integration/Helpers/BasicAuthenticationTestAttribute.cs b/Octokit.Tests.Integration/Helpers/BasicAuthenticationTestAttribute.cs new file mode 100644 index 00000000..e1ced818 --- /dev/null +++ b/Octokit.Tests.Integration/Helpers/BasicAuthenticationTestAttribute.cs @@ -0,0 +1,33 @@ +using System.Collections.Generic; +using System.Linq; +using Xunit; +using Xunit.Abstractions; +using Xunit.Sdk; + +namespace Octokit.Tests.Integration +{ + public class BasicAuthenticationTestDiscoverer : IXunitTestCaseDiscoverer + { + readonly IMessageSink diagnosticMessageSink; + + public BasicAuthenticationTestDiscoverer(IMessageSink diagnosticMessageSink) + { + this.diagnosticMessageSink = diagnosticMessageSink; + } + + public IEnumerable Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute) + { + if (Helper.Organization == null) + { + return Enumerable.Empty(); + } + + return new[] { new XunitTestCase(diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod) }; + } + } + + [XunitTestCaseDiscoverer("Octokit.Tests.Integration.BasicAuthenticationTestDiscoverer", "Octokit.Tests.Integration")] + public class BasicAuthenticationTestAttribute : FactAttribute + { + } +} diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index f4697936..cecb4fd2 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -105,6 +105,7 @@ +