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

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

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

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

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetPaths("owner", ""));
            }
Example #2
0
            public async Task RequestsCorrectUrlWithRepositoryId()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepositoryTrafficClient(connection);

                await client.GetPaths(1);

                connection.Received().GetAll <RepositoryTrafficPath>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/traffic/popular/paths"), "application/vnd.github.spiderman-preview");
            }
            public async Task RequestsCorrectUrlWithRepositoryId()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoryTrafficClient(connection);

                await client.GetPaths(1);

                connection.Received().GetAll<RepositoryTrafficPath>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/traffic/popular/paths"), "application/vnd.github.spiderman-preview");
            }
            public async Task EnsuresNonNullArguments()
            {
                var client = new RepositoryTrafficClient(Substitute.For<IApiConnection>());

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

                await Assert.ThrowsAsync<ArgumentException>(() => client.GetPaths("", "name"));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetPaths("owner", ""));
            }