Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete Moq and replace the Mocks with our own #220

Merged
merged 3 commits into from
Nov 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions UnitystationLauncher.Tests/GlobalUsings.cs
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;
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();
}
}
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;
}
}
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();
}
}
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();
}
}
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();
}
}
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();
}
}
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
{
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 UnitystationLauncher.Tests/MocksRepository/MockBlogService.cs

This file was deleted.

This file was deleted.

This file was deleted.

32 changes: 0 additions & 32 deletions UnitystationLauncher.Tests/MocksRepository/MockPingService.cs

This file was deleted.

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)!;
}
}
Loading