-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathVFSGitHubExtensionsTests.cs
More file actions
68 lines (57 loc) · 2.03 KB
/
VFSGitHubExtensionsTests.cs
File metadata and controls
68 lines (57 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright (c) 2022-2025, Atypical Consulting SRL
// All rights reserved... but seriously, we're open to sharing if you ask nicely!
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.
namespace VirtualFileSystem.GitHub.Tests;
public class VFSGitHubExtensionsTests
{
[Theory]
[InlineData("https://github.com/owner/repo", "owner", "repo")]
[InlineData("https://github.com/microsoft/dotnet", "microsoft", "dotnet")]
[InlineData("https://github.com/owner/repo.git", "owner", "repo")]
public void TryParseGitHubUrl_WithValidUrls_ShouldParse(string url, string expectedOwner, string expectedRepo)
{
// Act
var result = VFSGitHubExtensions.TryParseGitHubUrl(url, out var owner, out var repo);
// Assert
result.ShouldBeTrue();
owner.ShouldBe(expectedOwner);
repo.ShouldBe(expectedRepo);
}
[Theory]
[InlineData("https://gitlab.com/owner/repo")]
[InlineData("not-a-url")]
[InlineData("")]
public void TryParseGitHubUrl_WithInvalidUrls_ShouldReturnFalse(string url)
{
// Act
var result = VFSGitHubExtensions.TryParseGitHubUrl(url, out _, out _);
// Assert
result.ShouldBeFalse();
}
[Fact]
public async Task TryLoadGitHubRepositoryAsync_WithNonExistentRepo_ShouldReturnFalse()
{
// Arrange
var vfs = new VFS();
// Act
var (success, result) = await vfs.TryLoadGitHubRepositoryAsync(
"non-existent-owner-abc123",
"non-existent-repo-xyz789");
// Assert
success.ShouldBeFalse();
result.ShouldBeNull();
}
[Fact]
public async Task TryLoadGitHubRepositoryFromUrlAsync_WithInvalidUrl_ShouldReturnFalse()
{
// Arrange
var vfs = new VFS();
// Act
var (success, result) = await vfs.TryLoadGitHubRepositoryFromUrlAsync("not-a-valid-url");
// Assert
success.ShouldBeFalse();
result.ShouldBeNull();
}
}