- .NET 8 WPF app with full MVVM architecture - One-click boost: CPU, RAM, GPU, network, services, timer resolution - Real-time system monitor (LibreHardwareMonitor) - Auto game detection (30+ games) - RAM optimizer with kernel-level cleanup - Network optimizer (TCP registry tweaks) - Service manager, process manager, shader cache cleaner - Desktop widget overlay - Debug log viewer - Custom dark gaming theme with trans pride colors - 84 unit tests (xUnit) - Inno Setup installer script - Landing page website
225 lines
6.9 KiB
C#
225 lines
6.9 KiB
C#
using SpdUp.Models;
|
|
|
|
namespace SpdUp.Tests;
|
|
|
|
/// <summary>
|
|
/// Tests for the model classes.
|
|
/// </summary>
|
|
public class ModelTests
|
|
{
|
|
// ── SystemMetrics ────────────────────────────────────────
|
|
|
|
[Fact]
|
|
public void SystemMetrics_RamUsagePercent_CalculatesCorrectly()
|
|
{
|
|
var m = new SystemMetrics { RamUsageMB = 8000, RamTotalMB = 16000 };
|
|
Assert.Equal(50f, m.RamUsagePercent);
|
|
}
|
|
|
|
[Fact]
|
|
public void SystemMetrics_RamUsagePercent_ZeroTotal_ReturnsZero()
|
|
{
|
|
var m = new SystemMetrics { RamUsageMB = 100, RamTotalMB = 0 };
|
|
Assert.Equal(0f, m.RamUsagePercent);
|
|
}
|
|
|
|
[Fact]
|
|
public void SystemMetrics_RamUsagePercent_FullRam()
|
|
{
|
|
var m = new SystemMetrics { RamUsageMB = 16000, RamTotalMB = 16000 };
|
|
Assert.Equal(100f, m.RamUsagePercent);
|
|
}
|
|
|
|
[Fact]
|
|
public void SystemMetrics_DefaultTimestamp_IsNow()
|
|
{
|
|
var before = DateTime.Now.AddSeconds(-1);
|
|
var m = new SystemMetrics();
|
|
var after = DateTime.Now.AddSeconds(1);
|
|
|
|
Assert.InRange(m.Timestamp, before, after);
|
|
}
|
|
|
|
// ── GameEntry ────────────────────────────────────────────
|
|
|
|
[Fact]
|
|
public void GameEntry_ProcessNameFromPath_ExtractsFileName()
|
|
{
|
|
var result = GameEntry.ProcessNameFromPath(@"C:\Games\Cyberpunk2077\bin\Cyberpunk2077.exe");
|
|
Assert.Equal("Cyberpunk2077", result);
|
|
}
|
|
|
|
[Fact]
|
|
public void GameEntry_ProcessNameFromPath_HandlesForwardSlashes()
|
|
{
|
|
var result = GameEntry.ProcessNameFromPath("C:/Games/Game.exe");
|
|
Assert.Equal("Game", result);
|
|
}
|
|
|
|
[Fact]
|
|
public void GameEntry_ProcessNameFromPath_JustFileName()
|
|
{
|
|
var result = GameEntry.ProcessNameFromPath("myapp.exe");
|
|
Assert.Equal("myapp", result);
|
|
}
|
|
|
|
[Fact]
|
|
public void GameEntry_DefaultValues()
|
|
{
|
|
var g = new GameEntry();
|
|
Assert.Equal(string.Empty, g.Name);
|
|
Assert.Equal(string.Empty, g.ExecutablePath);
|
|
Assert.Equal("Manual", g.LauncherSource);
|
|
Assert.True(g.AutoBoost);
|
|
Assert.Null(g.IconPath);
|
|
}
|
|
|
|
[Fact]
|
|
public void BoostProfile_DefaultValues()
|
|
{
|
|
var p = new BoostProfile();
|
|
Assert.True(p.CleanRam);
|
|
Assert.True(p.SetHighPriority);
|
|
Assert.True(p.ReduceTimerResolution);
|
|
Assert.True(p.StopServices);
|
|
Assert.False(p.OptimizeNetwork);
|
|
}
|
|
|
|
// ── ProcessEntry ─────────────────────────────────────────
|
|
|
|
[Fact]
|
|
public void ProcessEntry_Properties()
|
|
{
|
|
var p = new ProcessEntry
|
|
{
|
|
Pid = 1234,
|
|
Name = "chrome",
|
|
WindowTitle = "Google Chrome",
|
|
CpuPercent = 12.5f,
|
|
MemoryMB = 350f,
|
|
PriorityClass = "High",
|
|
IsSystem = false
|
|
};
|
|
|
|
Assert.Equal(1234, p.Pid);
|
|
Assert.Equal("chrome", p.Name);
|
|
Assert.Equal("Google Chrome", p.WindowTitle);
|
|
Assert.Equal(12.5f, p.CpuPercent);
|
|
Assert.Equal(350f, p.MemoryMB);
|
|
Assert.Equal("High", p.PriorityClass);
|
|
Assert.False(p.IsSystem);
|
|
}
|
|
|
|
[Fact]
|
|
public void ProcessEntry_DefaultPriority_IsNormal()
|
|
{
|
|
var p = new ProcessEntry { Pid = 1, Name = "test" };
|
|
Assert.Equal("Normal", p.PriorityClass);
|
|
}
|
|
|
|
// ── ServiceEntry ─────────────────────────────────────────
|
|
|
|
[Fact]
|
|
public void ServiceEntry_DefaultStatus_IsUnknown()
|
|
{
|
|
var s = new ServiceEntry();
|
|
Assert.Equal("Unknown", s.Status);
|
|
Assert.False(s.WasRunningBeforeBoost);
|
|
}
|
|
|
|
[Fact]
|
|
public void ServiceEntry_Properties()
|
|
{
|
|
var s = new ServiceEntry
|
|
{
|
|
ServiceName = "WSearch",
|
|
DisplayName = "Windows Search",
|
|
Status = "Running",
|
|
WasRunningBeforeBoost = true,
|
|
Description = "Full-text search"
|
|
};
|
|
|
|
Assert.Equal("WSearch", s.ServiceName);
|
|
Assert.Equal("Windows Search", s.DisplayName);
|
|
Assert.Equal("Running", s.Status);
|
|
Assert.True(s.WasRunningBeforeBoost);
|
|
}
|
|
|
|
// ── AppSettings ──────────────────────────────────────────
|
|
|
|
[Fact]
|
|
public void AppSettings_DefaultValues()
|
|
{
|
|
var s = new AppSettings();
|
|
Assert.True(s.MinimizeToTray);
|
|
Assert.False(s.StartWithWindows);
|
|
Assert.True(s.AutoDetectGames);
|
|
Assert.True(s.AutoBoostOnGameLaunch);
|
|
Assert.False(s.ShowWidget);
|
|
Assert.Equal("8.8.8.8", s.PingTarget);
|
|
Assert.Equal("1.1.1.1", s.PreferredDns);
|
|
Assert.Equal(1000, s.MonitoringIntervalMs);
|
|
Assert.Contains("SysMain", s.ServicesToStop);
|
|
Assert.Contains("WSearch", s.ServicesToStop);
|
|
}
|
|
|
|
[Fact]
|
|
public void AppSettings_WidgetDefaults()
|
|
{
|
|
var s = new AppSettings();
|
|
Assert.True(s.WidgetCompactMode);
|
|
Assert.Equal(100, s.WidgetLeft);
|
|
Assert.Equal(100, s.WidgetTop);
|
|
Assert.Equal(0.85, s.WidgetOpacity);
|
|
Assert.Equal(1000, s.WidgetUpdateIntervalMs);
|
|
Assert.False(s.WidgetClickThrough);
|
|
}
|
|
|
|
// ── ShaderCleanResult ────────────────────────────────────
|
|
|
|
[Fact]
|
|
public void ShaderCleanResult_MBFreed_Calculation()
|
|
{
|
|
var r = new SpdUp.Services.ShaderCleanResult(10, 10_485_760); // 10 MB
|
|
Assert.Equal(10.0, r.MBFreed, 1);
|
|
}
|
|
|
|
[Fact]
|
|
public void ShaderCleanResult_ZeroBytes()
|
|
{
|
|
var r = new SpdUp.Services.ShaderCleanResult(0, 0);
|
|
Assert.Equal(0.0, r.MBFreed);
|
|
Assert.Equal(0, r.FilesDeleted);
|
|
}
|
|
|
|
// ── RamCleanupResult ─────────────────────────────────────
|
|
|
|
[Fact]
|
|
public void RamCleanupResult_RecordWithSyntax()
|
|
{
|
|
var r = new SpdUp.Services.RamCleanupResult(50, 5, 0);
|
|
var r2 = r with { StandbyPurged = 1 };
|
|
|
|
Assert.Equal(50, r2.TrimmedCount);
|
|
Assert.Equal(5, r2.FailedCount);
|
|
Assert.Equal(1, r2.StandbyPurged);
|
|
}
|
|
|
|
// ── BoostResult ──────────────────────────────────────────
|
|
|
|
[Fact]
|
|
public void BoostResult_Properties()
|
|
{
|
|
var r = new SpdUp.Services.BoostResult(true, "Boost activated");
|
|
Assert.True(r.Success);
|
|
Assert.Equal("Boost activated", r.Message);
|
|
}
|
|
|
|
[Fact]
|
|
public void BoostResult_Failure()
|
|
{
|
|
var r = new SpdUp.Services.BoostResult(false, "Error occurred");
|
|
Assert.False(r.Success);
|
|
}
|
|
}
|