Index: Application/Riskeer/src/Application.Riskeer/App.xaml.cs =================================================================== diff -u -r628a729daf3bed1d5cca1d4d0c107afb59134f54 -ra79026549254c82cf85550eb8fea2b7229bf9b1b --- Application/Riskeer/src/Application.Riskeer/App.xaml.cs (.../App.xaml.cs) (revision 628a729daf3bed1d5cca1d4d0c107afb59134f54) +++ Application/Riskeer/src/Application.Riskeer/App.xaml.cs (.../App.xaml.cs) (revision a79026549254c82cf85550eb8fea2b7229bf9b1b) @@ -135,8 +135,10 @@ var mainWindow = new MainWindow(); var projectMigrator = new ProjectMigrator(new DialogBasedInquiryHelper(mainWindow)); + var assessmentSectionFromFileHandler = new AssessmentSectionFromFileHandler(mainWindow); + var projectFactory = new RiskeerProjectFactory(() => assessmentSectionFromFileHandler.GetAssessmentSectionFromFile()); - gui = new GuiCore(mainWindow, new StorageSqLite(), projectMigrator, new RiskeerProjectFactory(), settings) + gui = new GuiCore(mainWindow, new StorageSqLite(), projectMigrator, projectFactory, settings) { Plugins = { Index: Application/Riskeer/test/Application.Riskeer.Integration.Test/StorageMigrationIntegrationTest.cs =================================================================== diff -u -r886b86a66f072735567285a3489923186c236c32 -ra79026549254c82cf85550eb8fea2b7229bf9b1b --- Application/Riskeer/test/Application.Riskeer.Integration.Test/StorageMigrationIntegrationTest.cs (.../StorageMigrationIntegrationTest.cs) (revision 886b86a66f072735567285a3489923186c236c32) +++ Application/Riskeer/test/Application.Riskeer.Integration.Test/StorageMigrationIntegrationTest.cs (.../StorageMigrationIntegrationTest.cs) (revision a79026549254c82cf85550eb8fea2b7229bf9b1b) @@ -67,7 +67,7 @@ ApplicationIcon = Resources.Riskeer }; - using (var gui = new GuiCore(new MainWindow(), projectStore, projectMigrator, new RiskeerProjectFactory(), guiCoreSettings)) + using (var gui = new GuiCore(new MainWindow(), projectStore, projectMigrator, new RiskeerProjectFactory(() => null), guiCoreSettings)) { // When gui.Run(targetFilePath); @@ -110,7 +110,7 @@ ApplicationIcon = Resources.Riskeer }; - using (var gui = new GuiCore(new MainWindow(), projectStore, projectMigrator, new RiskeerProjectFactory(), guiCoreSettings)) + using (var gui = new GuiCore(new MainWindow(), projectStore, projectMigrator, new RiskeerProjectFactory(() => null), guiCoreSettings)) { // When @@ -144,7 +144,7 @@ var projectMigrator = new ProjectMigrator(inquiryHelper); - using (var gui = new GuiCore(new MainWindow(), projectStore, projectMigrator, new RiskeerProjectFactory(), new GuiCoreSettings())) + using (var gui = new GuiCore(new MainWindow(), projectStore, projectMigrator, new RiskeerProjectFactory(() => null), new GuiCoreSettings())) { // When gui.Run(sourceFilePath); Index: Core/Common/src/Core.Common.Base/Data/IProjectFactory.cs =================================================================== diff -u -rc5f13c0a18ac4de5ad65240eea191a15e1dfd235 -ra79026549254c82cf85550eb8fea2b7229bf9b1b --- Core/Common/src/Core.Common.Base/Data/IProjectFactory.cs (.../IProjectFactory.cs) (revision c5f13c0a18ac4de5ad65240eea191a15e1dfd235) +++ Core/Common/src/Core.Common.Base/Data/IProjectFactory.cs (.../IProjectFactory.cs) (revision a79026549254c82cf85550eb8fea2b7229bf9b1b) @@ -31,11 +31,9 @@ /// /// Creates a new instance of . /// - /// The func to perform - /// when the project is created. /// An empty object. /// Thrown when something /// went wrong while creating the object. - IProject CreateNewProject(Func onCreateNewProjectFunc); + IProject CreateNewProject(); } } \ No newline at end of file Index: Core/Gui/src/Core.Gui/Commands/IStorageCommands.cs =================================================================== diff -u -r8b7e959df30173881f81b817c4f6226546807f31 -ra79026549254c82cf85550eb8fea2b7229bf9b1b --- Core/Gui/src/Core.Gui/Commands/IStorageCommands.cs (.../IStorageCommands.cs) (revision 8b7e959df30173881f81b817c4f6226546807f31) +++ Core/Gui/src/Core.Gui/Commands/IStorageCommands.cs (.../IStorageCommands.cs) (revision a79026549254c82cf85550eb8fea2b7229bf9b1b) @@ -34,9 +34,7 @@ /// /// Closes the current project and creates a new one. /// - /// The func to perform - /// when the project is created. - void CreateNewProject(Func onCreateNewProjectFunc); + void CreateNewProject(); /// /// Checks whether the current project has unsaved changes. If so, these unsaved changes Index: Core/Gui/src/Core.Gui/Commands/StorageCommandHandler.cs =================================================================== diff -u -rc5f13c0a18ac4de5ad65240eea191a15e1dfd235 -ra79026549254c82cf85550eb8fea2b7229bf9b1b --- Core/Gui/src/Core.Gui/Commands/StorageCommandHandler.cs (.../StorageCommandHandler.cs) (revision c5f13c0a18ac4de5ad65240eea191a15e1dfd235) +++ Core/Gui/src/Core.Gui/Commands/StorageCommandHandler.cs (.../StorageCommandHandler.cs) (revision a79026549254c82cf85550eb8fea2b7229bf9b1b) @@ -102,7 +102,7 @@ return unsavedChangesHandled; } - public void CreateNewProject(Func onCreateNewProjectFunc) + public void CreateNewProject() { if (!HandleUnsavedChanges()) { @@ -115,7 +115,7 @@ IProject newProject; try { - newProject = projectFactory.CreateNewProject(onCreateNewProjectFunc); + newProject = projectFactory.CreateNewProject(); } catch (ProjectFactoryException e) { Index: Core/Gui/src/Core.Gui/Forms/Main/MainWindow.xaml.cs =================================================================== diff -u -ra4b9c5a2a6571b50027ecf632345182c1d96cdd1 -ra79026549254c82cf85550eb8fea2b7229bf9b1b --- Core/Gui/src/Core.Gui/Forms/Main/MainWindow.xaml.cs (.../MainWindow.xaml.cs) (revision a4b9c5a2a6571b50027ecf632345182c1d96cdd1) +++ Core/Gui/src/Core.Gui/Forms/Main/MainWindow.xaml.cs (.../MainWindow.xaml.cs) (revision a79026549254c82cf85550eb8fea2b7229bf9b1b) @@ -423,7 +423,7 @@ private void OnNewProject(object obj) { - commands.StorageCommands.CreateNewProject(() => settings.FixedSettings.OnCreateNewProjectFunc(gui)); + commands.StorageCommands.CreateNewProject(); CloseBackstage(); } Index: Core/Gui/test/Core.Gui.Test/Commands/StorageCommandHandlerTest.cs =================================================================== diff -u -r886b86a66f072735567285a3489923186c236c32 -ra79026549254c82cf85550eb8fea2b7229bf9b1b --- Core/Gui/test/Core.Gui.Test/Commands/StorageCommandHandlerTest.cs (.../StorageCommandHandlerTest.cs) (revision 886b86a66f072735567285a3489923186c236c32) +++ Core/Gui/test/Core.Gui.Test/Commands/StorageCommandHandlerTest.cs (.../StorageCommandHandlerTest.cs) (revision a79026549254c82cf85550eb8fea2b7229bf9b1b) @@ -47,7 +47,6 @@ { // Setup const string savedProjectPath = @"C:\savedProject.rtd"; - object OnCreateNewProjectFunc() => null; var oldProject = mocks.Stub(); var newProject = mocks.Stub(); @@ -59,7 +58,7 @@ projectOwner.Stub(po => po.ProjectFilePath).Return(savedProjectPath); var projectFactory = mocks.Stub(); - projectFactory.Stub(pf => pf.CreateNewProject(OnCreateNewProjectFunc)) + projectFactory.Stub(pf => pf.CreateNewProject()) .Return(newProject); projectOwner.Expect(po => po.SetProject(newProject, null)); @@ -77,7 +76,7 @@ mainWindowController); // Call - void Call() => storageCommandHandler.CreateNewProject(OnCreateNewProjectFunc); + void Call() => storageCommandHandler.CreateNewProject(); // Assert Tuple[] expectedMessages = @@ -94,14 +93,12 @@ public void CreateNewProject_ProjectFactoryReturnsNull_LogsMessage() { // Setup - object OnCreateNewProjectFunc() => null; - var projectStorage = mocks.Stub(); var projectMigrator = mocks.Stub(); var projectOwner = mocks.Stub(); var projectFactory = mocks.StrictMock(); - projectFactory.Stub(pf => pf.CreateNewProject(OnCreateNewProjectFunc)) + projectFactory.Stub(pf => pf.CreateNewProject()) .Return(null); var inquiryHelper = mocks.Stub(); @@ -118,7 +115,7 @@ mainWindowController); // Call - void Call() => storageCommandHandler.CreateNewProject(OnCreateNewProjectFunc); + void Call() => storageCommandHandler.CreateNewProject(); // Assert Tuple[] expectedMessages = @@ -136,14 +133,13 @@ { // Setup const string expectedExceptionMessage = "Error message"; - object OnCreateNewProjectFunc() => null; var projectStorage = mocks.Stub(); var projectMigrator = mocks.Stub(); var projectOwner = mocks.Stub(); var projectFactory = mocks.StrictMock(); - projectFactory.Stub(pf => pf.CreateNewProject(OnCreateNewProjectFunc)) + projectFactory.Stub(pf => pf.CreateNewProject()) .Throw(new ProjectFactoryException(expectedExceptionMessage)); var inquiryHelper = mocks.Stub(); @@ -160,7 +156,7 @@ mainWindowController); // Call - void Call() => storageCommandHandler.CreateNewProject(OnCreateNewProjectFunc); + void Call() => storageCommandHandler.CreateNewProject(); // Assert Tuple[] expectedMessages = @@ -369,8 +365,7 @@ var project = mocks.Stub(); var projectFactory = mocks.StrictMock(); - projectFactory.Expect(pf => pf.CreateNewProject(null)) - .IgnoreArguments() + projectFactory.Expect(pf => pf.CreateNewProject()) .Return(project) .Repeat.Never(); @@ -417,8 +412,7 @@ var project = mocks.Stub(); var projectFactory = mocks.StrictMock(); - projectFactory.Expect(pf => pf.CreateNewProject(null)) - .IgnoreArguments() + projectFactory.Expect(pf => pf.CreateNewProject()) .Return(project) .Repeat.Never(); @@ -462,8 +456,8 @@ var project = mocks.Stub(); var projectFactory = mocks.StrictMock(); - projectFactory.Stub(pf => pf.CreateNewProject(null)) - .IgnoreArguments().Return(project); + projectFactory.Stub(pf => pf.CreateNewProject()) + .Return(project); var projectOwner = mocks.Stub(); projectOwner.Stub(po => po.Project).Return(project); @@ -603,8 +597,7 @@ projectMigrator.Stub(m => m.ShouldMigrate(pathToSomeInvalidFile)).Return(MigrationRequired.No); var projectFactory = mocks.Stub(); - projectFactory.Stub(pf => pf.CreateNewProject(null)) - .IgnoreArguments() + projectFactory.Stub(pf => pf.CreateNewProject()) .Return(project); var projectOwner = mocks.Stub(); @@ -663,8 +656,7 @@ var projectMigrator = mocks.Stub(); var projectFactory = mocks.Stub(); - projectFactory.Stub(pf => pf.CreateNewProject(null)) - .IgnoreArguments() + projectFactory.Stub(pf => pf.CreateNewProject()) .Return(project); var projectOwner = mocks.Stub(); Index: Core/Gui/test/Core.Gui.Test/Forms/Main/MainWindowTest.cs =================================================================== diff -u -r5fad04eb4f743ebc8b04307b6c7c04b2d9fbbf36 -ra79026549254c82cf85550eb8fea2b7229bf9b1b --- Core/Gui/test/Core.Gui.Test/Forms/Main/MainWindowTest.cs (.../MainWindowTest.cs) (revision 5fad04eb4f743ebc8b04307b6c7c04b2d9fbbf36) +++ Core/Gui/test/Core.Gui.Test/Forms/Main/MainWindowTest.cs (.../MainWindowTest.cs) (revision a79026549254c82cf85550eb8fea2b7229bf9b1b) @@ -638,8 +638,7 @@ var projectStore = mocks.Stub(); var projectMigrator = mocks.Stub(); var projectFactory = mocks.Stub(); - projectFactory.Stub(pf => pf.CreateNewProject(null)) - .IgnoreArguments() + projectFactory.Stub(pf => pf.CreateNewProject()) .Return(mocks.Stub()); mocks.ReplayAll(); @@ -674,8 +673,7 @@ var projectStore = mocks.Stub(); var projectMigrator = mocks.Stub(); var projectFactory = mocks.Stub(); - projectFactory.Stub(pf => pf.CreateNewProject(null)) - .IgnoreArguments() + projectFactory.Stub(pf => pf.CreateNewProject()) .Return(mocks.Stub()); mocks.ReplayAll(); @@ -711,8 +709,7 @@ var projectStore = mocks.Stub(); var projectMigrator = mocks.Stub(); var projectFactory = mocks.Stub(); - projectFactory.Stub(pf => pf.CreateNewProject(null)) - .IgnoreArguments() + projectFactory.Stub(pf => pf.CreateNewProject()) .Return(mocks.Stub()); mocks.ReplayAll(); @@ -752,8 +749,7 @@ var projectStore = mocks.Stub(); var projectMigrator = mocks.Stub(); var projectFactory = mocks.Stub(); - projectFactory.Stub(pf => pf.CreateNewProject(null)) - .IgnoreArguments() + projectFactory.Stub(pf => pf.CreateNewProject()) .Return(mocks.Stub()); mocks.ReplayAll(); @@ -791,8 +787,7 @@ var projectStore = mocks.Stub(); var projectMigrator = mocks.Stub(); var projectFactory = mocks.Stub(); - projectFactory.Stub(pf => pf.CreateNewProject(null)) - .IgnoreArguments() + projectFactory.Stub(pf => pf.CreateNewProject()) .Return(mocks.Stub()); mocks.ReplayAll(); @@ -832,8 +827,7 @@ var projectStore = mocks.Stub(); var projectMigrator = mocks.Stub(); var projectFactory = mocks.Stub(); - projectFactory.Stub(pf => pf.CreateNewProject(null)) - .IgnoreArguments() + projectFactory.Stub(pf => pf.CreateNewProject()) .Return(mocks.Stub()); mocks.ReplayAll(); @@ -869,8 +863,7 @@ var projectStore = mocks.Stub(); var projectMigrator = mocks.Stub(); var projectFactory = mocks.Stub(); - projectFactory.Stub(pf => pf.CreateNewProject(null)) - .IgnoreArguments() + projectFactory.Stub(pf => pf.CreateNewProject()) .Return(mocks.Stub()); mocks.ReplayAll(); @@ -910,8 +903,7 @@ var projectStore = mocks.Stub(); var projectMigrator = mocks.Stub(); var projectFactory = mocks.Stub(); - projectFactory.Stub(pf => pf.CreateNewProject(null)) - .IgnoreArguments() + projectFactory.Stub(pf => pf.CreateNewProject()) .Return(mocks.Stub()); mocks.ReplayAll(); @@ -949,8 +941,7 @@ var projectStore = mocks.Stub(); var projectMigrator = mocks.Stub(); var projectFactory = mocks.Stub(); - projectFactory.Stub(pf => pf.CreateNewProject(null)) - .IgnoreArguments() + projectFactory.Stub(pf => pf.CreateNewProject()) .Return(mocks.Stub()); mocks.ReplayAll(); @@ -992,8 +983,7 @@ var projectStore = mocks.Stub(); var projectMigrator = mocks.Stub(); var projectFactory = mocks.StrictMock(); - projectFactory.Expect(pf => pf.CreateNewProject(null)) - .IgnoreArguments() + projectFactory.Expect(pf => pf.CreateNewProject()) .Return(mocks.Stub()); mocks.ReplayAll(); @@ -1042,8 +1032,7 @@ var projectMigrator = mocks.Stub(); var projectFactory = mocks.Stub(); - projectFactory.Stub(pf => pf.CreateNewProject(null)) - .IgnoreArguments() + projectFactory.Stub(pf => pf.CreateNewProject()) .Return(project); mocks.ReplayAll(); @@ -1110,8 +1099,7 @@ var projectMigrator = mocks.Stub(); var projectFactory = mocks.Stub(); - projectFactory.Stub(pf => pf.CreateNewProject(null)) - .IgnoreArguments() + projectFactory.Stub(pf => pf.CreateNewProject()) .Return(project); mocks.ReplayAll(); @@ -1174,8 +1162,7 @@ var projectMigrator = mocks.Stub(); var projectFactory = mocks.Stub(); - projectFactory.Stub(pf => pf.CreateNewProject(null)) - .IgnoreArguments() + projectFactory.Stub(pf => pf.CreateNewProject()) .Return(project); mocks.ReplayAll(); @@ -1227,8 +1214,7 @@ var projectStore = mocks.Stub(); var projectMigrator = mocks.Stub(); var projectFactory = mocks.Stub(); - projectFactory.Stub(pf => pf.CreateNewProject(null)) - .IgnoreArguments() + projectFactory.Stub(pf => pf.CreateNewProject()) .Return(project); mocks.ReplayAll(); @@ -1258,8 +1244,7 @@ var projectStore = mocks.Stub(); var projectMigrator = mocks.Stub(); var projectFactory = mocks.Stub(); - projectFactory.Stub(pf => pf.CreateNewProject(null)) - .IgnoreArguments() + projectFactory.Stub(pf => pf.CreateNewProject()) .Return(project); mocks.ReplayAll(); @@ -1293,8 +1278,7 @@ var projectStore = mocks.Stub(); var projectMigrator = mocks.Stub(); var projectFactory = mocks.Stub(); - projectFactory.Stub(pf => pf.CreateNewProject(null)) - .IgnoreArguments() + projectFactory.Stub(pf => pf.CreateNewProject()) .Return(project); mocks.ReplayAll(); @@ -1332,8 +1316,7 @@ var projectStore = mocks.Stub(); var projectMigrator = mocks.Stub(); var projectFactory = mocks.Stub(); - projectFactory.Stub(pf => pf.CreateNewProject(null)) - .IgnoreArguments() + projectFactory.Stub(pf => pf.CreateNewProject()) .Return(mocks.Stub()); mocks.ReplayAll(); Index: Core/Gui/test/Core.Gui.Test/GuiCoreTest.cs =================================================================== diff -u -r6504c30fb7148a96d46f6971c4a3621d7e4d79fe -ra79026549254c82cf85550eb8fea2b7229bf9b1b --- Core/Gui/test/Core.Gui.Test/GuiCoreTest.cs (.../GuiCoreTest.cs) (revision 6504c30fb7148a96d46f6971c4a3621d7e4d79fe) +++ Core/Gui/test/Core.Gui.Test/GuiCoreTest.cs (.../GuiCoreTest.cs) (revision a79026549254c82cf85550eb8fea2b7229bf9b1b) @@ -590,8 +590,7 @@ var project = mocks.Stub(); projectStore.Expect(ps => ps.LoadProject(testFile)).Return(project); var projectFactory = mocks.Stub(); - projectFactory.Stub(pf => pf.CreateNewProject(null)) - .IgnoreArguments() + projectFactory.Stub(pf => pf.CreateNewProject()) .Return(project); mocks.ReplayAll(); @@ -1502,8 +1501,7 @@ private static IProjectFactory CreateProjectFactory(MockRepository mocks) { var projectFactory = mocks.Stub(); - projectFactory.Stub(pf => pf.CreateNewProject(null)) - .IgnoreArguments() + projectFactory.Stub(pf => pf.CreateNewProject()) .Return(mocks.Stub()); return projectFactory; Index: Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerProjectFactory.cs =================================================================== diff -u -r7f397d62e5fd14b5202c620c2aed09b79f8f94c8 -ra79026549254c82cf85550eb8fea2b7229bf9b1b --- Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerProjectFactory.cs (.../RiskeerProjectFactory.cs) (revision 7f397d62e5fd14b5202c620c2aed09b79f8f94c8) +++ Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerProjectFactory.cs (.../RiskeerProjectFactory.cs) (revision a79026549254c82cf85550eb8fea2b7229bf9b1b) @@ -32,39 +32,53 @@ /// public class RiskeerProjectFactory : IProjectFactory { + private readonly Func createAssessmentSectionFunc; + + /// + /// Creates a new instance of . + /// + /// The + /// to create an . + /// Thrown when + /// is null. + public RiskeerProjectFactory(Func createAssessmentSectionFunc) + { + if (createAssessmentSectionFunc == null) + { + throw new ArgumentNullException(nameof(createAssessmentSectionFunc)); + } + + this.createAssessmentSectionFunc = createAssessmentSectionFunc; + } + /// /// A ; or null when there /// is no . - /// Thrown when - /// is null. - public IProject CreateNewProject(Func onCreateNewProjectFunc) + public IProject CreateNewProject() { - if (onCreateNewProjectFunc == null) - { - throw new ArgumentNullException(nameof(onCreateNewProjectFunc)); - } + AssessmentSection assessmentSection; try { - var assessmentSection = (AssessmentSection) onCreateNewProjectFunc(); - - if (assessmentSection == null) - { - return null; - } - - return new RiskeerProject - { - AssessmentSections = - { - assessmentSection - } - }; + assessmentSection = createAssessmentSectionFunc(); } catch (Exception e) when (e is CriticalFileReadException || e is CriticalFileValidationException) { throw new ProjectFactoryException(e.Message, e); } + + if (assessmentSection == null) + { + return null; + } + + return new RiskeerProject + { + AssessmentSections = + { + assessmentSection + } + }; } } } \ No newline at end of file Index: Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/RiskeerPluginTest.cs =================================================================== diff -u -r886b86a66f072735567285a3489923186c236c32 -ra79026549254c82cf85550eb8fea2b7229bf9b1b --- Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/RiskeerPluginTest.cs (.../RiskeerPluginTest.cs) (revision 886b86a66f072735567285a3489923186c236c32) +++ Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/RiskeerPluginTest.cs (.../RiskeerPluginTest.cs) (revision a79026549254c82cf85550eb8fea2b7229bf9b1b) @@ -88,7 +88,7 @@ var projectMigrator = mocks.Stub(); mocks.ReplayAll(); - using (var gui = new GuiCore(new MainWindow(), projectStore, projectMigrator, new RiskeerProjectFactory(), new GuiCoreSettings())) + using (var gui = new GuiCore(new MainWindow(), projectStore, projectMigrator, new RiskeerProjectFactory(() => null), new GuiCoreSettings())) { SetPlugins(gui); gui.Run(); @@ -125,7 +125,7 @@ string testDataDir = TestHelper.GetTestDataPath(TestDataPath.Riskeer.Common.IO, nameof(HydraulicBoundaryDatabase)); string testFilePath = Path.Combine(testDataDir, "complete.sqlite"); - using (var gui = new GuiCore(new MainWindow(), projectStore, projectMigrator, new RiskeerProjectFactory(), new GuiCoreSettings())) + using (var gui = new GuiCore(new MainWindow(), projectStore, projectMigrator, new RiskeerProjectFactory(() => null), new GuiCoreSettings())) { SetPlugins(gui); gui.Run(); @@ -168,7 +168,7 @@ var projectMigrator = mocks.Stub(); mocks.ReplayAll(); - using (var gui = new GuiCore(new MainWindow(), projectStore, projectMigrator, new RiskeerProjectFactory(), new GuiCoreSettings())) + using (var gui = new GuiCore(new MainWindow(), projectStore, projectMigrator, new RiskeerProjectFactory(() => null), new GuiCoreSettings())) { SetPlugins(gui); gui.Run(); Index: Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/RiskeerProjectFactoryTest.cs =================================================================== diff -u -r2bb78c041989c4970c56a3d74f0afa82083625ae -ra79026549254c82cf85550eb8fea2b7229bf9b1b --- Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/RiskeerProjectFactoryTest.cs (.../RiskeerProjectFactoryTest.cs) (revision 2bb78c041989c4970c56a3d74f0afa82083625ae) +++ Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/RiskeerProjectFactoryTest.cs (.../RiskeerProjectFactoryTest.cs) (revision a79026549254c82cf85550eb8fea2b7229bf9b1b) @@ -33,28 +33,24 @@ public class RiskeerProjectFactoryTest { [Test] - public void CreateNewProject_OnCreateNewProjectFuncNull_ThrowsArgumentNullException() + public void Constructor_CreateAssessmentSectionFuncNull_ThrowsArgumentNullException() { - // Setup - var projectFactory = new RiskeerProjectFactory(); - // Call - void Call() => projectFactory.CreateNewProject(null); + void Call() => new RiskeerProjectFactory(null); // Assert var exception = Assert.Throws(Call); - Assert.AreEqual("onCreateNewProjectFunc", exception.ParamName); + Assert.AreEqual("createAssessmentSectionFunc", exception.ParamName); } - [Test] - public void CreateNewProject_WithOnCreateNewProjectFuncReturnAssessmentSection_ReturnsNewRiskeerProject() + public void CreateNewProject_WithCreateAssessmentSectionFuncReturnAssessmentSection_ReturnsNewRiskeerProject() { // Setup - var projectFactory = new RiskeerProjectFactory(); var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + var projectFactory = new RiskeerProjectFactory(() => assessmentSection); // Call - IProject project = projectFactory.CreateNewProject(() => assessmentSection); + IProject project = projectFactory.CreateNewProject(); // Assert Assert.IsInstanceOf(project); @@ -66,42 +62,42 @@ } [Test] - public void CreateNewProject_WithOnCreateNewProjectFuncReturnNull_ReturnsNull() + public void CreateNewProject_WithCreateAssessmentSectionFuncReturnNull_ReturnsNull() { // Setup - var projectFactory = new RiskeerProjectFactory(); + var projectFactory = new RiskeerProjectFactory(() => null); // Call - IProject project = projectFactory.CreateNewProject(() => null); + IProject project = projectFactory.CreateNewProject(); // Assert Assert.IsNull(project); } [Test] - public void CreateNewProject_WithOnCreateNewProjectFuncThrowsException_ThrowsException() + public void CreateNewProject_WithCreateAssessmentSectionFuncThrowsException_ThrowsException() { // Setup - var projectFactory = new RiskeerProjectFactory(); const string expectedMessage = "Exception message test"; + var projectFactory = new RiskeerProjectFactory(() => throw new Exception(expectedMessage)); // Call - void Call() => projectFactory.CreateNewProject(() => throw new Exception(expectedMessage)); + void Call() => projectFactory.CreateNewProject(); // Assert var exception = Assert.Throws(Call); Assert.AreEqual(expectedMessage, exception.Message); } [Test] - public void CreateNewProject_WithOnCreateNewProjectFuncThrowsCriticalFileReadException_ThrowsProjectFactoryException() + public void CreateNewProject_WithCreateAssessmentSectionFuncThrowsCriticalFileReadException_ThrowsProjectFactoryException() { // Setup - var projectFactory = new RiskeerProjectFactory(); const string expectedMessage = "Exception message test"; + var projectFactory = new RiskeerProjectFactory(() => throw new CriticalFileReadException(expectedMessage)); // Call - void Call() => projectFactory.CreateNewProject(() => throw new CriticalFileReadException(expectedMessage)); + void Call() => projectFactory.CreateNewProject(); // Assert var exception = Assert.Throws(Call); @@ -110,14 +106,14 @@ } [Test] - public void CreateNewProject_WithOnCreateNewProjectFuncThrowsCriticalFileValidationException_ThrowsProjectFactoryException() + public void CreateNewProject_WithCreateAssessmentSectionFuncThrowsCriticalFileValidationException_ThrowsProjectFactoryException() { // Setup - var projectFactory = new RiskeerProjectFactory(); const string expectedMessage = "Exception message test"; + var projectFactory = new RiskeerProjectFactory(() => throw new CriticalFileValidationException(expectedMessage)); // Call - void Call() => projectFactory.CreateNewProject(() => throw new CriticalFileValidationException(expectedMessage)); + void Call() => projectFactory.CreateNewProject(); // Assert var exception = Assert.Throws(Call); Index: Riskeer/Storage/test/Riskeer.Storage.Core.Test/IntegrationTests/StorageSqLiteIntegrationTest.cs =================================================================== diff -u -r886b86a66f072735567285a3489923186c236c32 -ra79026549254c82cf85550eb8fea2b7229bf9b1b --- Riskeer/Storage/test/Riskeer.Storage.Core.Test/IntegrationTests/StorageSqLiteIntegrationTest.cs (.../StorageSqLiteIntegrationTest.cs) (revision 886b86a66f072735567285a3489923186c236c32) +++ Riskeer/Storage/test/Riskeer.Storage.Core.Test/IntegrationTests/StorageSqLiteIntegrationTest.cs (.../StorageSqLiteIntegrationTest.cs) (revision a79026549254c82cf85550eb8fea2b7229bf9b1b) @@ -192,7 +192,7 @@ ApplicationIcon = CoreGuiTestUtilResources.TestIcon }; - using (var gui = new GuiCore(new MainWindow(), projectStore, projectMigrator, new RiskeerProjectFactory(), guiCoreSettings)) + using (var gui = new GuiCore(new MainWindow(), projectStore, projectMigrator, new RiskeerProjectFactory(() => null), guiCoreSettings)) { // When void Action() => gui.Run(projectFilePath);