示例#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);
            }
            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);
            }
            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));
            }
            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);
            }