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

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForUser(null));

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

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForUser("user", null));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForUser(""));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForUser("", ApiOptions.None));
            }
Example #2
0
            public void RequestsCorrectUrl()
            {
                var endpoint = new Uri("users/banana/subscriptions", UriKind.Relative);
                var connection = Substitute.For<IApiConnection>();
                var client = new WatchedClient(connection);

                client.GetAllForUser("banana");

                connection.Received().GetAll<Repository>(endpoint);
            }
Example #3
0
            public async Task RequestsCorrectUrlWithApiOptions()
            {
                var endpoint   = new Uri("users/banana/subscriptions", UriKind.Relative);
                var connection = Substitute.For <IApiConnection>();
                var client     = new WatchedClient(connection);

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

                await client.GetAllForUser("banana", options);

                connection.Received().GetAll <Repository>(endpoint, options);
            }
            public async Task EnsuresNonNullArguments()
            {
                var client = new WatchedClient(Substitute.For<IApiConnection>());

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

                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForUser(""));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForUser("", ApiOptions.None));
            }
            public void RequestsCorrectUrlWithApiOptions()
            {
                var endpoint = new Uri("users/banana/subscriptions", UriKind.Relative);
                var connection = Substitute.For<IApiConnection>();
                var client = new WatchedClient(connection);

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

                client.GetAllForUser("banana", options);

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