public async Task ReturnsContentsByRef() { List<RepositoryContent> result = new List<RepositoryContent> { new RepositoryContent() }; var connection = Substitute.For<IApiConnection>(); connection.GetAll<RepositoryContent>(Args.Uri).Returns(Task.FromResult(result.AsReadOnly() as IReadOnlyList<RepositoryContent>)); var contentsClient = new RepositoryContentsClient(connection); var contents = await contentsClient.GetAllContentsByRef("fake", "repo", "readme.md", "master"); connection.Received().GetAll<RepositoryContent>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/contents/readme.md?ref=master")); Assert.Equal(1, contents.Count); }
public async Task ReturnsAllContentsByRefWithRepositoryId() { var result = new List <RepositoryContent> { new RepositoryContent() }; var connection = Substitute.For <IApiConnection>(); connection.GetAll <RepositoryContent>(Args.Uri).Returns(Task.FromResult(result.AsReadOnly() as IReadOnlyList <RepositoryContent>)); var contentsClient = new RepositoryContentsClient(connection); var contents = await contentsClient.GetAllContentsByRef(1, "master"); connection.Received().GetAll <RepositoryContent>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/contents/?ref=master")); Assert.Equal(1, contents.Count); }
public async Task ReturnsContentsByRef() { List <RepositoryContent> result = new List <RepositoryContent>() { new RepositoryContent() { } }; var connection = Substitute.For <IApiConnection>(); connection.GetAll <RepositoryContent>(Args.Uri).Returns(Task.FromResult(result.AsReadOnly() as IReadOnlyList <RepositoryContent>)); var contentsClient = new RepositoryContentsClient(connection); var contents = await contentsClient.GetAllContentsByRef("fake", "repo", "readme.md", "master"); connection.Received().GetAll <RepositoryContent>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/contents/readme.md?ref=master")); Assert.Equal(1, contents.Count); }
public async Task EnsuresNonNullArguments() { var connection = Substitute.For <IApiConnection>(); var client = new RepositoryContentsClient(connection); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllContentsByRef(null, "name", "ref")); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllContentsByRef("owner", null, "ref")); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllContentsByRef("owner", "name", null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllContentsByRef(null, "name", "path", "reference")); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllContentsByRef("owner", null, "path", "reference")); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllContentsByRef("owner", "name", null, "reference")); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllContentsByRef("owner", "name", "path", null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllContentsByRef(1, null, "reference")); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllContentsByRef(1, "path", null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllContentsByRef(1, null)); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllContentsByRef("", "name", "ref")); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllContentsByRef("owner", "", "ref")); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllContentsByRef("owner", "name", "")); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllContentsByRef("", "name", "path", "reference")); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllContentsByRef("owner", "", "path", "reference")); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllContentsByRef("owner", "name", "", "reference")); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllContentsByRef("owner", "name", "path", "")); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllContentsByRef(1, "", "reference")); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllContentsByRef(1, "path", "")); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllContentsByRef(1, "")); }
public async Task EnsuresNonNullArguments() { var connection = Substitute.For<IApiConnection>(); var client = new RepositoryContentsClient(connection); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllContentsByRef(null, "name", "ref")); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllContentsByRef("owner", null, "ref")); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllContentsByRef("owner", "name", null)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllContentsByRef(null, "name", "path", "reference")); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllContentsByRef("owner", null, "path", "reference")); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllContentsByRef("owner", "name", null, "reference")); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllContentsByRef("owner", "name", "path", null)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllContentsByRef(1, null, "reference")); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllContentsByRef(1, "path", null)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllContentsByRef(1, null)); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllContentsByRef("", "name", "ref")); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllContentsByRef("owner", "", "ref")); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllContentsByRef("owner", "name", "")); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllContentsByRef("", "name", "path", "reference")); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllContentsByRef("owner", "", "path", "reference")); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllContentsByRef("owner", "name", "", "reference")); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllContentsByRef("owner", "name", "path", "")); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllContentsByRef(1, "", "reference")); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllContentsByRef(1, "path", "")); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllContentsByRef(1, "")); }