-
-
Notifications
You must be signed in to change notification settings - Fork 2
fix: address 6 medium bugs (#311) #351
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| // SysManager · DuplicateFileGroupTests | ||
| // Author: laurentiu021 · https://github.com/laurentiu021/SystemManager | ||
| // License: MIT | ||
|
|
||
| using SysManager.Models; | ||
|
|
||
| namespace SysManager.Tests; | ||
|
|
||
| /// <summary> | ||
| /// Tests for <see cref="DuplicateFileGroup"/> model — validates WastedBytes | ||
| /// calculation and property change notifications. | ||
| /// </summary> | ||
| public class DuplicateFileGroupTests | ||
| { | ||
| [Fact] | ||
| public void WastedBytes_CalculatesCorrectly() | ||
| { | ||
| var group = new DuplicateFileGroup(); | ||
| group.FileSize = 1024; | ||
| group.Count = 3; | ||
| // Wasted = (3 - 1) * 1024 = 2048 | ||
| Assert.Equal(2048, group.WastedBytes); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void WastedBytes_ZeroWhenCountIsOne() | ||
| { | ||
| var group = new DuplicateFileGroup(); | ||
| group.FileSize = 5000; | ||
| group.Count = 1; | ||
| Assert.Equal(0, group.WastedBytes); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void WastedBytes_ZeroWhenCountIsZero() | ||
| { | ||
| var group = new DuplicateFileGroup(); | ||
| group.FileSize = 5000; | ||
| group.Count = 0; | ||
| Assert.Equal(0, group.WastedBytes); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void WastedBytes_NotifiesWhenFileSizeChanges() | ||
| { | ||
| var group = new DuplicateFileGroup(); | ||
| group.Count = 3; | ||
| var changed = new List<string>(); | ||
| group.PropertyChanged += (_, e) => changed.Add(e.PropertyName!); | ||
|
|
||
| group.FileSize = 2048; | ||
|
|
||
| Assert.Contains("WastedBytes", changed); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void WastedBytes_NotifiesWhenCountChanges() | ||
| { | ||
| var group = new DuplicateFileGroup(); | ||
| group.FileSize = 1024; | ||
| var changed = new List<string>(); | ||
| group.PropertyChanged += (_, e) => changed.Add(e.PropertyName!); | ||
|
|
||
| group.Count = 5; | ||
|
|
||
| Assert.Contains("WastedBytes", changed); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void Hash_PropertyNotifies() | ||
| { | ||
| var group = new DuplicateFileGroup(); | ||
| var changed = new List<string>(); | ||
| group.PropertyChanged += (_, e) => changed.Add(e.PropertyName!); | ||
|
|
||
| group.Hash = "abc123"; | ||
|
|
||
| Assert.Contains("Hash", changed); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void Files_Collection_IsInitialized() | ||
| { | ||
| var group = new DuplicateFileGroup(); | ||
| Assert.NotNull(group.Files); | ||
| Assert.Empty(group.Files); | ||
| } | ||
|
|
||
| // ── DuplicateFileEntry tests ── | ||
|
|
||
| [Fact] | ||
| public void DuplicateFileEntry_Properties_Notify() | ||
| { | ||
| var entry = new DuplicateFileEntry(); | ||
| var changed = new List<string>(); | ||
| entry.PropertyChanged += (_, e) => changed.Add(e.PropertyName!); | ||
|
|
||
| entry.Path = @"C:\test\file.txt"; | ||
| entry.Name = "file.txt"; | ||
| entry.SizeBytes = 4096; | ||
| entry.LastModified = DateTime.Now; | ||
| entry.IsSelected = true; | ||
|
|
||
| Assert.Contains("Path", changed); | ||
| Assert.Contains("Name", changed); | ||
| Assert.Contains("SizeBytes", changed); | ||
| Assert.Contains("LastModified", changed); | ||
| Assert.Contains("IsSelected", changed); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -74,7 +74,7 @@ private async Task AutoCheckOnStartAsync() | |
| private void RelaunchAsAdmin() | ||
| { | ||
| if (AdminHelper.RelaunchAsAdmin()) | ||
| System.Windows.Application.Current.Shutdown(); | ||
| System.Windows.Application.Current?.Shutdown(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Verify whether any non-null-safe shutdown calls still exist.
# Expected: no matches for direct Application.Current.Shutdown(...)
rg -nP --type=cs 'Application\.Current\.Shutdown\s*\('
rg -nP --type=cs 'Application\.Current\?\.\s*Shutdown\s*\('Repository: laurentiu021/SystemManager Length of output: 1498 Apply null-guards to all relaunch shutdown paths. Line 77 was fixed, but lines 114 and 350 in WindowsUpdateViewModel.cs still call
Apply the null-coalescing operator ( 🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| [RelayCommand] | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.