Exemplo n.º 1
0
        public async Task Update_FileContents_Normal()
        {
            var fixture = new GitHubFixture();

            fixture.SetUpSampleInputOperation();

            var ExpectedURL = $"https://api.github.com/repos/{fixture.InputOwner}/{fixture.InputRepo}/contents/{fixture.InputPath}";

            // On the Setup, I call Assert on the Callback.
            fixture.SetupUpdateFileContents(ExpectedURL, fixture.InputOperation);
            var repository = new GitHubRepository(fixture.GitHubContext);
            await repository.UpdateFileContents(fixture.InputOwner, fixture.InputRepo, fixture.InputPath,
                                                fixture.InputOperation);
        }
Exemplo n.º 2
0
        public async Task Update_FileContents_Exception()
        {
            var fixture = new GitHubFixture();

            fixture.SetUpSampleInputOperation();
            var ExpectedURL = $"https://api.github.com/repos/{fixture.InputOwner}/{fixture.InputRepo}/contents/{fixture.InputPath}";

            fixture.SetupUpdateFileContentsFailure(ExpectedURL, fixture.InputOperation);
            var repository = new GitHubRepository(fixture.GitHubContext);
            var ex         = await Assert.ThrowsAsync <RestAPICallException>(async() =>
                                                                             await repository.UpdateFileContents(fixture.InputOwner, fixture.InputRepo, fixture.InputPath,
                                                                                                                 fixture.InputOperation)
                                                                             );

            Assert.Equal("InternalServerError", ex.StatusCode);
            Assert.Equal("Internal Server Error", ex.Message);
            Assert.Equal(ExpectedURL, ex.RequestMessage.RequestUri.ToString());
        }