Index: Core/Common/src/Core.Common.Gui/Forms/MainWindow/MainWindow.xaml.cs
===================================================================
diff -u -r05c6be6a736882e7d71424f4837a01c027638324 -r667f6bc7aad5f7fc5b82da1b0577d92d392e91a4
--- Core/Common/src/Core.Common.Gui/Forms/MainWindow/MainWindow.xaml.cs (.../MainWindow.xaml.cs) (revision 05c6be6a736882e7d71424f4837a01c027638324)
+++ Core/Common/src/Core.Common.Gui/Forms/MainWindow/MainWindow.xaml.cs (.../MainWindow.xaml.cs) (revision 667f6bc7aad5f7fc5b82da1b0577d92d392e91a4)
@@ -79,35 +79,20 @@
///
/// Gets the log messages tool window.
///
- public IMessageWindow MessageWindow
- {
- get
- {
- return messageWindow;
- }
- }
+ public IMessageWindow MessageWindow => messageWindow;
///
/// Gets the view host.
///
- public IViewHost ViewHost
- {
- get
- {
- return AvalonDockViewHost;
- }
- }
+ public IViewHost ViewHost => AvalonDockViewHost;
///
/// Gets or sets a value indicating whether or not the main user interface is visible.
///
/// Thrown when no gui has been set using .
public bool Visible
{
- get
- {
- return IsVisible;
- }
+ get => IsVisible;
set
{
if (gui == null)
@@ -136,29 +121,11 @@
}
}
- public IView PropertyGrid
- {
- get
- {
- return propertyGrid;
- }
- }
+ public IView PropertyGrid => propertyGrid;
- public IntPtr Handle
- {
- get
- {
- return windowInteropHelper.Handle;
- }
- }
+ public IntPtr Handle => windowInteropHelper.Handle;
- public bool InvokeRequired
- {
- get
- {
- return !Dispatcher.CheckAccess();
- }
- }
+ public bool InvokeRequired => !Dispatcher.CheckAccess();
public ProjectExplorer.ProjectExplorer ProjectExplorer => projectExplorer;
Index: Core/Common/test/Core.Common.Gui.Test/Forms/MainWindow/MainWindowTest.cs
===================================================================
diff -u -r05c6be6a736882e7d71424f4837a01c027638324 -r667f6bc7aad5f7fc5b82da1b0577d92d392e91a4
--- Core/Common/test/Core.Common.Gui.Test/Forms/MainWindow/MainWindowTest.cs (.../MainWindowTest.cs) (revision 05c6be6a736882e7d71424f4837a01c027638324)
+++ Core/Common/test/Core.Common.Gui.Test/Forms/MainWindow/MainWindowTest.cs (.../MainWindowTest.cs) (revision 667f6bc7aad5f7fc5b82da1b0577d92d392e91a4)
@@ -61,7 +61,7 @@
[Test]
[Apartment(ApartmentState.STA)]
- public void DefaultConstructor_ExpectedValues()
+ public void Constructor_ExpectedValues()
{
// Call
using (var mainWindow = new Gui.Forms.MainWindow.MainWindow())
@@ -114,10 +114,10 @@
using (var mainWindow = new Gui.Forms.MainWindow.MainWindow())
{
// Call
- TestDelegate call = () => mainWindow.Visible = newVisibleValue;
+ void Call() => mainWindow.Visible = newVisibleValue;
// Assert
- Assert.Throws(call);
+ Assert.Throws(Call);
}
}
@@ -194,10 +194,10 @@
using (var mainWindow = new Gui.Forms.MainWindow.MainWindow())
{
// Call
- TestDelegate call = () => mainWindow.SubscribeToGui();
+ void Call() => mainWindow.SubscribeToGui();
// Assert
- Assert.DoesNotThrow(call);
+ Assert.DoesNotThrow(Call);
}
}
@@ -234,10 +234,10 @@
using (var mainWindow = new Gui.Forms.MainWindow.MainWindow())
{
// Call
- TestDelegate call = () => mainWindow.UnsubscribeFromGui();
+ void Call() => mainWindow.UnsubscribeFromGui();
// Assert
- Assert.DoesNotThrow(call);
+ Assert.DoesNotThrow(Call);
}
}
@@ -276,10 +276,10 @@
using (var mainWindow = new Gui.Forms.MainWindow.MainWindow())
{
// Call
- TestDelegate call = () => mainWindow.InitPropertiesWindowOrBringToFront();
+ void Call() => mainWindow.InitPropertiesWindowOrBringToFront();
// Assert
- Assert.Throws(call);
+ Assert.Throws(Call);
}
}
@@ -371,10 +371,10 @@
using (var mainWindow = new Gui.Forms.MainWindow.MainWindow())
{
// Call
- TestDelegate call = () => mainWindow.InitializeToolWindows();
+ void Call() => mainWindow.InitializeToolWindows();
// Assert
- Assert.Throws(call);
+ Assert.Throws(Call);
}
}
@@ -439,7 +439,7 @@
[Apartment(ApartmentState.STA)]
public void GivenGuiWithProjectExplorer_WhenClosingProjectExplorer_ThenProjectExplorerSetToNull()
{
- // Setup
+ // Given
var mocks = new MockRepository();
var projectStore = mocks.Stub();
var projectMigrator = mocks.Stub();
@@ -475,10 +475,10 @@
// Precondition
Assert.IsNotNull(mainWindow.ProjectExplorer);
- // Call
+ // When
mainWindow.ViewHost.Remove(mainWindow.ProjectExplorer);
- // Assert
+ // Then
Assert.IsNull(mainWindow.ProjectExplorer);
}
@@ -489,7 +489,7 @@
[Apartment(ApartmentState.STA)]
public void GivenGuiWithPropertyGrid_WhenClosingPropertyGrid_ThenPropertyGridSetToNull()
{
- // Setup
+ // Given
var mocks = new MockRepository();
var projectStore = mocks.Stub();
var projectMigrator = mocks.Stub();
@@ -525,10 +525,10 @@
// Precondition
Assert.IsNotNull(mainWindow.PropertyGrid);
- // Call
+ // When
mainWindow.ViewHost.Remove(mainWindow.PropertyGrid);
- // Assert
+ // Then
Assert.IsNull(mainWindow.PropertyGrid);
}
@@ -539,7 +539,7 @@
[Apartment(ApartmentState.STA)]
public void GivenGuiWithMessageWindow_WhenClosingMessageWindow_ThenMessageWindowSetToNull()
{
- // Setup
+ // Given
var mocks = new MockRepository();
var projectStore = mocks.Stub();
var projectMigrator = mocks.Stub();
@@ -575,10 +575,10 @@
// Precondition
Assert.IsNotNull(mainWindow.MessageWindow);
- // Call
+ // When
mainWindow.ViewHost.Remove(mainWindow.MessageWindow);
- // Assert
+ // Then
Assert.IsNull(mainWindow.MessageWindow);
}
Index: Core/Common/test/Core.Common.Gui.Test/GuiCoreTest.cs
===================================================================
diff -u -r97fb7fb38c60ea9eb5bfd1ceebc2a05631dabea1 -r667f6bc7aad5f7fc5b82da1b0577d92d392e91a4
--- Core/Common/test/Core.Common.Gui.Test/GuiCoreTest.cs (.../GuiCoreTest.cs) (revision 97fb7fb38c60ea9eb5bfd1ceebc2a05631dabea1)
+++ Core/Common/test/Core.Common.Gui.Test/GuiCoreTest.cs (.../GuiCoreTest.cs) (revision 667f6bc7aad5f7fc5b82da1b0577d92d392e91a4)
@@ -73,7 +73,7 @@
[Test]
[Apartment(ApartmentState.STA)]
- public void ParameteredConstructor_ValidArguments_ExpectedValues()
+ public void Constructor_ValidArguments_ExpectedValues()
{
// Setup
var mocks = new MockRepository();
@@ -133,10 +133,10 @@
var guiCoreSettings = new GuiCoreSettings();
// Call
- TestDelegate call = () => new GuiCore(null, projectStore, projectMigrator, projectFactory, guiCoreSettings);
+ void Call() => new GuiCore(null, projectStore, projectMigrator, projectFactory, guiCoreSettings);
// Assert
- var exception = Assert.Throws(call);
+ var exception = Assert.Throws(Call);
Assert.AreEqual("mainWindow", exception.ParamName);
mocks.VerifyAll();
}
@@ -156,10 +156,10 @@
using (var mainWindow = new MainWindow())
{
// Call
- TestDelegate call = () => new GuiCore(mainWindow, projectStore, null, projectFactory, guiCoreSettings);
+ void Call() => new GuiCore(mainWindow, projectStore, null, projectFactory, guiCoreSettings);
// Assert
- var exception = Assert.Throws(call);
+ var exception = Assert.Throws(Call);
Assert.AreEqual("projectMigrator", exception.ParamName);
}
@@ -181,10 +181,10 @@
using (var mainWindow = new MainWindow())
{
// Call
- TestDelegate call = () => new GuiCore(mainWindow, null, projectMigrator, projectFactory, guiCoreSettings);
+ void Call() => new GuiCore(mainWindow, null, projectMigrator, projectFactory, guiCoreSettings);
// Assert
- var exception = Assert.Throws(call);
+ var exception = Assert.Throws(Call);
Assert.AreEqual("projectStore", exception.ParamName);
}
@@ -206,10 +206,10 @@
using (var mainWindow = new MainWindow())
{
// Call
- TestDelegate call = () => new GuiCore(mainWindow, projectStore, projectMigrator, null, guiCoreSettings);
+ void Call() => new GuiCore(mainWindow, projectStore, projectMigrator, null, guiCoreSettings);
// Assert
- var exception = Assert.Throws(call);
+ var exception = Assert.Throws(Call);
Assert.AreEqual("projectFactory", exception.ParamName);
}
@@ -230,10 +230,10 @@
using (var mainWindow = new MainWindow())
{
// Call
- TestDelegate call = () => new GuiCore(mainWindow, projectStore, projectMigrator, projectFactory, null);
+ void Call() => new GuiCore(mainWindow, projectStore, projectMigrator, projectFactory, null);
// Assert
- var exception = Assert.Throws(call);
+ var exception = Assert.Throws(Call);
Assert.AreEqual("fixedSettings", exception.ParamName);
}
@@ -257,13 +257,13 @@
using (new GuiCore(mainWindow, projectStore, projectMigrator, projectFactory, guiCoreSettings))
{
// Call
- TestDelegate call = () =>
+ void Call()
{
using (new GuiCore(mainWindow, projectStore, projectMigrator, projectFactory, guiCoreSettings)) {}
- };
+ }
// Assert
- Assert.Throws(call);
+ Assert.Throws(Call);
}
mocks.VerifyAll();
@@ -287,10 +287,10 @@
gui.Plugins.Add(plugin);
// Call
- TestDelegate test = () => gui.SetProject(null, null);
+ void Call() => gui.SetProject(null, null);
// Assert
- Assert.Throws(test);
+ Assert.Throws(Call);
}
mocks.VerifyAll();
@@ -339,10 +339,10 @@
gui.Plugins.Add(plugin);
// Call
- Action call = () => gui.Dispose();
+ void Call() => gui.Dispose();
// Assert
- TestHelper.AssertLogMessageIsGenerated(call, "Kritieke fout opgetreden tijdens deactivering van de grafische interface plugin.", 1);
+ TestHelper.AssertLogMessageIsGenerated(Call, "Kritieke fout opgetreden tijdens deactivering van de grafische interface plugin.", 1);
Assert.IsNull(gui.Plugins);
mocks.VerifyAll();
}
@@ -373,7 +373,7 @@
[Test]
[Apartment(ApartmentState.STA)]
- public void Dispose_HasMainWindow_DiposeOfMainWindow()
+ public void Dispose_HasMainWindow_DisposeOfMainWindow()
{
// Setup
var mocks = new MockRepository();
@@ -560,7 +560,7 @@
IAppender[] originalAppenders = rootLogger.Appenders.ToArray();
rootLogger.RemoveAllAppenders();
rootLogger.AddAppender(appender);
- bool rootloggerConfigured = rootLogger.Repository.Configured;
+ bool rootLoggerConfigured = rootLogger.Repository.Configured;
try
{
@@ -573,7 +573,7 @@
Assert.AreEqual(1, rootLogger.Appenders.Count);
Assert.AreSame(appender, rootLogger.Appenders[0]);
Assert.AreSame(appender, MessageWindowLogAppender.Instance);
- Assert.AreEqual(rootloggerConfigured, rootLogger.Repository.Configured);
+ Assert.AreEqual(rootLoggerConfigured, rootLogger.Repository.Configured);
Assert.IsTrue(MessageWindowLogAppender.Instance.Enabled);
}
@@ -596,7 +596,7 @@
{
// Setup
const string fileName = "SomeFile";
- string testFile = $"{fileName}.rtd";
+ var testFile = $"{fileName}.rtd";
var mocks = new MockRepository();
var projectStore = mocks.Stub();
@@ -616,21 +616,21 @@
using (var gui = new GuiCore(mainWindow, projectStore, projectMigrator, projectFactory, fixedSettings))
{
// Call
- Action call = () => gui.Run(testFile);
+ void Call() => gui.Run(testFile);
// Assert
Tuple[] expectedMessages =
{
Tuple.Create("Openen van project is gestart.", LogLevelConstant.Info),
Tuple.Create("Openen van project is gelukt.", LogLevelConstant.Info)
};
- TestHelper.AssertLogMessagesWithLevelAreGenerated(call, expectedMessages);
+ TestHelper.AssertLogMessagesWithLevelAreGenerated(Call, expectedMessages);
Assert.AreEqual(testFile, gui.ProjectFilePath);
Assert.AreSame(deserializedProject, gui.Project);
Assert.AreEqual(fileName, gui.Project.Name,
"Project name should be updated to the name of the file.");
- string expectedTitle = $"{fileName} - {fixedSettings.MainWindowTitle} {SettingsHelper.Instance.ApplicationVersion}";
+ var expectedTitle = $"{fileName} - {fixedSettings.MainWindowTitle} {SettingsHelper.Instance.ApplicationVersion}";
Assert.AreEqual(expectedTitle, mainWindow.Title);
}
@@ -643,7 +643,7 @@
{
// Setup
const string fileName = "SomeFile";
- string testFile = $"{fileName}.rtd";
+ var testFile = $"{fileName}.rtd";
var mocks = new MockRepository();
var projectStore = mocks.Stub();
@@ -673,7 +673,7 @@
// Assert
Assert.IsNull(gui.ProjectFilePath);
- string expectedTitle = $"{expectedProjectName} - {fixedSettings.MainWindowTitle} {SettingsHelper.Instance.ApplicationVersion}";
+ var expectedTitle = $"{expectedProjectName} - {fixedSettings.MainWindowTitle} {SettingsHelper.Instance.ApplicationVersion}";
Assert.AreEqual(expectedTitle, mainWindow.Title);
}
@@ -686,7 +686,7 @@
{
// Setup
const string fileName = "SomeFile";
- string testFile = $"{fileName}.rtd";
+ var testFile = $"{fileName}.rtd";
const string expectedErrorMessage = "You shall not migrate!";
@@ -714,10 +714,10 @@
using (var gui = new GuiCore(mainWindow, projectStore, projectMigrator, projectFactory, fixedSettings))
{
// Call
- Action call = () => gui.Run(testFile);
+ void Call() => gui.Run(testFile);
// Assert
- TestHelper.AssertLogMessageWithLevelIsGenerated(call, Tuple.Create(expectedErrorMessage, LogLevelConstant.Error));
+ TestHelper.AssertLogMessageWithLevelIsGenerated(Call, Tuple.Create(expectedErrorMessage, LogLevelConstant.Error));
Assert.IsNull(gui.ProjectFilePath);
string expectedTitle = $"{expectedProjectName} - {fixedSettings.MainWindowTitle} {SettingsHelper.Instance.ApplicationVersion}";
@@ -733,8 +733,8 @@
{
// Setup
const string fileName = "SomeFile";
- string testFile = $"{fileName}.rtd";
- string targetFile = $"{fileName}_17_1.rtd";
+ var testFile = $"{fileName}.rtd";
+ var targetFile = $"{fileName}_17_1.rtd";
const string expectedErrorMessage = "You shall not migrate!";
@@ -764,7 +764,7 @@
using (var gui = new GuiCore(mainWindow, projectStore, projectMigrator, projectFactory, fixedSettings))
{
// Call
- Action call = () => gui.Run(testFile);
+ void Call() => gui.Run(testFile);
// Assert
Tuple[] expectedMessages =
@@ -773,10 +773,10 @@
Tuple.Create(expectedErrorMessage, LogLevelConstant.Error),
Tuple.Create("Openen van project is mislukt.", LogLevelConstant.Error)
};
- TestHelper.AssertLogMessagesWithLevelAreGenerated(call, expectedMessages);
+ TestHelper.AssertLogMessagesWithLevelAreGenerated(Call, expectedMessages);
Assert.IsNull(gui.ProjectFilePath);
- string expectedTitle = $"{expectedProjectName} - {fixedSettings.MainWindowTitle} {SettingsHelper.Instance.ApplicationVersion}";
+ var expectedTitle = $"{expectedProjectName} - {fixedSettings.MainWindowTitle} {SettingsHelper.Instance.ApplicationVersion}";
Assert.AreEqual(expectedTitle, mainWindow.Title);
}
@@ -789,7 +789,7 @@
{
// Setup
const string fileName = "SomeFile";
- string testFile = $"{fileName}.rtd";
+ var testFile = $"{fileName}.rtd";
const string storageExceptionText = "";
@@ -815,7 +815,7 @@
using (var gui = new GuiCore(mainWindow, projectStore, projectMigrator, projectFactory, fixedSettings))
{
// Call
- Action call = () => gui.Run(testFile);
+ void Call() => gui.Run(testFile);
// Assert
Tuple[] expectedMessages =
@@ -824,10 +824,10 @@
Tuple.Create(storageExceptionText, LogLevelConstant.Error),
Tuple.Create("Openen van project is mislukt.", LogLevelConstant.Error)
};
- TestHelper.AssertLogMessagesWithLevelAreGenerated(call, expectedMessages);
+ TestHelper.AssertLogMessagesWithLevelAreGenerated(Call, expectedMessages);
Assert.IsNull(gui.ProjectFilePath);
- string expectedTitle = $"{expectedProjectName} - {fixedSettings.MainWindowTitle} {SettingsHelper.Instance.ApplicationVersion}";
+ var expectedTitle = $"{expectedProjectName} - {fixedSettings.MainWindowTitle} {SettingsHelper.Instance.ApplicationVersion}";
Assert.AreEqual(expectedTitle, mainWindow.Title);
}
@@ -867,7 +867,7 @@
// Assert
Assert.IsNull(gui.ProjectFilePath);
Assert.AreSame(project, gui.Project);
- string expectedTitle = $"{expectedProjectName} - {fixedSettings.MainWindowTitle} {SettingsHelper.Instance.ApplicationVersion}";
+ var expectedTitle = $"{expectedProjectName} - {fixedSettings.MainWindowTitle} {SettingsHelper.Instance.ApplicationVersion}";
Assert.AreEqual(expectedTitle, mainWindow.Title);
}
@@ -956,12 +956,12 @@
gui.Plugins.Add(plugin);
// Call
- Action call = () => gui.Run();
+ void Call() => gui.Run();
// Assert
const string expectedMessage = "Kritieke fout opgetreden tijdens deactivering van de grafische interface plugin.";
Tuple expectedMessageAndLogLevel = Tuple.Create(expectedMessage, LogLevelConstant.Error);
- TestHelper.AssertLogMessageWithLevelIsGenerated(call, expectedMessageAndLogLevel);
+ TestHelper.AssertLogMessageWithLevelIsGenerated(Call, expectedMessageAndLogLevel);
}
mocks.VerifyAll(); // Expect Dispose call on plugin
@@ -1228,10 +1228,10 @@
using (var gui = new GuiCore(new MainWindow(), projectStore, projectMigrator, projectFactory, new GuiCoreSettings()))
{
// Call
- TestDelegate call = () => gui.Get(new object(), treeView);
+ void Call() => gui.Get(new object(), treeView);
// Assert
- string message = Assert.Throws(call).Message;
+ string message = Assert.Throws(Call).Message;
Assert.AreEqual("Call IGui.Run in order to initialize dependencies before getting the ContextMenuBuilder.", message);
}