diff --git a/.travis.yml b/.travis.yml index ea0943ab..2979711d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,5 +14,4 @@ script: - dotnet --verbose build - cd ../InstaSharper.Tests - dotnet --verbose build - - dotnet --verbose test -parallel none - \ No newline at end of file + - dotnet --verbose test -parallel none \ No newline at end of file diff --git a/InstaSharper.Tests/FactNTheories/AuthTest.cs b/InstaSharper.Tests/Endpoints/AuthTest.cs similarity index 91% rename from InstaSharper.Tests/FactNTheories/AuthTest.cs rename to InstaSharper.Tests/Endpoints/AuthTest.cs index 788b613c..6004c596 100644 --- a/InstaSharper.Tests/FactNTheories/AuthTest.cs +++ b/InstaSharper.Tests/Endpoints/AuthTest.cs @@ -4,9 +4,9 @@ using Xunit; using Xunit.Abstractions; -namespace InstaSharper.Tests.FactNTheories +namespace InstaSharper.Tests.Endpoints { - [Collection("InstaSharper Tests")] + [Collection("Endpoints")] public class AuthTest { public AuthTest(ITestOutputHelper output) @@ -16,7 +16,7 @@ public AuthTest(ITestOutputHelper output) private readonly ITestOutputHelper _output; - [Fact] + [RunnableInDebugOnlyFact] public async void UserLoginFailTest() { var username = "alex_codegarage"; @@ -33,7 +33,7 @@ public async void UserLoginFailTest() Assert.False(apiInstance.IsUserAuthenticated); } - [Fact] + [RunnableInDebugOnlyFact] public async void UserLoginSuccessTest() { var username = "alex_codegarage"; diff --git a/InstaSharper.Tests/FactNTheories/DiscoverTest.cs b/InstaSharper.Tests/Endpoints/DiscoverTest.cs similarity index 91% rename from InstaSharper.Tests/FactNTheories/DiscoverTest.cs rename to InstaSharper.Tests/Endpoints/DiscoverTest.cs index 7698dd6e..1db07aa6 100644 --- a/InstaSharper.Tests/FactNTheories/DiscoverTest.cs +++ b/InstaSharper.Tests/Endpoints/DiscoverTest.cs @@ -4,21 +4,21 @@ using Xunit; using Xunit.Abstractions; -namespace InstaSharper.Tests.FactNTheories +namespace InstaSharper.Tests.Endpoints { - [Collection("InstaSharper Tests")] + [Collection("Endpoints")] public class DiscoverTest { + private readonly ITestOutputHelper _output; + private readonly string _password = Environment.GetEnvironmentVariable("instaapiuserpassword"); + private readonly string _username = "alex_codegarage"; + public DiscoverTest(ITestOutputHelper output) { _output = output; } - private readonly ITestOutputHelper _output; - private readonly string _username = "alex_codegarage"; - private readonly string _password = Environment.GetEnvironmentVariable("instaapiuserpassword"); - - [Fact] + [RunnableInDebugOnlyFact] public async void ExploreTest() { //arrange diff --git a/InstaSharper.Tests/FactNTheories/FeedTest.cs b/InstaSharper.Tests/Endpoints/FeedTest.cs similarity index 96% rename from InstaSharper.Tests/FactNTheories/FeedTest.cs rename to InstaSharper.Tests/Endpoints/FeedTest.cs index 1daac1cc..0df5d4fe 100644 --- a/InstaSharper.Tests/FactNTheories/FeedTest.cs +++ b/InstaSharper.Tests/Endpoints/FeedTest.cs @@ -4,21 +4,21 @@ using Xunit; using Xunit.Abstractions; -namespace InstaSharper.Tests.FactNTheories +namespace InstaSharper.Tests.Endpoints { - [Collection("InstaSharper Tests")] + [Collection("Endpoints")] public class FeedTest { + private readonly ITestOutputHelper _output; + private readonly string _password = Environment.GetEnvironmentVariable("instaapiuserpassword"); + private readonly string _username = "alex_codegarage"; + public FeedTest(ITestOutputHelper output) { _output = output; } - private readonly ITestOutputHelper _output; - private readonly string _username = "alex_codegarage"; - private readonly string _password = Environment.GetEnvironmentVariable("instaapiuserpassword"); - - [Theory] + [RunnableInDebugOnlyTheory] [InlineData("christmas")] [InlineData("rock")] public async void GetTagFeedTest(string tag) @@ -49,7 +49,7 @@ public async void GetTagFeedTest(string tag) } - [Theory] + [RunnableInDebugOnlyTheory] [InlineData("rock")] public async void GetUserTagFeedTest(string username) { @@ -78,7 +78,7 @@ public async void GetUserTagFeedTest(string username) Assert.NotNull(tagFeed); } - [Fact] + [RunnableInDebugOnlyFact] public async void GetFollowingRecentActivityFeedTest() { //arrange @@ -108,7 +108,7 @@ public async void GetFollowingRecentActivityFeedTest() Assert.True(!folloowingRecentFeed.IsOwnActivity); } - [Fact] + [RunnableInDebugOnlyFact] public async void GetRecentActivityFeedTest() { //arrange @@ -137,7 +137,7 @@ public async void GetRecentActivityFeedTest() Assert.True(ownRecentFeed.IsOwnActivity); } - [Fact] + [RunnableInDebugOnlyFact] public async void GetUserFeedTest() { //arrange diff --git a/InstaSharper.Tests/FactNTheories/FollowersTest.cs b/InstaSharper.Tests/Endpoints/FollowersTest.cs similarity index 92% rename from InstaSharper.Tests/FactNTheories/FollowersTest.cs rename to InstaSharper.Tests/Endpoints/FollowersTest.cs index 6b4a1a16..81bed67c 100644 --- a/InstaSharper.Tests/FactNTheories/FollowersTest.cs +++ b/InstaSharper.Tests/Endpoints/FollowersTest.cs @@ -4,19 +4,19 @@ using Xunit; using Xunit.Abstractions; -namespace InstaSharper.Tests.FactNTheories +namespace InstaSharper.Tests.Endpoints { - [Collection("InstaSharper Tests")] + [Collection("Endpoints")] public class FollowersTest { + private readonly ITestOutputHelper _output; + public FollowersTest(ITestOutputHelper output) { _output = output; } - private readonly ITestOutputHelper _output; - - [Theory] + [RunnableInDebugOnlyTheory] [InlineData("discovery")] public async void GetUserFollowersTest(string username) { @@ -35,7 +35,7 @@ public async void GetUserFollowersTest(string username) Assert.NotNull(followers); } - [Fact] + [RunnableInDebugOnlyFact] public async void GetCurrentUserFollwersTest() { var username = "alex_codegarage"; diff --git a/InstaSharper.Tests/FactNTheories/MediaTest.cs b/InstaSharper.Tests/Endpoints/MediaTest.cs similarity index 94% rename from InstaSharper.Tests/FactNTheories/MediaTest.cs rename to InstaSharper.Tests/Endpoints/MediaTest.cs index bf667b19..5f27e954 100644 --- a/InstaSharper.Tests/FactNTheories/MediaTest.cs +++ b/InstaSharper.Tests/Endpoints/MediaTest.cs @@ -4,9 +4,9 @@ using Xunit; using Xunit.Abstractions; -namespace InstaSharper.Tests.FactNTheories +namespace InstaSharper.Tests.Endpoints { - [Collection("InstaSharper Tests")] + [Collection("Endpoints")] public class MediaTest { private readonly ITestOutputHelper _output; @@ -16,7 +16,7 @@ public MediaTest(ITestOutputHelper output) _output = output; } - [Theory] + [RunnableInDebugOnlyTheory] [InlineData("1379932752706850783")] public async void GetMediaByCodeTest(string mediaId) { @@ -37,7 +37,7 @@ public async void GetMediaByCodeTest(string mediaId) Assert.NotNull(media); } - [Theory] + [RunnableInDebugOnlyTheory] [InlineData("alex_codegarage")] [InlineData("instagram")] [InlineData("therock")] diff --git a/InstaSharper.Tests/FactNTheories/MessagingTest.cs b/InstaSharper.Tests/Endpoints/MessagingTest.cs similarity index 94% rename from InstaSharper.Tests/FactNTheories/MessagingTest.cs rename to InstaSharper.Tests/Endpoints/MessagingTest.cs index 5b5bb3bc..d8155395 100644 --- a/InstaSharper.Tests/FactNTheories/MessagingTest.cs +++ b/InstaSharper.Tests/Endpoints/MessagingTest.cs @@ -4,21 +4,21 @@ using Xunit; using Xunit.Abstractions; -namespace InstaSharper.Tests.FactNTheories +namespace InstaSharper.Tests.Endpoints { - [Collection("InstaSharper Tests")] + [Collection("Endpoints")] public class MessagingTest { + private readonly ITestOutputHelper _output; + private readonly string _password = Environment.GetEnvironmentVariable("instaapiuserpassword"); + private readonly string _username = "alex_codegarage"; + public MessagingTest(ITestOutputHelper output) { _output = output; } - private readonly ITestOutputHelper _output; - private readonly string _username = "alex_codegarage"; - private readonly string _password = Environment.GetEnvironmentVariable("instaapiuserpassword"); - - [Theory] + [RunnableInDebugOnlyTheory] [InlineData("340282366841710300949128137443944319108")] public async void GetDirectInboxThreadByIdTest(string threadId) { @@ -38,7 +38,7 @@ public async void GetDirectInboxThreadByIdTest(string threadId) Assert.NotNull(thread); } - [Fact] + [RunnableInDebugOnlyFact] public async void GetDirectInboxTest() { //arrange @@ -57,7 +57,7 @@ public async void GetDirectInboxTest() Assert.NotNull(inbox); } - [Fact] + [RunnableInDebugOnlyFact] public async void GetRankedeRecipientsTest() { //arrange @@ -82,7 +82,7 @@ public async void GetRankedeRecipientsTest() Assert.True(result.Succeeded); } - [Fact] + [RunnableInDebugOnlyFact] public async void GetRecentRecipientsTest() { //arrange diff --git a/InstaSharper.Tests/FactNTheories/UserInfoTest.cs b/InstaSharper.Tests/Endpoints/UserInfoTest.cs similarity index 93% rename from InstaSharper.Tests/FactNTheories/UserInfoTest.cs rename to InstaSharper.Tests/Endpoints/UserInfoTest.cs index 879e2535..9db4d3f7 100644 --- a/InstaSharper.Tests/FactNTheories/UserInfoTest.cs +++ b/InstaSharper.Tests/Endpoints/UserInfoTest.cs @@ -4,21 +4,21 @@ using Xunit; using Xunit.Abstractions; -namespace InstaSharper.Tests.FactNTheories +namespace InstaSharper.Tests.Endpoints { - [Collection("InstaSharper Tests")] + [Collection("Endpoints")] public class UserInfoTest { + private readonly ITestOutputHelper _output; + private readonly string _password = Environment.GetEnvironmentVariable("instaapiuserpassword"); + private readonly string _username = "alex_codegarage"; + public UserInfoTest(ITestOutputHelper output) { _output = output; } - private readonly ITestOutputHelper _output; - private readonly string _username = "alex_codegarage"; - private readonly string _password = Environment.GetEnvironmentVariable("instaapiuserpassword"); - - [Fact] + [RunnableInDebugOnlyFact] public async void GetCurrentUserTest() { //arrange @@ -38,7 +38,7 @@ public async void GetCurrentUserTest() Assert.Equal(user.UserName, _username); } - [Fact] + [RunnableInDebugOnlyFact] public async void GetUserTest() { //arrange diff --git a/InstaSharper.Tests/FactNTheories/ApiInstanceBuilderTest.cs b/InstaSharper.Tests/Infrastructure/ApiInstanceBuilderTest.cs similarity index 82% rename from InstaSharper.Tests/FactNTheories/ApiInstanceBuilderTest.cs rename to InstaSharper.Tests/Infrastructure/ApiInstanceBuilderTest.cs index cc086499..f3832b6b 100644 --- a/InstaSharper.Tests/FactNTheories/ApiInstanceBuilderTest.cs +++ b/InstaSharper.Tests/Infrastructure/ApiInstanceBuilderTest.cs @@ -2,9 +2,9 @@ using InstaSharper.Tests.Utils; using Xunit; -namespace InstaSharper.Tests.FactNTheories +namespace InstaSharper.Tests.Infrastructure { - [Collection("InstaSharper Tests")] + [Collection("Infrastructure")] public class ApiInstanceBuilderTest { [Fact] diff --git a/InstaSharper.Tests/Utils/RunnableInDebugOnlyFact.cs b/InstaSharper.Tests/Utils/RunnableInDebugOnlyFact.cs new file mode 100644 index 00000000..d9a216e6 --- /dev/null +++ b/InstaSharper.Tests/Utils/RunnableInDebugOnlyFact.cs @@ -0,0 +1,14 @@ +using System.Diagnostics; +using Xunit; + +namespace InstaSharper.Tests.Utils +{ + public sealed class RunnableInDebugOnlyFact : FactAttribute + { + public RunnableInDebugOnlyFact() + { + if (!Debugger.IsAttached) + Skip = "This fact only running in interactive mode."; + } + } +} \ No newline at end of file diff --git a/InstaSharper.Tests/Utils/RunnableInDebugOnlyTheory.cs b/InstaSharper.Tests/Utils/RunnableInDebugOnlyTheory.cs new file mode 100644 index 00000000..cf2d1ac6 --- /dev/null +++ b/InstaSharper.Tests/Utils/RunnableInDebugOnlyTheory.cs @@ -0,0 +1,14 @@ +using System.Diagnostics; +using Xunit; + +namespace InstaSharper.Tests.Utils +{ + public sealed class RunnableInDebugOnlyTheory : TheoryAttribute + { + public RunnableInDebugOnlyTheory() + { + if (!Debugger.IsAttached) + Skip = "This theory only running in interactive mode."; + } + } +} \ No newline at end of file diff --git a/InstaSharper.Tests/project.json b/InstaSharper.Tests/project.json index 092e385c..73d1109d 100644 --- a/InstaSharper.Tests/project.json +++ b/InstaSharper.Tests/project.json @@ -15,5 +15,10 @@ } } } + }, + "buildOptions": { + "copyToOutput": { + "include": ["xunit.runner.json"] + } } } \ No newline at end of file diff --git a/InstaSharper.Tests/xunit.runner.json b/InstaSharper.Tests/xunit.runner.json new file mode 100644 index 00000000..da368119 --- /dev/null +++ b/InstaSharper.Tests/xunit.runner.json @@ -0,0 +1,5 @@ +{ + "parallelizeTestCollections": false, + "diagnosticMessages": true, + "maxParallelThreads": 1 +} \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index 5502ff8a..f0e77741 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -32,31 +32,5 @@ build_script: environment: instaapiuserpassword: secure: 7eAl+O5i5BxXWexd26z+wg== - -artifacts: - - path: InstaSharper\bin\$(configuration)\netstandard1.6\*.dll - name: dlls - - - path: '**\*.nupkg' - -deploy: - - provider: GitHub - auth_token: - secure: FE6k4kAwz++t3+H7UvZkUELVZsx8DIjSOM1R3ZVT7YgqwQXuMKFQpDM5HmQobF22 - artifact: /.*\.nupkg/, dlls - draft: false - prerelease: false - on: - branch: release - platform: Any CPU - configuration: Release - - provider: NuGet - api_key: - secure: At3FDhivtW6bQz/WXdwE6RzuFeouCMag3htqBE/1uuTJnFmHB8hU9gCy31ORFWtS - artifact: /.*\.nupkg/ - on: - branch: release - platform: Any CPU - configuration: Release test: off