Index: Core/Gui/src/Core.Gui/Forms/Backstage/AboutViewModel.cs =================================================================== diff -u -r86dacf60005c631ea61dad7782e13644b57831c5 -r6f2f24378f372a8b22b5e5fa2b6987a804e3f7f6 --- Core/Gui/src/Core.Gui/Forms/Backstage/AboutViewModel.cs (.../AboutViewModel.cs) (revision 86dacf60005c631ea61dad7782e13644b57831c5) +++ Core/Gui/src/Core.Gui/Forms/Backstage/AboutViewModel.cs (.../AboutViewModel.cs) (revision 6f2f24378f372a8b22b5e5fa2b6987a804e3f7f6) @@ -35,8 +35,13 @@ /// /// Creates a new instance of . /// - public AboutViewModel() + /// The application name. + /// The application version. + public AboutViewModel(string applicationName, string version) { + ApplicationName = applicationName; + Version = version; + WindowsEdition = (string) GetOperatingSystemValue("Caption"); WindowsBuild = (string) GetOperatingSystemValue("BuildNumber"); Processor = (string) GetProcessorValue("Name"); @@ -45,12 +50,12 @@ /// /// Gets the application name. /// - public string ApplicationName => "Riskeer"; - + public string ApplicationName { get; } + /// /// Gets the application version. /// - public string Version => "21.2.1.1"; + public string Version { get; } /// /// Gets the Windows edition. Index: Core/Gui/src/Core.Gui/Forms/Backstage/BackstageControl.xaml.cs =================================================================== diff -u -rc30c93c3f77e0f07d0859c717c639329a63bd468 -r6f2f24378f372a8b22b5e5fa2b6987a804e3f7f6 --- Core/Gui/src/Core.Gui/Forms/Backstage/BackstageControl.xaml.cs (.../BackstageControl.xaml.cs) (revision c30c93c3f77e0f07d0859c717c639329a63bd468) +++ Core/Gui/src/Core.Gui/Forms/Backstage/BackstageControl.xaml.cs (.../BackstageControl.xaml.cs) (revision 6f2f24378f372a8b22b5e5fa2b6987a804e3f7f6) @@ -34,8 +34,6 @@ public BackstageControl() { InitializeComponent(); - - DataContext = new BackstageViewModel(); } } } \ No newline at end of file Index: Core/Gui/src/Core.Gui/Forms/Backstage/BackstageViewModel.cs =================================================================== diff -u -rb641495492850378ead7ce56a66c4b52c6e6041e -r6f2f24378f372a8b22b5e5fa2b6987a804e3f7f6 --- Core/Gui/src/Core.Gui/Forms/Backstage/BackstageViewModel.cs (.../BackstageViewModel.cs) (revision b641495492850378ead7ce56a66c4b52c6e6041e) +++ Core/Gui/src/Core.Gui/Forms/Backstage/BackstageViewModel.cs (.../BackstageViewModel.cs) (revision 6f2f24378f372a8b22b5e5fa2b6987a804e3f7f6) @@ -19,10 +19,12 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.ComponentModel; using System.Runtime.CompilerServices; using System.Windows.Input; using Core.Gui.Commands; +using Core.Gui.Settings; namespace Core.Gui.Forms.Backstage { @@ -41,10 +43,19 @@ /// /// Creates a new instance of . /// - public BackstageViewModel() + /// The application settings. + /// The application version. + /// Thrown when + /// is null. + public BackstageViewModel(GuiCoreSettings settings, string version) { + if (settings == null) + { + throw new ArgumentNullException(nameof(settings)); + } + InfoViewModel = new InfoViewModel(); - AboutViewModel = new AboutViewModel(); + AboutViewModel = new AboutViewModel(settings.MainWindowTitle, version); SupportViewModel = new SupportViewModel(); SetSelectedViewModelCommand = new RelayCommand(OnSetCurrentViewModel); Index: Core/Gui/src/Core.Gui/Forms/MainWindow/MainWindow.xaml =================================================================== diff -u -r44a1619c9ffc6d60995d5ee42702271be0064727 -r6f2f24378f372a8b22b5e5fa2b6987a804e3f7f6 --- Core/Gui/src/Core.Gui/Forms/MainWindow/MainWindow.xaml (.../MainWindow.xaml) (revision 44a1619c9ffc6d60995d5ee42702271be0064727) +++ Core/Gui/src/Core.Gui/Forms/MainWindow/MainWindow.xaml (.../MainWindow.xaml) (revision 6f2f24378f372a8b22b5e5fa2b6987a804e3f7f6) @@ -184,7 +184,8 @@ - + Index: Core/Gui/src/Core.Gui/Forms/MainWindow/MainWindow.xaml.cs =================================================================== diff -u -r6d127df298d3bc96c2690a6e3b3361fc4560583f -r6f2f24378f372a8b22b5e5fa2b6987a804e3f7f6 --- Core/Gui/src/Core.Gui/Forms/MainWindow/MainWindow.xaml.cs (.../MainWindow.xaml.cs) (revision 6d127df298d3bc96c2690a6e3b3361fc4560583f) +++ Core/Gui/src/Core.Gui/Forms/MainWindow/MainWindow.xaml.cs (.../MainWindow.xaml.cs) (revision 6f2f24378f372a8b22b5e5fa2b6987a804e3f7f6) @@ -37,6 +37,7 @@ using Core.Components.Chart.Forms; using Core.Components.Gis.Forms; using Core.Gui.Commands; +using Core.Gui.Forms.Backstage; using Core.Gui.Forms.Chart; using Core.Gui.Forms.Map; using Core.Gui.Forms.MessageWindow; @@ -98,6 +99,11 @@ } /// + /// Gets the . + /// + public BackstageViewModel BackstageViewModel { get; private set; } + + /// /// Gets a value indicating whether this window is disposed. /// public bool IsWindowDisposed { get; private set; } @@ -179,6 +185,9 @@ settings = gui; commands = gui; applicationSelection = gui; + + BackstageViewModel = new BackstageViewModel(settings.FixedSettings, SettingsHelper.Instance.ApplicationVersion); + } /// @@ -273,7 +282,11 @@ Close(); - SetGui(null); + gui = null; + viewController = null; + settings = null; + commands = null; + applicationSelection = null; } internal void AddStateButton(string text, string symbol, Func getRootData) Index: Core/Gui/src/Core.Gui/GuiCore.cs =================================================================== diff -u -r3a27be199e6082eee7cd89141fb8fcadd2cc0b7c -r6f2f24378f372a8b22b5e5fa2b6987a804e3f7f6 --- Core/Gui/src/Core.Gui/GuiCore.cs (.../GuiCore.cs) (revision 3a27be199e6082eee7cd89141fb8fcadd2cc0b7c) +++ Core/Gui/src/Core.Gui/GuiCore.cs (.../GuiCore.cs) (revision 6f2f24378f372a8b22b5e5fa2b6987a804e3f7f6) @@ -120,9 +120,9 @@ throw new ArgumentNullException(nameof(fixedSettings)); } - MainWindow = mainWindow; ProjectStore = projectStore; FixedSettings = fixedSettings; + MainWindow = mainWindow; isAlreadyRunningInstanceOfIGui = true; instanceCreationStackTrace = new StackTrace().ToString(); Index: Core/Gui/test/Core.Gui.Test/Forms/Backstage/AboutViewModelTest.cs =================================================================== diff -u -r86dacf60005c631ea61dad7782e13644b57831c5 -r6f2f24378f372a8b22b5e5fa2b6987a804e3f7f6 --- Core/Gui/test/Core.Gui.Test/Forms/Backstage/AboutViewModelTest.cs (.../AboutViewModelTest.cs) (revision 86dacf60005c631ea61dad7782e13644b57831c5) +++ Core/Gui/test/Core.Gui.Test/Forms/Backstage/AboutViewModelTest.cs (.../AboutViewModelTest.cs) (revision 6f2f24378f372a8b22b5e5fa2b6987a804e3f7f6) @@ -35,13 +35,17 @@ [Test] public void Constructor_ExpectedValues() { + // Setup + const string applicationName = "Riskeer"; + const string version = "1.0"; + // Call - var viewModel = new AboutViewModel(); + var viewModel = new AboutViewModel(applicationName, version); // Assert Assert.IsInstanceOf(viewModel); - Assert.AreEqual("Riskeer", viewModel.ApplicationName); - Assert.AreEqual("21.2.1.1", viewModel.Version); + Assert.AreEqual(applicationName, viewModel.ApplicationName); + Assert.AreEqual(version, viewModel.Version); ManagementObject processorManagementObject = new ManagementObjectSearcher("select * from Win32_Processor") Index: Core/Gui/test/Core.Gui.Test/Forms/Backstage/BackstageControlTest.cs =================================================================== diff -u -r7ed9edfa97f83402ba56d518da451e56f0cdccf6 -r6f2f24378f372a8b22b5e5fa2b6987a804e3f7f6 --- Core/Gui/test/Core.Gui.Test/Forms/Backstage/BackstageControlTest.cs (.../BackstageControlTest.cs) (revision 7ed9edfa97f83402ba56d518da451e56f0cdccf6) +++ Core/Gui/test/Core.Gui.Test/Forms/Backstage/BackstageControlTest.cs (.../BackstageControlTest.cs) (revision 6f2f24378f372a8b22b5e5fa2b6987a804e3f7f6) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System.Threading; using System.Windows.Controls; using Core.Gui.Forms.Backstage; using NUnit.Framework; @@ -29,14 +30,14 @@ public class BackstageControlTest { [Test] + [Apartment(ApartmentState.STA)] public void Constructor_ExpectedValues() { // Call var backstageControl = new BackstageControl(); // Assert Assert.IsInstanceOf(backstageControl); - Assert.IsNotNull(backstageControl.DataContext); } } } \ No newline at end of file Index: Core/Gui/test/Core.Gui.Test/Forms/Backstage/BackstageViewModelTest.cs =================================================================== diff -u -rb641495492850378ead7ce56a66c4b52c6e6041e -r6f2f24378f372a8b22b5e5fa2b6987a804e3f7f6 --- Core/Gui/test/Core.Gui.Test/Forms/Backstage/BackstageViewModelTest.cs (.../BackstageViewModelTest.cs) (revision b641495492850378ead7ce56a66c4b52c6e6041e) +++ Core/Gui/test/Core.Gui.Test/Forms/Backstage/BackstageViewModelTest.cs (.../BackstageViewModelTest.cs) (revision 6f2f24378f372a8b22b5e5fa2b6987a804e3f7f6) @@ -23,6 +23,7 @@ using System.Collections.Generic; using System.ComponentModel; using Core.Gui.Forms.Backstage; +using Core.Gui.Settings; using NUnit.Framework; namespace Core.Gui.Test.Forms.Backstage @@ -31,16 +32,38 @@ public class BackstageViewModelTest { [Test] + public void Constructor_SettingsNull_ThrowsArgumentNullException() + { + // Call + void Call() => new BackstageViewModel(null, "0"); + + // Assert + var exception = Assert.Throws(Call); + Assert.AreEqual("settings", exception.ParamName); + } + + [Test] public void Constructor_ExpectedValues() { + // Setup + var settings = new GuiCoreSettings + { + MainWindowTitle = "Riskeer" + }; + const string version = "1.0"; + // Call - var viewModel = new BackstageViewModel(); + var viewModel = new BackstageViewModel(settings, version); // Assert Assert.IsInstanceOf(viewModel); Assert.IsNotNull(viewModel.InfoViewModel); + Assert.IsNotNull(viewModel.AboutViewModel); + Assert.AreEqual(settings.MainWindowTitle, viewModel.AboutViewModel.ApplicationName); + Assert.AreEqual(version, viewModel.AboutViewModel.Version); + Assert.IsNotNull(viewModel.SupportViewModel); Assert.IsNotNull(viewModel.SetSelectedViewModelCommand); @@ -58,7 +81,7 @@ bool infoSelected, bool openSelected, bool aboutSelected) { // Given - var viewModel = new BackstageViewModel(); + var viewModel = new BackstageViewModel(new GuiCoreSettings(), "1.0"); IBackstagePageViewModel backstagePageViewModel = getBackstagePageViewModelFunc(viewModel); if (backstagePageViewModel is InfoViewModel) @@ -83,7 +106,7 @@ bool infoSelected, bool openSelected, bool aboutSelected) { // Given - var viewModel = new BackstageViewModel(); + var viewModel = new BackstageViewModel(new GuiCoreSettings(), "1.0"); IBackstagePageViewModel backstagePageViewModel = getBackstagePageViewModelFunc(viewModel); viewModel.SelectedViewModel = backstagePageViewModel; Index: Core/Gui/test/Core.Gui.Test/Forms/MainWindow/MainWindowTest.cs =================================================================== diff -u -r3a27be199e6082eee7cd89141fb8fcadd2cc0b7c -r6f2f24378f372a8b22b5e5fa2b6987a804e3f7f6 --- Core/Gui/test/Core.Gui.Test/Forms/MainWindow/MainWindowTest.cs (.../MainWindowTest.cs) (revision 3a27be199e6082eee7cd89141fb8fcadd2cc0b7c) +++ Core/Gui/test/Core.Gui.Test/Forms/MainWindow/MainWindowTest.cs (.../MainWindowTest.cs) (revision 6f2f24378f372a8b22b5e5fa2b6987a804e3f7f6) @@ -117,10 +117,31 @@ Assert.IsNotNull(mainWindow.ToggleMessageWindowCommand); Assert.IsNotNull(mainWindow.OpenLogFileCommand); Assert.IsNotNull(mainWindow.OpenUserManualCommand); + + Assert.IsNull(mainWindow.BackstageViewModel); } } [Test] + public void SetGui_Always_ExpectedValues() + { + // Setup + var mocks = new MockRepository(); + var gui = mocks.Stub(); + gui.Stub(g => g.FixedSettings).Return(new GuiCoreSettings()); + mocks.ReplayAll(); + + using (var mainWindow = new Gui.Forms.MainWindow.MainWindow()) + { + mainWindow.SetGui(gui); + + // Assert + Assert.IsNotNull(mainWindow.BackstageViewModel); + mocks.VerifyAll(); + } + } + + [Test] public void Dispose_SetIsWindowDisposedTrue() { // Setup @@ -240,6 +261,7 @@ var gui = mocks.Stub(); gui.Stub(g => g.ViewHost).Return(viewHost); + gui.Stub(g => g.FixedSettings).Return(new GuiCoreSettings()); mocks.ReplayAll(); using (var mainWindow = new Gui.Forms.MainWindow.MainWindow()) @@ -285,6 +307,7 @@ var gui = mocks.Stub(); gui.Stub(g => g.ViewHost).Return(viewHost); + gui.Stub(g => g.FixedSettings).Return(new GuiCoreSettings()); mocks.ReplayAll(); using (var mainWindow = new Gui.Forms.MainWindow.MainWindow()) @@ -333,6 +356,7 @@ gui.Stub(g => g.ViewHost).Return(viewHost); gui.Selection = selectedObject; gui.Stub(g => g.PropertyResolver).Return(propertyResolver); + gui.Stub(g => g.FixedSettings).Return(new GuiCoreSettings()); mocks.ReplayAll(); using (var mainWindow = new Gui.Forms.MainWindow.MainWindow()) @@ -370,6 +394,7 @@ gui.Stub(g => g.ViewHost).Return(viewHost); gui.Selection = selectedObject; gui.Stub(g => g.PropertyResolver).Return(propertyResolver); + gui.Stub(g => g.FixedSettings).Return(new GuiCoreSettings()); mocks.ReplayAll(); using (var mainWindow = new Gui.Forms.MainWindow.MainWindow()) @@ -434,6 +459,7 @@ gui.Stub(g => g.ViewCommands).Return(viewCommands); gui.Stub(g => g.Project).Return(project); gui.Stub(g => g.GetTreeNodeInfos()).Return(treeNodeInfos); + gui.Stub(g => g.FixedSettings).Return(new GuiCoreSettings()); mocks.ReplayAll(); gui.Selection = selectedObject; @@ -1202,15 +1228,15 @@ { ManualFilePath = userManualPresent ? path : null }; - + using (var mainWindow = new Gui.Forms.MainWindow.MainWindow()) using (var gui = new GuiCore(mainWindow, projectStore, projectMigrator, projectFactory, settings)) { gui.Plugins.Add(new TestPlugin()); gui.Run(); mainWindow.SetGui(gui); - + // When bool canExecute = mainWindow.OpenUserManualCommand.CanExecute(null);