33 lines
1.2 KiB
C#
Raw Normal View History

2023-08-25 19:09:36 -04:00
using SPTInstaller.CustomControls;
using SPTInstaller.Models;
using System.Threading.Tasks;
namespace SPTInstaller.Installer_Tasks.PreChecks;
2024-05-01 10:31:55 -04:00
2023-08-25 19:09:36 -04:00
public class TestPreCheck : PreCheckBase
{
private StatusSpinner.SpinnerState _endState;
2024-05-01 10:31:55 -04:00
public static TestPreCheck FromRandomName(StatusSpinner.SpinnerState EndState) => new TestPreCheck(
$"{EndState} #{new Random().Next(0, 9999)}", EndState == StatusSpinner.SpinnerState.Error, EndState);
2023-08-25 19:09:36 -04:00
public TestPreCheck(string name, bool isRequired, StatusSpinner.SpinnerState endState) : base(name, isRequired)
{
_endState = endState;
}
2024-05-01 10:31:55 -04:00
2023-08-25 19:09:36 -04:00
public override async Task<PreCheckResult> CheckOperation()
{
await Task.Delay(1000);
2024-05-01 10:31:55 -04:00
2023-08-25 19:09:36 -04:00
switch (_endState)
{
case StatusSpinner.SpinnerState.Error:
return PreCheckResult.FromError("This is what a required precheck failing looks like");
case StatusSpinner.SpinnerState.Warning:
return PreCheckResult.FromError("This is what a non-required precheck failing looks like");
default:
return PreCheckResult.FromSuccess("This is what a successful precheck looks like");
}
}
2024-05-01 10:31:55 -04:00
}