public void UploadTheGistToGitHub() { var gitHubSender = new MockGitHubSender(); var gistApi = new UploadsGists { GitHubSender = gitHubSender }; gistApi.Upload("file3.cs", "My oh my"); gitHubSender.SentAGist.Should().Be.True(); }
public void GistUrlWillBeAvaible() { string actualUrl = null; var gitHubSender = new MockGitHubSender() { ResultingUrl = "http://gist.github.com/123" }; var gistApi = new UploadsGists { GitHubSender = gitHubSender }; gistApi.Uploaded = url => actualUrl = url; gistApi.Upload("file3.cs", "My oh my"); actualUrl.Should().Equal("http://gist.github.com/123"); }
public void CompleteOccursAtTheEnd() { var wasSuccessful = false; var uploads = new UploadsGists(); uploads.Uploaded = url => wasSuccessful = true; uploads.Upload("asdf", "qwer"); wasSuccessful.Should().Be.True(); }
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); }
public void WillAllowUsToGetInvolvedWhenCredentialsAreBad() { var sender = new MockGitHubSender(); sender.FailWith("Blah"); var uploads = new UploadsGists(); uploads.GitHubSender = sender; var didTellUs = false; uploads.CredentialsAreBad = () => didTellUs = true; uploads.Upload("asdf", "asdF"); didTellUs.Should().Be.True(); }
/// <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); }