public async Task ReturnsRawContent() { var result = new byte[] { 1, 2, 3 }; var connection = Substitute.For <IApiConnection>(); connection.GetRaw(Args.Uri, default).Returns(result); var contentsClient = new RepositoryContentsClient(connection); var rawContent = await contentsClient.GetRawContent("fake", "repo", "path/to/file.txt"); connection.Received().GetRaw(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/contents/path/to/file.txt"), null); Assert.Same(result, rawContent); }
public async Task EnsuresNonNullArguments() { var connection = Substitute.For <IApiConnection>(); var client = new RepositoryContentsClient(connection); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetRawContent(null, "name", "path")); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetRawContent("owner", null, "path")); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetRawContent("owner", "name", null)); await Assert.ThrowsAsync <ArgumentException>(() => client.GetRawContent("", "name", "path")); await Assert.ThrowsAsync <ArgumentException>(() => client.GetRawContent("owner", "", "path")); await Assert.ThrowsAsync <ArgumentException>(() => client.GetRawContent("owner", "name", "")); }