コード例 #1
0
            public async Task RequestsCorrectUrlWithRepositoryId()
            {
                var endpoint   = new Uri("repositories/1/subscribers", UriKind.Relative);
                var connection = Substitute.For <IApiConnection>();
                var client     = new WatchedClient(connection);

                await client.GetAllWatchers(1);

                connection.Received().GetAll <User>(endpoint, Args.ApiOptions);
            }
コード例 #2
0
            public void RequestsCorrectUrl()
            {
                var endpoint = new Uri("repos/fight/club/subscribers", UriKind.Relative);
                var connection = Substitute.For<IApiConnection>();
                var client = new WatchedClient(connection);

                client.GetAllWatchers("fight", "club");

                connection.Received().GetAll<User>(endpoint);
            }
コード例 #3
0
            public async Task EnsuresNonNullArguments()
            {
                var client = new WatchedClient(Substitute.For <IApiConnection>());

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

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

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

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

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

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllWatchers(1, null));

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

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllWatchers("owner", ""));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllWatchers("", "name", ApiOptions.None));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllWatchers("owner", "", ApiOptions.None));
            }
コード例 #4
0
            public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions()
            {
                var endpoint   = new Uri("repositories/1/subscribers", UriKind.Relative);
                var connection = Substitute.For <IApiConnection>();
                var client     = new WatchedClient(connection);

                var options = new ApiOptions
                {
                    StartPage = 1,
                    PageCount = 1,
                    PageSize  = 1
                };

                await client.GetAllWatchers(1, options);

                connection.Received().GetAll <User>(endpoint, options);
            }
コード例 #5
0
            public void RequestsCorrectUrlWithApiOptions()
            {
                var endpoint   = new Uri("repos/fight/club/subscribers", UriKind.Relative);
                var connection = Substitute.For <IApiConnection>();
                var client     = new WatchedClient(connection);

                var options = new ApiOptions
                {
                    StartPage = 1,
                    PageCount = 1,
                    PageSize  = 1
                };

                client.GetAllWatchers("fight", "club", options);

                connection.Received().GetAll <User>(endpoint, options);
            }
コード例 #6
0
            public async Task EnsuresNonNullArguments()
            {
                var client = new WatchedClient(Substitute.For<IApiConnection>());

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllWatchers(null, "name"));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllWatchers("owner", null));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllWatchers(null, "name", ApiOptions.None));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllWatchers("owner", null, ApiOptions.None));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllWatchers("owner", "name", null));

                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllWatchers("", "name"));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllWatchers("owner", ""));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllWatchers("", "name", ApiOptions.None));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllWatchers("owner", "", ApiOptions.None));
            }
コード例 #7
0
            public void RequestsCorrectUrlWithApiOptions()
            {
                var endpoint = new Uri("repos/fight/club/subscribers", UriKind.Relative);
                var connection = Substitute.For<IApiConnection>();
                var client = new WatchedClient(connection);

                var options = new ApiOptions
                {
                    StartPage = 1,
                    PageCount = 1,
                    PageSize = 1
                };

                client.GetAllWatchers("fight", "club", options);

                connection.Received().GetAll<User>(endpoint, options);
            }