|
| 1 | +using System; |
| 2 | +using GitHub.Services; |
| 3 | +using LibGit2Sharp; |
| 4 | +using NSubstitute; |
| 5 | +using Xunit; |
| 6 | +using System.Linq; |
| 7 | +using System.Collections; |
| 8 | +using System.Collections.Generic; |
| 9 | + |
| 10 | +public class GitServiceTests : TestBaseClass |
| 11 | +{ |
| 12 | + [Theory] |
| 13 | + [InlineData("asdf", null)] |
| 14 | + [InlineData("", null)] |
| 15 | + [InlineData(null, null)] |
| 16 | + [InlineData("file:///C:/dev/exp/foo", "file:///C:/dev/exp/foo")] |
| 17 | + [InlineData("http://example.com/", "http://example.com/")] |
| 18 | + [InlineData("http://haacked@example.com/foo/bar", "http://example.com/foo/bar")] |
| 19 | + [InlineData("https://github.com/github/Windows", "https://github.com/github/Windows")] |
| 20 | + [InlineData("https://github.com/github/Windows.git", "https://github.com/github/Windows")] |
| 21 | + [InlineData("https://haacked@github.com/github/Windows.git", "https://github.com/github/Windows")] |
| 22 | + [InlineData("http://example.com:4000/github/Windows", "http://example.com:4000/github/Windows")] |
| 23 | + [InlineData("git@192.168.1.2:github/Windows.git", "https://192.168.1.2/github/Windows")] |
| 24 | + [InlineData("git@example.com:org/repo.git", "https://example.com/org/repo")] |
| 25 | + [InlineData("ssh://git@github.com:443/shana/cef", "https://github.com/shana/cef")] |
| 26 | + [InlineData("ssh://git@example.com:23/haacked/encourage", "https://example.com:23/haacked/encourage")] |
| 27 | + public void GetUriShouldNotThrow(string url, string expected) |
| 28 | + { |
| 29 | + var origin = Substitute.For<Remote>(); |
| 30 | + origin.Url.Returns(url); |
| 31 | + var repository = Substitute.For<IRepository>(); |
| 32 | + repository.Network.Remotes["origin"].Returns(origin); |
| 33 | + |
| 34 | + var gitservice = new GitService(); |
| 35 | + Assert.Equal(expected, gitservice.GetUri(repository)?.ToString()); |
| 36 | + } |
| 37 | +} |
0 commit comments