tests(git-provider): Add basic registration tests
- make ModuleCore internals visible to ModuleTests
This commit is contained in:
parent
b9f856e716
commit
09236e826a
7 changed files with 135 additions and 38 deletions
36
tests/ModuleTests/Git/AddRegistrationTests.cs
Normal file
36
tests/ModuleTests/Git/AddRegistrationTests.cs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
using System.Text;
|
||||
using ModuleCore.Calendar;
|
||||
using ModuleCore.Git;
|
||||
using ModuleTests.Git.TestData;
|
||||
|
||||
namespace ModuleTests.Git;
|
||||
|
||||
public class AddRegistrationTests
|
||||
{
|
||||
private static readonly VerifySettings Settings;
|
||||
|
||||
static AddRegistrationTests()
|
||||
{
|
||||
Settings = new VerifySettings();
|
||||
var testBaseDirectory = Path.Join(TestConstants.SnapshotFolderName, nameof(AddRegistrationTests));
|
||||
|
||||
Settings.UseDirectory(testBaseDirectory);
|
||||
Settings.DisableDiff();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[ClassData(typeof(AddRegistrationTestData))]
|
||||
public Task BasicRepoRegistration((int testId, string path) testData)
|
||||
{
|
||||
Settings.UseFileName($"{nameof(BasicRepoRegistration)}_{testData.testId}");
|
||||
|
||||
var gitManager = GitManager.InternalFreshInstance;
|
||||
|
||||
var repoRegistration = gitManager.RegisterRepo("Test:/some/test/repo", testData.path);
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine($"Attempted to register: {testData.path}")
|
||||
.AppendLine($"Registration result: {repoRegistration}");
|
||||
|
||||
return Verify(sb, Settings);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
Attempted to register: test
|
||||
Registration result: test
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
Attempted to register: test\path
|
||||
Registration result: test\path
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
Attempted to register: other/path
|
||||
Registration result: other\path
|
||||
18
tests/ModuleTests/Git/TestData/AddRegistrationTestData.cs
Normal file
18
tests/ModuleTests/Git/TestData/AddRegistrationTestData.cs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
using System.Linq;
|
||||
|
||||
namespace ModuleTests.Git.TestData;
|
||||
|
||||
public class AddRegistrationTestData : TestDataEnumerator<(int testId, string path)>
|
||||
{
|
||||
public AddRegistrationTestData()
|
||||
{
|
||||
Data = new List<string>()
|
||||
{
|
||||
"test",
|
||||
$"test{Path.DirectorySeparatorChar}path",
|
||||
$"other{Path.AltDirectorySeparatorChar}path"
|
||||
}
|
||||
.Select((x, i) => (i, x))
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue