Пример #1
0
        public async Task Update_File_Normal_Case()
        {
            var ExpectedCommitName  = "Tsuyoshi Ushio";
            var ExpectedCommitEmail = "*****@*****.**";

            using (var session = new CommitSession(ExpectedCommitName, ExpectedCommitEmail))
            {
                var InputPath            = "foo";
                var InputText            = "konnichiwa.";
                var ExpectedTargetBranch = "foo-ja";
                var ExpectedSha          = "quux";
                var InputLanguage        = "ja";
                var fixture = new GitHubFixture();
                fixture.SetupUpdateFileContents(fixture.InputOwner, fixture.InputRepo, InputPath);
                // public async Task UpdateFileContentsAsync(string owner, string repo, string path, string branch, string text, string sha, string language)
                var service = new GitHubService(fixture.GitHubRepository);
                await service.UpdateFileContentsAsync(fixture.InputOwner, fixture.InputRepo, InputPath,
                                                      ExpectedTargetBranch, InputText, ExpectedSha, InputLanguage);

                var operation = fixture.ActualFileOperation;
                Assert.Equal($"Generate {InputLanguage} version", operation.message);
                Assert.Equal(ExpectedCommitName, operation.commiter.name);
                Assert.Equal(ExpectedCommitEmail, operation.commiter.email);
                Assert.Equal(ExpectedTargetBranch, operation.branch);
                Assert.Equal(ExpectedSha, operation.sha);
                Assert.Equal(Convert.ToBase64String(Encoding.UTF8.GetBytes(InputText)), operation.content);
            }
        }
Пример #2
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);
        }