Example #1
0
            public async Task EnsuresNonNullArguments()
            {
                var client = new WatchedClient(Substitute.For <IApiConnection>());

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.UnwatchRepo(null, "name"));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.UnwatchRepo("owner", null));

                await Assert.ThrowsAsync <ArgumentException>(() => client.UnwatchRepo("", "name"));

                await Assert.ThrowsAsync <ArgumentException>(() => client.UnwatchRepo("owner", ""));
            }
Example #2
0
 public async Task <bool> UnWatchRepository(long repositoryId, GitHubClient authorizedGitHubClient)
 {
     if (_watchedClient == null)
     {
         _watchedClient = new WatchedClient(new ApiConnection(authorizedGitHubClient.Connection));
     }
     return(await _watchedClient.UnwatchRepo(repositoryId));
 }
Example #3
0
            public async Task ReturnsCorrectResultBasedOnStatus(HttpStatusCode status, bool expected)
            {
                var response = Task.Factory.StartNew<HttpStatusCode>(() => status);

                var connection = Substitute.For<IConnection>();
                connection.DeleteAsync(Arg.Is<Uri>(u => u.ToString() == "repos/yes/no/subscription"))
                    .Returns(response);

                var apiConnection = Substitute.For<IApiConnection>();
                apiConnection.Connection.Returns(connection);

                var client = new WatchedClient(apiConnection);
                var result = await client.UnwatchRepo("yes", "no");

                Assert.Equal(expected, result);
            }
Example #4
0
            public async Task ReturnsCorrectResultBasedOnStatusWithRepositoryId(HttpStatusCode status, bool expected)
            {
                var response = Task.FromResult(status);

                var connection = Substitute.For <IConnection>();

                connection.Delete(Arg.Is <Uri>(u => u.ToString() == "repositories/1/subscription"))
                .Returns(response);

                var apiConnection = Substitute.For <IApiConnection>();

                apiConnection.Connection.Returns(connection);

                var client = new WatchedClient(apiConnection);
                var result = await client.UnwatchRepo(1);

                Assert.Equal(expected, result);
            }