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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }