Index: Core/Gui/src/Core.Gui/Forms/Backstage/AboutViewModel.cs
===================================================================
diff -u -rc30c93c3f77e0f07d0859c717c639329a63bd468 -r7ed9edfa97f83402ba56d518da451e56f0cdccf6
--- Core/Gui/src/Core.Gui/Forms/Backstage/AboutViewModel.cs (.../AboutViewModel.cs) (revision c30c93c3f77e0f07d0859c717c639329a63bd468)
+++ Core/Gui/src/Core.Gui/Forms/Backstage/AboutViewModel.cs (.../AboutViewModel.cs) (revision 7ed9edfa97f83402ba56d518da451e56f0cdccf6)
@@ -21,5 +21,5 @@
namespace Core.Gui.Forms.Backstage
{
- public class AboutViewModel : IViewModel {}
+ public class AboutViewModel : IBackstagePageViewModel {}
}
\ No newline at end of file
Index: Core/Gui/src/Core.Gui/Forms/Backstage/BackstageControl.xaml
===================================================================
diff -u -r2f8eceba36e55965b2d861414826454261bcbec0 -r7ed9edfa97f83402ba56d518da451e56f0cdccf6
--- Core/Gui/src/Core.Gui/Forms/Backstage/BackstageControl.xaml (.../BackstageControl.xaml) (revision 2f8eceba36e55965b2d861414826454261bcbec0)
+++ Core/Gui/src/Core.Gui/Forms/Backstage/BackstageControl.xaml (.../BackstageControl.xaml) (revision 7ed9edfa97f83402ba56d518da451e56f0cdccf6)
@@ -151,7 +151,7 @@
@@ -160,7 +160,7 @@
Command="{x:Static commands:MainWindowCommands.NewProjectCommand}" />
-
Index: Core/Gui/src/Core.Gui/Forms/Backstage/BackstageViewModel.cs
===================================================================
diff -u -r2f8eceba36e55965b2d861414826454261bcbec0 -r7ed9edfa97f83402ba56d518da451e56f0cdccf6
--- Core/Gui/src/Core.Gui/Forms/Backstage/BackstageViewModel.cs (.../BackstageViewModel.cs) (revision 2f8eceba36e55965b2d861414826454261bcbec0)
+++ Core/Gui/src/Core.Gui/Forms/Backstage/BackstageViewModel.cs (.../BackstageViewModel.cs) (revision 7ed9edfa97f83402ba56d518da451e56f0cdccf6)
@@ -26,47 +26,76 @@
namespace Core.Gui.Forms.Backstage
{
+ ///
+ /// ViewModel for the .
+ ///
public class BackstageViewModel : INotifyPropertyChanged
{
- private IViewModel currentViewModel;
+ private IBackstagePageViewModel selectedViewModel;
private bool infoSelected;
private bool openSelected;
private bool aboutSelected;
+
public event PropertyChangedEventHandler PropertyChanged;
+ ///
+ /// Creates a new instance of .
+ ///
public BackstageViewModel()
{
InfoViewModel = new InfoViewModel();
OpenViewModel = new OpenViewModel();
AboutViewModel = new AboutViewModel();
- SetCurrentViewModelCommand = new RelayCommand(OnSetCurrentViewModel);
+ SetSelectedViewModelCommand = new RelayCommand(OnSetCurrentViewModel);
- CurrentViewModel = InfoViewModel;
+ SelectedViewModel = InfoViewModel;
}
- public ICommand SetCurrentViewModelCommand { get; }
- public IViewModel InfoViewModel { get; }
- public IViewModel OpenViewModel { get; }
- public IViewModel AboutViewModel { get; }
+ ///
+ /// Gets the command to set the selected view model.
+ ///
+ public ICommand SetSelectedViewModelCommand { get; }
+
+ ///
+ /// Gets the .
+ ///
+ public InfoViewModel InfoViewModel { get; }
+
+ ///
+ /// Gets the .
+ ///
+ public OpenViewModel OpenViewModel { get; }
+
+ ///
+ /// Gets the .
+ ///
+ public AboutViewModel AboutViewModel { get; }
- public IViewModel CurrentViewModel
+ ///
+ /// Gets or sets the selected view model.
+ ///
+ public IBackstagePageViewModel SelectedViewModel
{
- get => currentViewModel;
+ get => selectedViewModel;
set
{
- if (value == currentViewModel)
+ if (value == selectedViewModel)
{
return;
}
- currentViewModel = value;
- OnPropertyChanged(nameof(CurrentViewModel));
+ selectedViewModel = value;
+ OnPropertyChanged(nameof(SelectedViewModel));
SetButtonStates();
}
}
+ ///
+ /// Gets an indicator whether the
+ /// is selected.
+ ///
public bool InfoSelected
{
get => infoSelected;
@@ -77,6 +106,10 @@
}
}
+ ///
+ /// Gets an indicator whether the
+ /// is selected.
+ ///
public bool OpenSelected
{
get => openSelected;
@@ -87,6 +120,10 @@
}
}
+ ///
+ /// Gets an indicator whether the
+ /// is selected.
+ ///
public bool AboutSelected
{
get => aboutSelected;
@@ -104,14 +141,14 @@
private void SetButtonStates()
{
- InfoSelected = currentViewModel is InfoViewModel;
- OpenSelected = currentViewModel is OpenViewModel;
- AboutSelected = currentViewModel is AboutViewModel;
+ InfoSelected = selectedViewModel is InfoViewModel;
+ OpenSelected = selectedViewModel is OpenViewModel;
+ AboutSelected = selectedViewModel is AboutViewModel;
}
private void OnSetCurrentViewModel(object obj)
{
- CurrentViewModel = (IViewModel) obj;
+ SelectedViewModel = (IBackstagePageViewModel) obj;
}
}
}
\ No newline at end of file
Index: Core/Gui/src/Core.Gui/Forms/Backstage/IBackstagePageViewModel.cs
===================================================================
diff -u -rc30c93c3f77e0f07d0859c717c639329a63bd468 -r7ed9edfa97f83402ba56d518da451e56f0cdccf6
--- Core/Gui/src/Core.Gui/Forms/Backstage/IBackstagePageViewModel.cs (.../IBackstagePageViewModel.cs) (revision c30c93c3f77e0f07d0859c717c639329a63bd468)
+++ Core/Gui/src/Core.Gui/Forms/Backstage/IBackstagePageViewModel.cs (.../IBackstagePageViewModel.cs) (revision 7ed9edfa97f83402ba56d518da451e56f0cdccf6)
@@ -21,5 +21,5 @@
namespace Core.Gui.Forms.Backstage
{
- public interface IViewModel {}
+ public interface IBackstagePageViewModel {}
}
\ No newline at end of file
Index: Core/Gui/src/Core.Gui/Forms/Backstage/InfoViewModel.cs
===================================================================
diff -u -rc30c93c3f77e0f07d0859c717c639329a63bd468 -r7ed9edfa97f83402ba56d518da451e56f0cdccf6
--- Core/Gui/src/Core.Gui/Forms/Backstage/InfoViewModel.cs (.../InfoViewModel.cs) (revision c30c93c3f77e0f07d0859c717c639329a63bd468)
+++ Core/Gui/src/Core.Gui/Forms/Backstage/InfoViewModel.cs (.../InfoViewModel.cs) (revision 7ed9edfa97f83402ba56d518da451e56f0cdccf6)
@@ -21,5 +21,5 @@
namespace Core.Gui.Forms.Backstage
{
- public class InfoViewModel : IViewModel {}
+ public class InfoViewModel : IBackstagePageViewModel {}
}
\ No newline at end of file
Index: Core/Gui/src/Core.Gui/Forms/Backstage/OpenViewModel.cs
===================================================================
diff -u -rc30c93c3f77e0f07d0859c717c639329a63bd468 -r7ed9edfa97f83402ba56d518da451e56f0cdccf6
--- Core/Gui/src/Core.Gui/Forms/Backstage/OpenViewModel.cs (.../OpenViewModel.cs) (revision c30c93c3f77e0f07d0859c717c639329a63bd468)
+++ Core/Gui/src/Core.Gui/Forms/Backstage/OpenViewModel.cs (.../OpenViewModel.cs) (revision 7ed9edfa97f83402ba56d518da451e56f0cdccf6)
@@ -21,5 +21,5 @@
namespace Core.Gui.Forms.Backstage
{
- public class OpenViewModel : IViewModel {}
+ public class OpenViewModel : IBackstagePageViewModel {}
}
\ No newline at end of file
Index: Core/Gui/test/Core.Gui.Test/Forms/Backstage/AboutViewModelTest.cs
===================================================================
diff -u
--- Core/Gui/test/Core.Gui.Test/Forms/Backstage/AboutViewModelTest.cs (revision 0)
+++ Core/Gui/test/Core.Gui.Test/Forms/Backstage/AboutViewModelTest.cs (revision 7ed9edfa97f83402ba56d518da451e56f0cdccf6)
@@ -0,0 +1,40 @@
+// Copyright (C) Stichting Deltares 2021. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using Core.Gui.Forms.Backstage;
+using NUnit.Framework;
+
+namespace Core.Gui.Test.Forms.Backstage
+{
+ [TestFixture]
+ public class AboutViewModelTest
+ {
+ [Test]
+ public void Constructor_ExpectedValues()
+ {
+ // Call
+ var viewModel = new AboutViewModel();
+
+ // Assert
+ Assert.IsInstanceOf(viewModel);
+ }
+ }
+}
\ No newline at end of file
Index: Core/Gui/test/Core.Gui.Test/Forms/Backstage/BackstageControlTest.cs
===================================================================
diff -u
--- Core/Gui/test/Core.Gui.Test/Forms/Backstage/BackstageControlTest.cs (revision 0)
+++ Core/Gui/test/Core.Gui.Test/Forms/Backstage/BackstageControlTest.cs (revision 7ed9edfa97f83402ba56d518da451e56f0cdccf6)
@@ -0,0 +1,42 @@
+// Copyright (C) Stichting Deltares 2021. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.Windows.Controls;
+using Core.Gui.Forms.Backstage;
+using NUnit.Framework;
+
+namespace Core.Gui.Test.Forms.Backstage
+{
+ [TestFixture]
+ public class BackstageControlTest
+ {
+ [Test]
+ 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
--- Core/Gui/test/Core.Gui.Test/Forms/Backstage/BackstageViewModelTest.cs (revision 0)
+++ Core/Gui/test/Core.Gui.Test/Forms/Backstage/BackstageViewModelTest.cs (revision 7ed9edfa97f83402ba56d518da451e56f0cdccf6)
@@ -0,0 +1,117 @@
+// Copyright (C) Stichting Deltares 2021. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using Core.Gui.Forms.Backstage;
+using NUnit.Framework;
+
+namespace Core.Gui.Test.Forms.Backstage
+{
+ [TestFixture]
+ public class BackstageViewModelTest
+ {
+ [Test]
+ public void Constructor_ExpectedValues()
+ {
+ // Call
+ var viewModel = new BackstageViewModel();
+
+ // Assert
+ Assert.IsInstanceOf(viewModel);
+
+ Assert.IsNotNull(viewModel.InfoViewModel);
+ Assert.IsNotNull(viewModel.OpenViewModel);
+ Assert.IsNotNull(viewModel.AboutViewModel);
+
+ Assert.IsNotNull(viewModel.SetSelectedViewModelCommand);
+
+ Assert.AreSame(viewModel.InfoViewModel, viewModel.SelectedViewModel);
+ Assert.IsTrue(viewModel.InfoSelected);
+ Assert.IsFalse(viewModel.OpenSelected);
+ Assert.IsFalse(viewModel.AboutSelected);
+ }
+
+ [Test]
+ [TestCaseSource(nameof(GetBackstagePageViewModels))]
+ public void GivenViewModel_WhenExecutingSetSelectedViewModelCommand_ThenExpectedValuesSet(
+ Func getBackstagePageViewModelFunc,
+ bool infoSelected, bool openSelected, bool aboutSelected)
+ {
+ // Given
+ var viewModel = new BackstageViewModel();
+ IBackstagePageViewModel backstagePageViewModel = getBackstagePageViewModelFunc(viewModel);
+
+ if (backstagePageViewModel is InfoViewModel)
+ {
+ viewModel.SelectedViewModel = viewModel.AboutViewModel;
+ }
+
+ // When
+ viewModel.SetSelectedViewModelCommand.Execute(backstagePageViewModel);
+
+ // Assert
+ Assert.AreSame(backstagePageViewModel, viewModel.SelectedViewModel);
+ Assert.AreEqual(infoSelected, viewModel.InfoSelected);
+ Assert.AreEqual(openSelected, viewModel.OpenSelected);
+ Assert.AreEqual(aboutSelected, viewModel.AboutSelected);
+ }
+
+ [Test]
+ [TestCaseSource(nameof(GetBackstagePageViewModels))]
+ public void GivenViewModel_WhenExecutingSetSelectedViewModelCommandAndSetToSameViewModel_ThenNothingHappens(
+ Func getBackstagePageViewModelFunc,
+ bool infoSelected, bool openSelected, bool aboutSelected)
+ {
+ // Given
+ var viewModel = new BackstageViewModel();
+ IBackstagePageViewModel backstagePageViewModel = getBackstagePageViewModelFunc(viewModel);
+
+ viewModel.SelectedViewModel = backstagePageViewModel;
+
+ // Precondition
+ Assert.AreSame(backstagePageViewModel, viewModel.SelectedViewModel);
+ Assert.AreEqual(infoSelected, viewModel.InfoSelected);
+ Assert.AreEqual(openSelected, viewModel.OpenSelected);
+ Assert.AreEqual(aboutSelected, viewModel.AboutSelected);
+
+ // When
+ viewModel.SetSelectedViewModelCommand.Execute(backstagePageViewModel);
+
+ // Assert
+ Assert.AreSame(backstagePageViewModel, viewModel.SelectedViewModel);
+ Assert.AreEqual(infoSelected, viewModel.InfoSelected);
+ Assert.AreEqual(openSelected, viewModel.OpenSelected);
+ Assert.AreEqual(aboutSelected, viewModel.AboutSelected);
+ }
+
+ private static IEnumerable GetBackstagePageViewModels()
+ {
+ yield return new TestCaseData(new Func(
+ viewModel => viewModel.InfoViewModel), true, false ,false);
+ yield return new TestCaseData(new Func(
+ viewModel => viewModel.OpenViewModel), false, true, false);
+ yield return new TestCaseData(new Func(
+ viewModel => viewModel.AboutViewModel), false, false, true);
+ }
+ }
+}
\ No newline at end of file
Index: Core/Gui/test/Core.Gui.Test/Forms/Backstage/InfoViewModelTest.cs
===================================================================
diff -u
--- Core/Gui/test/Core.Gui.Test/Forms/Backstage/InfoViewModelTest.cs (revision 0)
+++ Core/Gui/test/Core.Gui.Test/Forms/Backstage/InfoViewModelTest.cs (revision 7ed9edfa97f83402ba56d518da451e56f0cdccf6)
@@ -0,0 +1,40 @@
+// Copyright (C) Stichting Deltares 2021. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using Core.Gui.Forms.Backstage;
+using NUnit.Framework;
+
+namespace Core.Gui.Test.Forms.Backstage
+{
+ [TestFixture]
+ public class InfoViewModelTest
+ {
+ [Test]
+ public void Constructor_ExpectedValues()
+ {
+ // Call
+ var viewModel = new AboutViewModel();
+
+ // Assert
+ Assert.IsInstanceOf(viewModel);
+ }
+ }
+}
\ No newline at end of file
Index: Core/Gui/test/Core.Gui.Test/Forms/Backstage/OpenViewModelTest.cs
===================================================================
diff -u
--- Core/Gui/test/Core.Gui.Test/Forms/Backstage/OpenViewModelTest.cs (revision 0)
+++ Core/Gui/test/Core.Gui.Test/Forms/Backstage/OpenViewModelTest.cs (revision 7ed9edfa97f83402ba56d518da451e56f0cdccf6)
@@ -0,0 +1,40 @@
+// Copyright (C) Stichting Deltares 2021. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using Core.Gui.Forms.Backstage;
+using NUnit.Framework;
+
+namespace Core.Gui.Test.Forms.Backstage
+{
+ [TestFixture]
+ public class OpenViewModelTest
+ {
+ [Test]
+ public void Constructor_ExpectedValues()
+ {
+ // Call
+ var viewModel = new AboutViewModel();
+
+ // Assert
+ Assert.IsInstanceOf(viewModel);
+ }
+ }
+}
\ No newline at end of file