コード例 #1
0
            public async Task RequestsCorrectUrl4WithRepositoryId()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepositoryContentsClient(connection);

                await client.GetArchive(1, ArchiveFormat.Zipball, "ref", TimeSpan.FromMinutes(60));

                const string expectedUri      = "repositories/1/zipball/ref";
                var          expectedTimeSpan = TimeSpan.FromMinutes(60);

                connection.Connection.Received().Get <byte[]>(Arg.Is <Uri>(uri => uri.ToString() == expectedUri), Arg.Is <TimeSpan>(span => span == expectedTimeSpan));
            }
コード例 #2
0
            public async Task RequestsCorrectUrl1()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepositoryContentsClient(connection);

                await client.GetArchive("org", "repo");

                const string expectedUri      = "repos/org/repo/tarball/";
                var          expectedTimeSpan = TimeSpan.FromMinutes(60);

                connection.Connection.Received().Get <byte[]>(Arg.Is <Uri>(uri => uri.ToString() == expectedUri), Arg.Is <TimeSpan>(span => span == expectedTimeSpan));
            }
コード例 #3
0
            public void EnsurePassingCorrectParameters()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepositoryContentsClient(connection);

                client.GetArchive("org", "repo", ArchiveFormat.Tarball, "dev");

                const string expectedUri      = "repos/org/repo/tarball/dev";
                var          expectedTimeSpan = TimeSpan.FromMinutes(60);

                connection.Connection.Received().Get <byte[]>(Arg.Is <Uri>(uri => uri.ToString() == expectedUri), Arg.Is <TimeSpan>(span => span == expectedTimeSpan));
            }
コード例 #4
0
            public void EnsurePassingCorrectParameters()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoryContentsClient(connection);

                client.GetArchive("org", "repo", ArchiveFormat.Tarball, "dev");

                const string expectedUri = "repos/org/repo/tarball/dev";
                var expectedTimeSpan = TimeSpan.FromMinutes(60);

                connection.Connection.Received().Get<byte[]>(Arg.Is<Uri>(uri => uri.ToString() == expectedUri), Arg.Is<TimeSpan>(span => span == expectedTimeSpan));
            }
コード例 #5
0
            public async Task EnsuresNonNullArguments()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new RepositoryContentsClient(connection);

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetArchive(null, "repo"));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetArchive("org", null));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetArchive(null, "repo", ArchiveFormat.Tarball));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetArchive("org", null, ArchiveFormat.Tarball));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetArchive(null, "repo", ArchiveFormat.Tarball, "ref"));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetArchive("org", null, ArchiveFormat.Tarball, "ref"));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetArchive("org", "repo", ArchiveFormat.Tarball, null));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetArchive(null, "repo", ArchiveFormat.Tarball, "ref", TimeSpan.MaxValue));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetArchive("org", null, ArchiveFormat.Tarball, "ref", TimeSpan.MaxValue));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetArchive("org", "repo", ArchiveFormat.Tarball, null, TimeSpan.MaxValue));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetArchive(1, ArchiveFormat.Tarball, null));

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetArchive(1, ArchiveFormat.Tarball, null, TimeSpan.MaxValue));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetArchive("", "repo"));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetArchive("org", ""));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetArchive("", "repo", ArchiveFormat.Tarball));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetArchive("org", "", ArchiveFormat.Tarball));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetArchive("", "repo", ArchiveFormat.Tarball, "ref"));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetArchive("org", "", ArchiveFormat.Tarball, "ref"));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetArchive("", "repo", ArchiveFormat.Tarball, "ref", TimeSpan.MaxValue));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetArchive("org", "", ArchiveFormat.Tarball, "ref", TimeSpan.MaxValue));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetArchive("org", "repo", ArchiveFormat.Tarball, "ref", TimeSpan.Zero));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetArchive(1, ArchiveFormat.Tarball, "ref", TimeSpan.Zero));
            }
コード例 #6
0
            public async Task EnsuresNonNullArguments()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoryContentsClient(connection);

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetArchive(null, "repo"));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetArchive("org", null));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetArchive(null, "repo", ArchiveFormat.Tarball));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetArchive("org", null, ArchiveFormat.Tarball));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetArchive(null, "repo", ArchiveFormat.Tarball, "ref"));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetArchive("org", null, ArchiveFormat.Tarball, "ref"));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetArchive("org", "repo", ArchiveFormat.Tarball, null));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetArchive(null, "repo", ArchiveFormat.Tarball, "ref", TimeSpan.MaxValue));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetArchive("org", null, ArchiveFormat.Tarball, "ref", TimeSpan.MaxValue));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetArchive("org", "repo", ArchiveFormat.Tarball, null, TimeSpan.MaxValue));

                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetArchive(1, ArchiveFormat.Tarball, null));
                await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetArchive(1, ArchiveFormat.Tarball, null, TimeSpan.MaxValue));

                await Assert.ThrowsAsync<ArgumentException>(() => client.GetArchive("", "repo"));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetArchive("org", ""));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetArchive("", "repo", ArchiveFormat.Tarball));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetArchive("org", "", ArchiveFormat.Tarball));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetArchive("", "repo", ArchiveFormat.Tarball, "ref"));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetArchive("org", "", ArchiveFormat.Tarball, "ref"));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetArchive("", "repo", ArchiveFormat.Tarball, "ref", TimeSpan.MaxValue));
                await Assert.ThrowsAsync<ArgumentException>(() => client.GetArchive("org", "", ArchiveFormat.Tarball, "ref", TimeSpan.MaxValue));

                await Assert.ThrowsAsync<ArgumentException>(() => client.GetArchive("org", "repo", ArchiveFormat.Tarball, "ref", TimeSpan.Zero));

                await Assert.ThrowsAsync<ArgumentException>(() => client.GetArchive(1, ArchiveFormat.Tarball, "ref", TimeSpan.Zero));
            }
コード例 #7
0
            public async Task RequestsCorrectUrl4WithRepositoryId()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoryContentsClient(connection);

                await client.GetArchive(1, ArchiveFormat.Zipball, "ref", TimeSpan.FromMinutes(60));

                const string expectedUri = "repositories/1/zipball/ref";
                var expectedTimeSpan = TimeSpan.FromMinutes(60);

                connection.Connection.Received().Get<byte[]>(Arg.Is<Uri>(uri => uri.ToString() == expectedUri), Arg.Is<TimeSpan>(span => span == expectedTimeSpan));
            }
コード例 #8
0
            public async Task RequestsCorrectUrl1()
            {
                var connection = Substitute.For<IApiConnection>();
                var client = new RepositoryContentsClient(connection);

                await client.GetArchive("org", "repo");

                const string expectedUri = "repos/org/repo/tarball/";
                var expectedTimeSpan = TimeSpan.FromMinutes(60);

                connection.Connection.Received().Get<byte[]>(Arg.Is<Uri>(uri => uri.ToString() == expectedUri), Arg.Is<TimeSpan>(span => span == expectedTimeSpan));
            }