public void SameContentEqualsTrue(string name1, string url1, string path1, string name2, string url2, string path2) { var a = new SimpleRepositoryModel(name1, new UriString(url1), path1); var b = new SimpleRepositoryModel(name2, new UriString(url2), path2); Assert.Equal(a, b); Assert.False(a == b); Assert.Equal(a.GetHashCode(), b.GetHashCode()); }
public void SameContentEqualsTrue(string name1, string url1, string path1, string name2, string url2, string path2) { var a = new SimpleRepositoryModel(name1, new UriString(url1), path1); var b = new SimpleRepositoryModel(name2, new UriString(url2), path2); Assert.Equal(a, b); Assert.False(a == b); Assert.Equal(a.GetHashCode(), b.GetHashCode()); }
public void WithRemoteUrl() { var provider = Substitutes.ServiceProvider; Services.PackageServiceProvider = provider; var gitservice = provider.GetGitService(); var repo = Substitute.For<IRepository>(); var path = Directory.CreateSubdirectory("repo-name"); gitservice.GetUri(path.FullName).Returns(new UriString("https://github.com/user/repo-name")); var model = new SimpleRepositoryModel(path.FullName); Assert.Equal("user/repo-name", model.Name); }
public void NoRemoteUrl() { var provider = Substitutes.ServiceProvider; Services.PackageServiceProvider = provider; var gitservice = Substitutes.IGitService; provider.GetService(typeof(IGitService)).Returns(gitservice); var repo = Substitute.For<IRepository>(); var path = Directory.CreateSubdirectory("repo-name"); gitservice.GetUri(path.FullName).Returns((UriString)null); var model = new SimpleRepositoryModel(path.FullName); Assert.Equal("repo-name", model.Name); }
public void NoRemoteUrl() { var provider = Substitutes.ServiceProvider; var gitservice = provider.GetGitService(); var repo = Substitute.For <IRepository>(); var path = Directory.CreateSubdirectory("repo-name"); gitservice.GetUri(path.FullName).Returns((UriString)null); var model = new SimpleRepositoryModel(path.FullName); Assert.Equal("repo-name", model.Name); }
public void WithRemoteUrl() { var provider = Substitutes.ServiceProvider; var gitservice = provider.GetGitService(); var repo = Substitute.For <IRepository>(); var path = Directory.CreateSubdirectory("repo-name"); gitservice.GetUri(path.FullName).Returns(new UriString("https://github.com/user/repo-name")); var model = new SimpleRepositoryModel(path.FullName); Assert.Equal("repo-name", model.Name); Assert.Equal("user", model.Owner); }
public void GenerateUrl(bool createRootedPath, string baseUrl, string sha, string path, int startLine, int endLine, string expected) { SetupRepository(sha); var basePath = Directory.CreateSubdirectory("generate-url-test1"); if (createRootedPath && path != null) path = System.IO.Path.Combine(basePath.FullName, path); ISimpleRepositoryModel model = null; if (!String.IsNullOrEmpty(baseUrl)) model = new SimpleRepositoryModel("bar", new UriString(baseUrl), basePath.FullName); else model = new SimpleRepositoryModel(basePath.FullName); var result = model.GenerateUrl(path, startLine, endLine); Assert.Equal(expected, result?.ToString()); }
public void CreatePullRequestAllArgsMandatory() { var serviceProvider = Substitutes.ServiceProvider; var service = new PullRequestService(Substitute.For <IGitClient>(), serviceProvider.GetGitService(), serviceProvider.GetOperatingSystem(), Substitute.For <IUsageTracker>()); IRepositoryHost host = null; ISimpleRepositoryModel sourceRepo = null; ISimpleRepositoryModel targetRepo = null; string title = null; string body = null; IBranch source = null; IBranch target = null; Assert.Throws <ArgumentNullException>(() => service.CreatePullRequest(host, sourceRepo, targetRepo, source, target, title, body)); host = serviceProvider.GetRepositoryHosts().GitHubHost; Assert.Throws <ArgumentNullException>(() => service.CreatePullRequest(host, sourceRepo, targetRepo, source, target, title, body)); sourceRepo = new SimpleRepositoryModel("name", new GitHub.Primitives.UriString("http://github.com/github/stuff")); Assert.Throws <ArgumentNullException>(() => service.CreatePullRequest(host, sourceRepo, targetRepo, source, target, title, body)); targetRepo = new SimpleRepositoryModel("name", new GitHub.Primitives.UriString("http://github.com/github/stuff")); Assert.Throws <ArgumentNullException>(() => service.CreatePullRequest(host, sourceRepo, targetRepo, source, target, title, body)); title = "a title"; Assert.Throws <ArgumentNullException>(() => service.CreatePullRequest(host, sourceRepo, targetRepo, source, target, title, body)); body = "a body"; Assert.Throws <ArgumentNullException>(() => service.CreatePullRequest(host, sourceRepo, targetRepo, source, target, title, body)); source = new BranchModel("source", sourceRepo); Assert.Throws <ArgumentNullException>(() => service.CreatePullRequest(host, sourceRepo, targetRepo, source, target, title, body)); target = new BranchModel("target", targetRepo); var pr = service.CreatePullRequest(host, sourceRepo, targetRepo, source, target, title, body); Assert.NotNull(pr); }
public void GenerateUrl(int testid, bool createRootedPath, string baseUrl, string sha, string path, int startLine, int endLine, string expected) { SetupRepository(sha); var basePath = Directory.CreateSubdirectory("generate-url-test1-" + testid); if (createRootedPath && path != null) { path = System.IO.Path.Combine(basePath.FullName, path); } ISimpleRepositoryModel model = null; if (!String.IsNullOrEmpty(baseUrl)) { model = new SimpleRepositoryModel("bar", new UriString(baseUrl), basePath.FullName); } else { model = new SimpleRepositoryModel(basePath.FullName); } var result = model.GenerateUrl(path, startLine, endLine); Assert.Equal(expected, result?.ToString()); }
public async Task <CodeContainer> AcquireCodeContainerAsync(RemoteCodeContainer onlineCodeContainer, IProgress <ServiceProgressData> downloadProgress, CancellationToken cancellationToken) { var repository = new SimpleRepositoryModel(UriString.ToUriString(onlineCodeContainer.DisplayUrl)); return(await RunAcquisition(downloadProgress, cancellationToken, repository)); }