From bef3c844d86bb37add4f822e270d6a645afb88de Mon Sep 17 00:00:00 2001 From: Roberto <107645954+intcooper@users.noreply.github.com> Date: Mon, 20 May 2024 17:56:59 +0200 Subject: [PATCH] Bug fix: the main window was not automatically opened on the first start. Clean up setup script. --- .github/workflows/create-release.yml | 4 ---- MMExNotifier.Tests/MainViewModelTests.cs | 5 ++++- MMExNotifier/Setup.iss | 6 +----- MMExNotifier/ViewModels/MainViewModel.cs | 3 +++ 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 632dd1c..a424e62 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -75,10 +75,6 @@ jobs: - name: Setup MSBuild.exe uses: microsoft/setup-msbuild@v2 - # Execute all unit tests in the solution - - name: Execute unit tests - run: dotnet test - # Restore the application to populate the obj folder with RuntimeIdentifiers - name: Restore the application run: msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration diff --git a/MMExNotifier.Tests/MainViewModelTests.cs b/MMExNotifier.Tests/MainViewModelTests.cs index d46e953..362b28b 100644 --- a/MMExNotifier.Tests/MainViewModelTests.cs +++ b/MMExNotifier.Tests/MainViewModelTests.cs @@ -27,15 +27,18 @@ public void Setup() } [Test] - public void WhenDatabasePathIsNotConfigured_ShouldNotAttemptOpenDatabase() + public void WhenDatabasePathIsNotConfigured_ShouldRaiseOpen() { mockAppConfiguration.Setup(x => x.MMExDatabasePath).Returns(string.Empty); mockDatabaseService.Setup(x => x.ExpiringBills).Returns(() => null); var mainViewModel = new MainViewModel(mockAppConfiguration.Object, mockNotificationService.Object, mockDatabaseService.Object); + var openInvoked = false; + mainViewModel.OnOpen += (s, e) => { openInvoked = true; }; mainViewModel.Activate(); Assert.That(mockDatabaseService.Invocations, Is.Empty); + Assert.That(openInvoked, Is.True); } [Test] diff --git a/MMExNotifier/Setup.iss b/MMExNotifier/Setup.iss index 56e4378..6ac61b0 100644 --- a/MMExNotifier/Setup.iss +++ b/MMExNotifier/Setup.iss @@ -45,9 +45,6 @@ Name: "{app}\runtimes" [Files] Source: "{#FindFolder("bin\Release\net6.0-*")}\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion -Source: "{#FindFolder("bin\Release\net6.0-*")}\EntityFramework.dll"; DestDir: "{app}"; Flags: ignoreversion -Source: "{#FindFolder("bin\Release\net6.0-*")}\EntityFramework.SqlServer.dll"; DestDir: "{app}"; Flags: ignoreversion -Source: "{#FindFolder("bin\Release\net6.0-*")}\Hardcodet.NotifyIcon.Wpf.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "{#FindFolder("bin\Release\net6.0-*")}\linq2db.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "{#FindFolder("bin\Release\net6.0-*")}\Microsoft.Toolkit.Uwp.Notifications.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "{#FindFolder("bin\Release\net6.0-*")}\Microsoft.Win32.TaskScheduler.dll"; DestDir: "{app}"; Flags: ignoreversion @@ -57,10 +54,9 @@ Source: "{#FindFolder("bin\Release\net6.0-*")}\MMExNotifier.dll"; DestDir: "{app Source: "{#FindFolder("bin\Release\net6.0-*")}\MMExNotifier.dll.config"; DestDir: "{app}"; Flags: ignoreversion Source: "{#FindFolder("bin\Release\net6.0-*")}\MMExNotifier.pdb"; DestDir: "{app}"; Flags: ignoreversion Source: "{#FindFolder("bin\Release\net6.0-*")}\MMExNotifier.runtimeconfig.json"; DestDir: "{app}"; Flags: ignoreversion -Source: "{#FindFolder("bin\Release\net6.0-*")}\System.Data.SqlClient.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "{#FindFolder("bin\Release\net6.0-*")}\System.Data.SQLite.dll"; DestDir: "{app}"; Flags: ignoreversion -Source: "{#FindFolder("bin\Release\net6.0-*")}\System.Data.SQLite.EF6.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "{#FindFolder("bin\Release\net6.0-*")}\WinRT.Runtime.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "{#FindFolder("bin\Release\net6.0-*")}\Wpf.Ui.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "{#FindFolder("bin\Release\net6.0-*")}\runtimes\*"; DestDir: "{app}\runtimes"; Flags: recursesubdirs Source: "LICENSE.txt"; DestDir: "{app}"; Flags: ignoreversion ; NOTE: Don't use "Flags: ignoreversion" on any shared system files diff --git a/MMExNotifier/ViewModels/MainViewModel.cs b/MMExNotifier/ViewModels/MainViewModel.cs index 4961f93..cc5a351 100644 --- a/MMExNotifier/ViewModels/MainViewModel.cs +++ b/MMExNotifier/ViewModels/MainViewModel.cs @@ -29,7 +29,10 @@ public MainViewModel(IAppConfiguration appSettings, INotificationService notific public override void Activate() { if (string.IsNullOrEmpty(AppSettings.MMExDatabasePath)) + { + Open(); return; + } LoadExpiringBills();