public UseCredentials ( GitHubCredentials credentials ) : void | ||
credentials | GitHubCredentials | |
return | void |
public void WillBeSentWithAppliedCredentials() { var gitHubSender = new MockGitHubSender(); var uploads = new UploadsGists { GitHubSender = gitHubSender }; var credentials = new GitHubUserCredentials("something", "secret"); uploads.UseCredentials(credentials); uploads.Upload("file4.cs", "gee wizz"); gitHubSender.LastCredentialsApplied.Should().Equal(credentials); }
/// <summary> /// This function is the callback used to execute a command when the a menu item is clicked. /// See the Initialize method to see how the menu item is associated to this function using /// the OleMenuCommandService service and the MenuCommand class. /// </summary> private void CreateGist(object sender, EventArgs e) { var view = GetActiveTextView(); if (NotReadyRockAndRoll(view)) return; var content = GetCurrentContentForGist(view); var fileName = GetCurrentFilenameForGist(); var credentials = GetGitHubCredentials(); NotifyUserThat("Creating gist for {0}", fileName); if (credentials == GitHubCredentials.Anonymous) { NotifyUserThat("Cancelled Gist"); return; } var uploadsGists = new UploadsGists { GitHubSender = new HttpGitHubSender(), CredentialsAreBad = () => { NotifyUserThat("Gist not created. Invalid GitHub Credentials"); new CachesGitHubCredentials().AssureNotCached(); }, Uploaded = url => { Clipboard.SetText(url); new CachesGitHubCredentials().Cache(credentials); NotifyUserThat("Gist created successfully. Url placed in the clipboard."); } }; uploadsGists.UseCredentials(credentials); uploadsGists.Upload(fileName, content); }