public async Task Search_MdFiles_Normal() { var InputOwner = "foo"; var InputRepo = "bar"; var InputSha = "baz"; var ExpectedURL = $"https://api.github.com/repos/{InputOwner}/{InputRepo}/git/trees/{InputSha}?recursive=1"; var fixture = new GitHubFixture(); var trees = new Tree[] { new Tree() { path = "abc.txt" }, new Tree() { path = "bcd.md" }, new Tree() { path = "cde.md" }, new Tree() { path = "def.lock" } }; var searchResult = new SearchResult(); searchResult.tree = trees; var treeJson = JsonConvert.SerializeObject(searchResult); fixture.SetupSearchMd(ExpectedURL, treeJson); var repository = new GitHubRepository(fixture.GitHubContext); var result = await repository.SearchMdFilesAsync(InputOwner, InputRepo, InputSha); Assert.Equal(2, result.Count()); var enumerator = result.GetEnumerator(); enumerator.MoveNext(); Assert.Equal("bcd.md", enumerator.Current.path); enumerator.MoveNext(); Assert.Equal("cde.md", enumerator.Current.path); }
public async Task Search_MdFiles_Exception() { var InputOwner = "foo"; var InputRepo = "bar"; var InputSha = "baz"; var ExpectedURL = $"https://api.github.com/repos/{InputOwner}/{InputRepo}/git/trees/{InputSha}?recursive=1"; var fixture = new GitHubFixture(); fixture.SetupSearchMdWithFailure(ExpectedURL); var repository = new GitHubRepository(fixture.GitHubContext); var ex = await Assert.ThrowsAsync <RestAPICallException>(async() => await repository.SearchMdFilesAsync(InputOwner, InputRepo, InputSha) ); Assert.Equal("InternalServerError", ex.StatusCode); Assert.Equal("Internal Server Error", ex.Message); Assert.Equal(ExpectedURL, ex.RequestMessage.RequestUri.ToString()); }