Initial commit: SpdUp Windows Gaming Booster v1.0.0
- .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
This commit is contained in:
@@ -0,0 +1,157 @@
|
||||
using System.Collections.Specialized;
|
||||
using SpdUp.Core;
|
||||
using SpdUp.ViewModels;
|
||||
|
||||
namespace SpdUp.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// Tests for DebugLogViewModel.
|
||||
/// Uses a helper to run on STA thread for WPF Dispatcher compatibility.
|
||||
/// </summary>
|
||||
public class DebugLogViewModelTests
|
||||
{
|
||||
private static void RunOnSta(Action action)
|
||||
{
|
||||
Exception? caught = null;
|
||||
var thread = new Thread(() =>
|
||||
{
|
||||
try { action(); }
|
||||
catch (Exception ex) { caught = ex; }
|
||||
});
|
||||
thread.SetApartmentState(ApartmentState.STA);
|
||||
thread.Start();
|
||||
thread.Join();
|
||||
if (caught is not null)
|
||||
throw new Xunit.Sdk.XunitException($"STA test failed: {caught.Message}", caught);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Initial_LogLines_IsEmpty()
|
||||
{
|
||||
RunOnSta(() =>
|
||||
{
|
||||
var vm = new DebugLogViewModel();
|
||||
Assert.Empty(vm.LogLines);
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AutoScroll_DefaultTrue()
|
||||
{
|
||||
RunOnSta(() =>
|
||||
{
|
||||
var vm = new DebugLogViewModel();
|
||||
Assert.True(vm.AutoScroll);
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AutoScroll_Settable()
|
||||
{
|
||||
RunOnSta(() =>
|
||||
{
|
||||
var vm = new DebugLogViewModel();
|
||||
vm.AutoScroll = false;
|
||||
Assert.False(vm.AutoScroll);
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FilterText_DefaultEmpty()
|
||||
{
|
||||
RunOnSta(() =>
|
||||
{
|
||||
var vm = new DebugLogViewModel();
|
||||
Assert.Equal(string.Empty, vm.FilterText);
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FilterText_RaisesPropertyChanged()
|
||||
{
|
||||
RunOnSta(() =>
|
||||
{
|
||||
var vm = new DebugLogViewModel();
|
||||
var changed = new List<string>();
|
||||
vm.PropertyChanged += (_, e) => changed.Add(e.PropertyName!);
|
||||
|
||||
vm.FilterText = "error";
|
||||
|
||||
Assert.Contains("FilterText", changed);
|
||||
Assert.Contains("FilteredLogLines", changed);
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ClearCommand_ClearsLogLines()
|
||||
{
|
||||
RunOnSta(() =>
|
||||
{
|
||||
var vm = new DebugLogViewModel();
|
||||
vm.LogLines.Add("test line 1");
|
||||
vm.LogLines.Add("test line 2");
|
||||
|
||||
vm.ClearCommand.Execute(null);
|
||||
|
||||
Assert.Empty(vm.LogLines);
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FilteredLogLines_NoFilter_ReturnsAll()
|
||||
{
|
||||
RunOnSta(() =>
|
||||
{
|
||||
var vm = new DebugLogViewModel();
|
||||
vm.LogLines.Add("[INFO] started");
|
||||
vm.LogLines.Add("[ERROR] failed");
|
||||
vm.LogLines.Add("[WARN] low memory");
|
||||
|
||||
var filtered = vm.FilteredLogLines.ToList();
|
||||
Assert.Equal(3, filtered.Count);
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FilteredLogLines_WithFilter_ReturnsMatches()
|
||||
{
|
||||
RunOnSta(() =>
|
||||
{
|
||||
var vm = new DebugLogViewModel();
|
||||
vm.LogLines.Add("[INFO] started");
|
||||
vm.LogLines.Add("[ERROR] something failed");
|
||||
vm.LogLines.Add("[WARN] low memory");
|
||||
|
||||
vm.FilterText = "error";
|
||||
|
||||
var filtered = vm.FilteredLogLines.ToList();
|
||||
Assert.Single(filtered);
|
||||
Assert.Contains("ERROR", filtered[0]);
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FilteredLogLines_CaseInsensitive()
|
||||
{
|
||||
RunOnSta(() =>
|
||||
{
|
||||
var vm = new DebugLogViewModel();
|
||||
vm.LogLines.Add("[INFO] Test Message");
|
||||
|
||||
vm.FilterText = "test message";
|
||||
|
||||
Assert.Single(vm.FilteredLogLines);
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Commands_AreNotNull()
|
||||
{
|
||||
RunOnSta(() =>
|
||||
{
|
||||
var vm = new DebugLogViewModel();
|
||||
Assert.NotNull(vm.ClearCommand);
|
||||
Assert.NotNull(vm.CopyAllCommand);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user