-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Delete Moq and replace the Mocks with our own (#220)
* Delete Moq and replace the Mocks with our own * Update out of date documentation and give more examples * dotnet format
- Loading branch information
1 parent
576f119
commit 54cf525
Showing
25 changed files
with
344 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
// Global using directives | ||
|
||
global using System; | ||
global using FluentAssertions; | ||
global using Xunit; | ||
global using Moq; | ||
global using Xunit; |
13 changes: 13 additions & 0 deletions
13
UnitystationLauncher.Tests/MocksRepository/BlogService/MockBlogPostsThrowException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System.Collections.Generic; | ||
using UnitystationLauncher.Models.Api.Changelog; | ||
using UnitystationLauncher.Services.Interface; | ||
|
||
namespace UnitystationLauncher.Tests.MocksRepository.BlogService; | ||
|
||
public class MockBlogPostsThrowException : IBlogService | ||
{ | ||
public List<BlogPost> GetBlogPosts(int count) | ||
{ | ||
throw new(); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
UnitystationLauncher.Tests/MocksRepository/BlogService/MockNormalBlogPosts.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System.Collections.Generic; | ||
using UnitystationLauncher.Models.Api.Changelog; | ||
using UnitystationLauncher.Services.Interface; | ||
|
||
namespace UnitystationLauncher.Tests.MocksRepository.BlogService; | ||
|
||
public class MockNormalBlogPosts : IBlogService | ||
{ | ||
public List<BlogPost> GetBlogPosts(int count) | ||
{ | ||
List<BlogPost> blogPosts = new(); | ||
|
||
for (int i = 0; i < count; i++) | ||
{ | ||
blogPosts.Add(new() | ||
{ | ||
Title = $"Test {i}", | ||
Slug = $"test-{i}", | ||
ImageUrl = $"test-{i}.png" | ||
}); | ||
} | ||
|
||
return blogPosts; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
UnitystationLauncher.Tests/MocksRepository/EnvironmentService/MockLinuxFlatpakEnvironment.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System.Diagnostics; | ||
using UnitystationLauncher.Models.Enums; | ||
using UnitystationLauncher.Services.Interface; | ||
|
||
namespace UnitystationLauncher.Tests.MocksRepository.EnvironmentService; | ||
|
||
public class MockLinuxFlatpakEnvironment : IEnvironmentService | ||
{ | ||
public CurrentEnvironment GetCurrentEnvironment() | ||
{ | ||
return CurrentEnvironment.LinuxFlatpak; | ||
} | ||
|
||
public string GetUserdataDirectory() | ||
{ | ||
return "/home/unitTester/UnitystationLauncher"; | ||
} | ||
|
||
public bool ShouldDisableUpdateCheck() | ||
{ | ||
return true; | ||
} | ||
|
||
public ProcessStartInfo? GetGameProcessStartInfo(string executable, string arguments) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...tationLauncher.Tests/MocksRepository/EnvironmentService/MockLinuxStandaloneEnvironment.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System.Diagnostics; | ||
using UnitystationLauncher.Models.Enums; | ||
using UnitystationLauncher.Services.Interface; | ||
|
||
namespace UnitystationLauncher.Tests.MocksRepository.EnvironmentService; | ||
|
||
public class MockLinuxStandaloneEnvironment : IEnvironmentService | ||
{ | ||
public CurrentEnvironment GetCurrentEnvironment() | ||
{ | ||
return CurrentEnvironment.LinuxStandalone; | ||
} | ||
|
||
public string GetUserdataDirectory() | ||
{ | ||
return "/home/unitTester/UnitystationLauncher"; | ||
} | ||
|
||
public bool ShouldDisableUpdateCheck() | ||
{ | ||
return false; | ||
} | ||
|
||
public ProcessStartInfo? GetGameProcessStartInfo(string executable, string arguments) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...tationLauncher.Tests/MocksRepository/EnvironmentService/MockMacOsStandaloneEnvironment.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System.Diagnostics; | ||
using UnitystationLauncher.Models.Enums; | ||
using UnitystationLauncher.Services.Interface; | ||
|
||
namespace UnitystationLauncher.Tests.MocksRepository.EnvironmentService; | ||
|
||
public class MockMacOsStandaloneEnvironment : IEnvironmentService | ||
{ | ||
public CurrentEnvironment GetCurrentEnvironment() | ||
{ | ||
return CurrentEnvironment.MacOsStandalone; | ||
} | ||
|
||
public string GetUserdataDirectory() | ||
{ | ||
return "/home/unitTester/UnitystationLauncher"; | ||
} | ||
|
||
public bool ShouldDisableUpdateCheck() | ||
{ | ||
return false; | ||
} | ||
|
||
public ProcessStartInfo? GetGameProcessStartInfo(string executable, string arguments) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...tionLauncher.Tests/MocksRepository/EnvironmentService/MockWindowsStandaloneEnvironment.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System.Diagnostics; | ||
using UnitystationLauncher.Models.Enums; | ||
using UnitystationLauncher.Services.Interface; | ||
|
||
namespace UnitystationLauncher.Tests.MocksRepository.EnvironmentService; | ||
|
||
public class MockWindowsStandaloneEnvironment : IEnvironmentService | ||
{ | ||
public CurrentEnvironment GetCurrentEnvironment() | ||
{ | ||
return CurrentEnvironment.WindowsStandalone; | ||
} | ||
|
||
public string GetUserdataDirectory() | ||
{ | ||
return "C:/Users/UnitTester/UnitystationLauncher"; | ||
} | ||
|
||
public bool ShouldDisableUpdateCheck() | ||
{ | ||
return false; | ||
} | ||
|
||
public ProcessStartInfo? GetGameProcessStartInfo(string executable, string arguments) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
UnitystationLauncher.Tests/MocksRepository/InstallationService/MockNoActiveDownloads.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using System.Collections.Generic; | ||
using UnitystationLauncher.Models; | ||
using UnitystationLauncher.Models.Api; | ||
using UnitystationLauncher.Services.Interface; | ||
|
||
namespace UnitystationLauncher.Tests.MocksRepository.InstallationService; | ||
|
||
public class MockNoActiveDownloads : IInstallationService | ||
Check failure on line 8 in UnitystationLauncher.Tests/MocksRepository/InstallationService/MockNoActiveDownloads.cs GitHub Actions / test
|
||
{ | ||
public List<Installation> GetInstallations() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Installation? GetInstallation(string forkName, int buildVersion) | ||
{ | ||
return null; | ||
} | ||
|
||
public Download? GetInProgressDownload(string forkName, int buildVersion) | ||
{ | ||
return null; | ||
} | ||
|
||
public (Download?, string) DownloadInstallation(Server server) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public (bool, string) StartInstallation(Guid installationId, string? server = null, short? port = null) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public (bool, string) DeleteInstallation(Guid installationId) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public (bool, string) CleanupOldVersions(bool isAutoRemoveAction) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public bool MoveInstallations(string newBasePath) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public (bool, string) IsValidInstallationBasePath(string path) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} |
37 changes: 0 additions & 37 deletions
37
UnitystationLauncher.Tests/MocksRepository/MockBlogService.cs
This file was deleted.
Oops, something went wrong.
55 changes: 0 additions & 55 deletions
55
UnitystationLauncher.Tests/MocksRepository/MockEnvironmentService.cs
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
UnitystationLauncher.Tests/MocksRepository/MockInstallationService.cs
This file was deleted.
Oops, something went wrong.
32 changes: 0 additions & 32 deletions
32
UnitystationLauncher.Tests/MocksRepository/MockPingService.cs
This file was deleted.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
UnitystationLauncher.Tests/MocksRepository/PingService/MockPingReturnsNull.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System.Threading.Tasks; | ||
using UnitystationLauncher.Models.Api; | ||
using UnitystationLauncher.Services.Interface; | ||
|
||
namespace UnitystationLauncher.Tests.MocksRepository.PingService; | ||
|
||
public class MockPingReturnsNull : IPingService | ||
{ | ||
public Task<string> GetPing(Server server) | ||
{ | ||
return Task.FromResult(null as string)!; | ||
} | ||
} |
Oops, something went wrong.