Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PersistenceRegistry.cs =================================================================== diff -u -r3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6 -r1eed3e3f652618c52a462edc502cfd4250772314 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PersistenceRegistry.cs (.../PersistenceRegistry.cs) (revision 3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PersistenceRegistry.cs (.../PersistenceRegistry.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -22,13 +22,9 @@ using System; using System.Collections.Generic; using System.Linq; - using Application.Ringtoets.Storage.DbContext; - -using Core.Common.Base.Data; using Core.Common.Base.Geometry; using Core.Common.Utils; - using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Data.Probability; @@ -50,7 +46,7 @@ /// internal class PersistenceRegistry { - private readonly Dictionary projects = new Dictionary(new ReferenceEqualityComparer()); + private readonly Dictionary projects = new Dictionary(new ReferenceEqualityComparer()); private readonly Dictionary assessmentSections = new Dictionary(new ReferenceEqualityComparer()); private readonly Dictionary failureMechanisms = new Dictionary(new ReferenceEqualityComparer()); private readonly Dictionary failureMechanismSections = new Dictionary(); @@ -550,13 +546,13 @@ /// that was constructed with the information. /// /// The to be registered. - /// The to be registered. + /// The to be registered. /// Thrown when either: /// /// is null /// is null /// - internal void Register(ProjectEntity entity, Project model) + internal void Register(ProjectEntity entity, RingtoetsProject model) { Register(projects, entity, model); } Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/ProjectCreateExtensions.cs =================================================================== diff -u -rae6f0c6b534ca650e160ae6d9c0bc90369d25c68 -r1eed3e3f652618c52a462edc502cfd4250772314 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/ProjectCreateExtensions.cs (.../ProjectCreateExtensions.cs) (revision ae6f0c6b534ca650e160ae6d9c0bc90369d25c68) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/ProjectCreateExtensions.cs (.../ProjectCreateExtensions.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -20,26 +20,25 @@ // All rights reserved. using System; -using System.Linq; using Application.Ringtoets.Storage.DbContext; using Core.Common.Base.Data; using Ringtoets.Integration.Data; namespace Application.Ringtoets.Storage.Create { /// - /// Extension methods for related to creating database entities. + /// Extension methods for related to creating database entities. /// internal static class ProjectCreateExtensions { /// - /// Creates a based on the information of the . + /// Creates a based on the information of the . /// /// The project to create a database entity for. /// The object keeping track of create operations. /// A new . /// Thrown when is null. - internal static ProjectEntity Create(this Project project, PersistenceRegistry registry) + internal static ProjectEntity Create(this RingtoetsProject project, PersistenceRegistry registry) { if (registry == null) { @@ -57,9 +56,9 @@ return entity; } - private static void AddEntitiesForAssessmentSections(Project project, ProjectEntity entity, PersistenceRegistry registry) + private static void AddEntitiesForAssessmentSections(RingtoetsProject project, ProjectEntity entity, PersistenceRegistry registry) { - foreach (var result in project.Items.OfType()) + foreach (var result in project.Items) { entity.AssessmentSectionEntities.Add(result.Create(registry)); } Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ProjectEntityReadExtensions.cs =================================================================== diff -u -r062281754a35164e1095479c9f1ccb8ee821f939 -r1eed3e3f652618c52a462edc502cfd4250772314 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ProjectEntityReadExtensions.cs (.../ProjectEntityReadExtensions.cs) (revision 062281754a35164e1095479c9f1ccb8ee821f939) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ProjectEntityReadExtensions.cs (.../ProjectEntityReadExtensions.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -21,30 +21,30 @@ using System; using Application.Ringtoets.Storage.DbContext; -using Core.Common.Base.Data; +using Ringtoets.Integration.Data; namespace Application.Ringtoets.Storage.Read { /// - /// This class defines extension methods for read operations for a based on the + /// This class defines extension methods for read operations for an based on the /// . /// internal static class ProjectEntityReadExtensions { /// - /// Reads the and use the information to construct a . + /// Reads the and use the information to construct a . /// - /// The to create for. + /// The to create for. /// The object keeping track of read operations. - /// A new . + /// A new . /// Thrown when is null. - internal static Project Read(this ProjectEntity entity, ReadConversionCollector collector) + internal static RingtoetsProject Read(this ProjectEntity entity, ReadConversionCollector collector) { if (collector == null) { throw new ArgumentNullException("collector"); } - var project = new Project + var project = new RingtoetsProject { StorageId = entity.ProjectEntityId, Description = entity.Description Index: Application/Ringtoets/src/Application.Ringtoets.Storage/StorageSqLite.cs =================================================================== diff -u -r669853e6468fcf1301a64f5df1400456fe6929eb -r1eed3e3f652618c52a462edc502cfd4250772314 --- Application/Ringtoets/src/Application.Ringtoets.Storage/StorageSqLite.cs (.../StorageSqLite.cs) (revision 669853e6468fcf1301a64f5df1400456fe6929eb) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/StorageSqLite.cs (.../StorageSqLite.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -34,6 +34,7 @@ using Core.Common.Base.Storage; using Core.Common.Utils; using Core.Common.Utils.Builders; +using Ringtoets.Integration.Data; using UtilsResources = Core.Common.Utils.Properties.Resources; namespace Application.Ringtoets.Storage @@ -57,8 +58,7 @@ /// Converts to a new in the database. /// /// Path to database file. - /// to save. - /// Returns the number of changes that were saved in . + /// to save. /// Thrown when is null. /// is invalid. /// No file is present at @@ -71,9 +71,9 @@ /// The connection to the database file failed. /// /// - public void SaveProjectAs(string databaseFilePath, Project project) + public void SaveProjectAs(string databaseFilePath, IProject project) { - if (project == null) + if (!(project is RingtoetsProject)) { throw new ArgumentNullException("project"); } @@ -84,7 +84,7 @@ try { SetConnectionToNewFile(databaseFilePath); - SaveProjectInDatabase(databaseFilePath, project); + SaveProjectInDatabase(databaseFilePath, (RingtoetsProject) project); } catch { @@ -98,8 +98,7 @@ /// Converts to an existing in the database. /// /// Path to database file. - /// to save. - /// Returns the number of changes that were saved in . + /// to save. /// Thrown when is null. /// is invalid. /// No file is present at @@ -113,9 +112,9 @@ /// The related entity was not found in the database. Therefore, no update was possible. /// /// - public void SaveProject(string databaseFilePath, Project project) + public void SaveProject(string databaseFilePath, IProject project) { - if (project == null) + if (!(project is RingtoetsProject)) { throw new ArgumentNullException("project"); } @@ -129,11 +128,11 @@ SaveProjectAs(databaseFilePath, project); } - UpdateProjectInDatabase(databaseFilePath, project); + UpdateProjectInDatabase(databaseFilePath, (RingtoetsProject) project); } /// - /// Attempts to load the from the SQLite database. + /// Attempts to load the from the SQLite database. /// /// Path to database file. /// Returns a new instance of with the data from the database or null when not found. @@ -146,7 +145,7 @@ /// The related entity was not found in the database. /// /// - public Project LoadProject(string databaseFilePath) + public IProject LoadProject(string databaseFilePath) { SetConnectionToExistingFile(databaseFilePath); try @@ -185,7 +184,7 @@ connectionString = null; } - public bool HasChanges(Project project) + public bool HasChanges(IProject project) { if (string.IsNullOrWhiteSpace(connectionString)) { @@ -196,8 +195,9 @@ { try { + var ringtoetsProject = (RingtoetsProject) project; var persistenceRegistry = new PersistenceRegistry(); - project.Update(persistenceRegistry, dbContext); + ringtoetsProject.Update(persistenceRegistry, dbContext); persistenceRegistry.RemoveUntouched(dbContext); return dbContext.ChangeTracker.HasChanges(); @@ -214,7 +214,7 @@ } /// - /// Cleans up a new . + /// Cleans up a new . /// /// The to use for cleaning up. /// Value indicating whether the should revert to @@ -253,7 +253,7 @@ } } - private void SaveProjectInDatabase(string databaseFilePath, Project project) + private void SaveProjectInDatabase(string databaseFilePath, RingtoetsProject project) { using (var dbContext = new RingtoetsEntities(connectionString)) { @@ -281,7 +281,7 @@ } } - private void UpdateProjectInDatabase(string databaseFilePath, Project project) + private void UpdateProjectInDatabase(string databaseFilePath, RingtoetsProject project) { using (var dbContext = new RingtoetsEntities(connectionString)) { Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/ProjectUpdateExtensions.cs =================================================================== diff -u -r5b3736b5350315a520f72c90222af261ea651019 -r1eed3e3f652618c52a462edc502cfd4250772314 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/ProjectUpdateExtensions.cs (.../ProjectUpdateExtensions.cs) (revision 5b3736b5350315a520f72c90222af261ea651019) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/ProjectUpdateExtensions.cs (.../ProjectUpdateExtensions.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -20,23 +20,21 @@ // All rights reserved. using System; -using System.Linq; using Application.Ringtoets.Storage.Create; using Application.Ringtoets.Storage.DbContext; using Application.Ringtoets.Storage.Exceptions; -using Core.Common.Base.Data; using Ringtoets.Integration.Data; namespace Application.Ringtoets.Storage.Update { /// - /// Extension methods for related to updating a . + /// Extension methods for related to updating a . /// internal static class ProjectUpdateExtensions { /// /// Updates a in the database based on the information of the - /// . + /// . /// /// The project to update the database entity for. /// The object keeping track of update operations. @@ -48,7 +46,7 @@ /// /// When /// does not have a corresponding entity in the database. - internal static void Update(this Project project, PersistenceRegistry registry, IRingtoetsEntities context) + internal static void Update(this RingtoetsProject project, PersistenceRegistry registry, IRingtoetsEntities context) { if (context == null) { @@ -65,7 +63,7 @@ entity.Description = project.Description; - foreach (var result in project.Items.OfType()) + foreach (var result in project.Items) { if (result.IsNew()) { Index: Application/Ringtoets/src/Application.Ringtoets/App.xaml.cs =================================================================== diff -u -rc5717eada81586126cbf53266abb0fc925382393 -r1eed3e3f652618c52a462edc502cfd4250772314 --- Application/Ringtoets/src/Application.Ringtoets/App.xaml.cs (.../App.xaml.cs) (revision c5717eada81586126cbf53266abb0fc925382393) +++ Application/Ringtoets/src/Application.Ringtoets/App.xaml.cs (.../App.xaml.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -45,6 +45,7 @@ using log4net; using Ringtoets.GrassCoverErosionInwards.Plugin; using Ringtoets.HeightStructures.Plugin; +using Ringtoets.Integration.Data; using Ringtoets.Integration.Plugin; using Ringtoets.Piping.Plugin; using MessageBox = System.Windows.MessageBox; @@ -146,7 +147,7 @@ ManualFilePath = "Ringtoets_Manual.pdf" }; var mainWindow = new MainWindow(); - gui = new GuiCore(mainWindow, new StorageSqLite(), settings) + gui = new GuiCore(mainWindow, new StorageSqLite(), new RingtoetsProjectFactory(), settings) { Plugins = { Index: Application/Ringtoets/src/Application.Ringtoets/Application.Ringtoets.csproj =================================================================== diff -u -rc5717eada81586126cbf53266abb0fc925382393 -r1eed3e3f652618c52a462edc502cfd4250772314 --- Application/Ringtoets/src/Application.Ringtoets/Application.Ringtoets.csproj (.../Application.Ringtoets.csproj) (revision c5717eada81586126cbf53266abb0fc925382393) +++ Application/Ringtoets/src/Application.Ringtoets/Application.Ringtoets.csproj (.../Application.Ringtoets.csproj) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -166,6 +166,10 @@ Ringtoets.HeightStructures.Plugin False + + {11F1F874-45AF-43E4-8AE5-15A5C9593E28} + Ringtoets.Integration.Data + {c8383b76-b3f1-4e6e-b56c-527b469fa20a} Ringtoets.Integration.Plugin Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PersistenceRegistryTest.cs =================================================================== diff -u -r3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6 -r1eed3e3f652618c52a462edc502cfd4250772314 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PersistenceRegistryTest.cs (.../PersistenceRegistryTest.cs) (revision 3ddadfbc5e096c8df7d709be0d9a9057cf4b8dd6) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PersistenceRegistryTest.cs (.../PersistenceRegistryTest.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -21,18 +21,12 @@ using System; using System.Linq; - using Application.Ringtoets.Storage.Create; using Application.Ringtoets.Storage.DbContext; using Application.Ringtoets.Storage.TestUtil; - -using Core.Common.Base.Data; using Core.Common.Base.Geometry; - using NUnit.Framework; - using Rhino.Mocks; - using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.FailureMechanism; @@ -53,6 +47,22 @@ [TestFixture] public class PersistenceRegistryTest { + private static DikeProfile CreateDikeProfile() + { + return new DikeProfile(new Point2D(0, 0), + new[] + { + new RoughnessPoint(new Point2D(1, 2), 0.75), + new RoughnessPoint(new Point2D(3, 4), 0.75) + }, + new[] + { + new Point2D(5, 6), + new Point2D(7, 8) + }, + null, new DikeProfile.ConstructionProperties()); + } + #region Contains methods [Test] @@ -62,7 +72,7 @@ var registry = new PersistenceRegistry(); // Call - TestDelegate test = () => registry.Contains((PipingSoilProfile)null); + TestDelegate test = () => registry.Contains((PipingSoilProfile) null); // Assert var paramName = Assert.Throws(test).ParamName; @@ -120,7 +130,7 @@ var registry = new PersistenceRegistry(); // Call - TestDelegate test = () => registry.Contains((RingtoetsPipingSurfaceLine)null); + TestDelegate test = () => registry.Contains((RingtoetsPipingSurfaceLine) null); // Assert var paramName = Assert.Throws(test).ParamName; @@ -178,7 +188,7 @@ var registry = new PersistenceRegistry(); // Call - TestDelegate test = () => registry.Contains((HydraulicBoundaryLocation)null); + TestDelegate test = () => registry.Contains((HydraulicBoundaryLocation) null); // Assert var paramName = Assert.Throws(test).ParamName; @@ -236,7 +246,7 @@ var registry = new PersistenceRegistry(); // Call - TestDelegate test = () => registry.Contains((StochasticSoilModel)null); + TestDelegate test = () => registry.Contains((StochasticSoilModel) null); // Assert var paramName = Assert.Throws(test).ParamName; @@ -294,7 +304,7 @@ var registry = new PersistenceRegistry(); // Call - TestDelegate test = () => registry.Contains((StochasticSoilProfile)null); + TestDelegate test = () => registry.Contains((StochasticSoilProfile) null); // Assert var paramName = Assert.Throws(test).ParamName; @@ -400,7 +410,7 @@ var registry = new PersistenceRegistry(); // Call - TestDelegate test = () => registry.Get((PipingSoilProfile)null); + TestDelegate test = () => registry.Get((PipingSoilProfile) null); // Assert var paramName = Assert.Throws(test).ParamName; @@ -459,7 +469,7 @@ var registry = new PersistenceRegistry(); // Call - TestDelegate test = () => registry.Get((RingtoetsPipingSurfaceLine)null); + TestDelegate test = () => registry.Get((RingtoetsPipingSurfaceLine) null); // Assert var paramName = Assert.Throws(test).ParamName; @@ -518,7 +528,7 @@ var registry = new PersistenceRegistry(); // Call - TestDelegate test = () => registry.Get((HydraulicBoundaryLocation)null); + TestDelegate test = () => registry.Get((HydraulicBoundaryLocation) null); // Assert var paramName = Assert.Throws(test).ParamName; @@ -577,7 +587,7 @@ var registry = new PersistenceRegistry(); // Call - TestDelegate test = () => registry.Get((StochasticSoilModel)null); + TestDelegate test = () => registry.Get((StochasticSoilModel) null); // Assert var paramName = Assert.Throws(test).ParamName; @@ -636,7 +646,7 @@ var registry = new PersistenceRegistry(); // Call - TestDelegate test = () => registry.Get((StochasticSoilProfile)null); + TestDelegate test = () => registry.Get((StochasticSoilProfile) null); // Assert var paramName = Assert.Throws(test).ParamName; @@ -695,7 +705,7 @@ var registry = new PersistenceRegistry(); // Call - TestDelegate test = () => registry.Get((FailureMechanismSection)null); + TestDelegate test = () => registry.Get((FailureMechanismSection) null); // Assert var paramName = Assert.Throws(test).ParamName; @@ -775,7 +785,7 @@ var registry = new PersistenceRegistry(); // Call - TestDelegate test = () => registry.Register(null, new Project()); + TestDelegate test = () => registry.Register(null, new RingtoetsProject()); // Assert var paramName = Assert.Throws(test).ParamName; @@ -1792,7 +1802,7 @@ var registry = new PersistenceRegistry(); // Call - TestDelegate call = () => registry.Register((SurfaceLinePointEntity)null, new Point3D(1.1, 2.2, 3.3)); + TestDelegate call = () => registry.Register((SurfaceLinePointEntity) null, new Point3D(1.1, 2.2, 3.3)); // Assert var paramName = Assert.Throws(call).ParamName; @@ -1820,7 +1830,7 @@ var registry = new PersistenceRegistry(); // Call - TestDelegate call = () => registry.Register((CharacteristicPointEntity)null, new Point3D(1.1, 2.2, 3.3)); + TestDelegate call = () => registry.Register((CharacteristicPointEntity) null, new Point3D(1.1, 2.2, 3.3)); // Assert var paramName = Assert.Throws(call).ParamName; @@ -1884,7 +1894,7 @@ { ProjectEntityId = storageId }; - var model = new Project(); + var model = new RingtoetsProject(); registry.Register(entity, model); // Call @@ -2739,7 +2749,7 @@ dbContext.ProjectEntities.Add(orphanedEntity); dbContext.ProjectEntities.Add(persistentEntity); - var project = new Project + var project = new RingtoetsProject { StorageId = persistentEntity.ProjectEntityId }; @@ -3023,7 +3033,7 @@ dbContext.GrassCoverErosionInwardsOutputEntities.Add(orphanedEntity); dbContext.GrassCoverErosionInwardsOutputEntities.Add(persistentEntity); - var calculation = new GrassCoverErosionInwardsOutput(1, false, new ProbabilityAssessmentOutput(1,1,1,1,1), 1) + var calculation = new GrassCoverErosionInwardsOutput(1, false, new ProbabilityAssessmentOutput(1, 1, 1, 1, 1), 1) { StorageId = persistentEntity.GrassCoverErosionInwardsOutputId }; @@ -4158,21 +4168,5 @@ } #endregion - - private static DikeProfile CreateDikeProfile() - { - return new DikeProfile(new Point2D(0, 0), - new[] - { - new RoughnessPoint(new Point2D(1, 2), 0.75), - new RoughnessPoint(new Point2D(3, 4), 0.75) - }, - new[] - { - new Point2D(5, 6), - new Point2D(7, 8) - }, - null, new DikeProfile.ConstructionProperties()); - } } } \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/ProjectCreateExtensionsTest.cs =================================================================== diff -u -rae6f0c6b534ca650e160ae6d9c0bc90369d25c68 -r1eed3e3f652618c52a462edc502cfd4250772314 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/ProjectCreateExtensionsTest.cs (.../ProjectCreateExtensionsTest.cs) (revision ae6f0c6b534ca650e160ae6d9c0bc90369d25c68) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/ProjectCreateExtensionsTest.cs (.../ProjectCreateExtensionsTest.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -21,7 +21,6 @@ using System; using Application.Ringtoets.Storage.Create; -using Core.Common.Base.Data; using NUnit.Framework; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Integration.Data; @@ -35,7 +34,7 @@ public void Create_WithoutPersistenceRegistry_ThrowsArgumentNullException() { // Setup - var project = new Project(); + var project = new RingtoetsProject(); // Call TestDelegate test = () => project.Create(null); @@ -50,7 +49,7 @@ { // Setup var testdescription = "testDescription"; - var project = new Project + var project = new RingtoetsProject { Description = testdescription }; @@ -68,7 +67,7 @@ public void Create_WithAssessmentSections_AddsSectionsToEntity() { // Setup - var project = new Project + var project = new RingtoetsProject { Items = { Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/StorageSqLiteIntegrationTest.cs =================================================================== diff -u -r6917c98a7820943d62df19669a6551bb76bbf851 -r1eed3e3f652618c52a462edc502cfd4250772314 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/StorageSqLiteIntegrationTest.cs (.../StorageSqLiteIntegrationTest.cs) (revision 6917c98a7820943d62df19669a6551bb76bbf851) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/StorageSqLiteIntegrationTest.cs (.../StorageSqLiteIntegrationTest.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -26,7 +26,6 @@ using System.Windows.Threading; using Application.Ringtoets.Storage.TestUtil; using Core.Common.Base; -using Core.Common.Base.Data; using Core.Common.Base.Geometry; using Core.Common.Gui; using Core.Common.Gui.Forms.MainWindow; @@ -63,21 +62,21 @@ public void SaveProjectAs_SaveAsNewFile_ProjectAsEntitiesInBothFiles() { // Setup - Project fullProject = RingtoetsProjectHelper.GetFullTestProject(); + RingtoetsProject fullProject = RingtoetsProjectTestHelper.GetFullTestProject(); var tempFile = Path.Combine(testDataPath, "tempProjectAsFile.rtd"); StorageSqLite storage = new StorageSqLite(); TestDelegate precondition = () => storage.SaveProjectAs(tempRingtoetsFile, fullProject); Assert.DoesNotThrow(precondition, String.Format("Precondition: file '{0}' must be a valid Ringtoets database file.", tempRingtoetsFile)); // Call - Project firstProject = null; - Project secondProject = null; + RingtoetsProject firstProject = null; + RingtoetsProject secondProject = null; try { storage.SaveProjectAs(tempFile, fullProject); - firstProject = storage.LoadProject(tempRingtoetsFile); - secondProject = storage.LoadProject(tempFile); + firstProject = storage.LoadProject(tempRingtoetsFile) as RingtoetsProject; + secondProject = storage.LoadProject(tempFile) as RingtoetsProject; } catch (Exception exception) { @@ -98,7 +97,7 @@ { // Setup StorageSqLite storage = new StorageSqLite(); - Project fullProject = RingtoetsProjectHelper.GetFullTestProject(); + RingtoetsProject fullProject = RingtoetsProjectTestHelper.GetFullTestProject(); TestDelegate precondition = () => storage.SaveProjectAs(tempRingtoetsFile, fullProject); Assert.DoesNotThrow(precondition, String.Format("Precondition: file '{0}' must be a valid Ringtoets database file.", tempRingtoetsFile)); @@ -109,7 +108,7 @@ Assert.DoesNotThrow(test, String.Format("Precondition: failed to save project to file '{0}'.", tempRingtoetsFile)); // Call - Project loadedProject = storage.LoadProject(tempRingtoetsFile); + RingtoetsProject loadedProject = storage.LoadProject(tempRingtoetsFile) as RingtoetsProject; // Assert AssertProjectsAreEqual(fullProject, loadedProject); @@ -121,14 +120,14 @@ { // Given var projectStore = new StorageSqLite(); - Project fullProject = RingtoetsProjectHelper.GetFullTestProject(); + RingtoetsProject fullProject = RingtoetsProjectTestHelper.GetFullTestProject(); var expectedProjectName = Path.GetFileNameWithoutExtension(tempRingtoetsFile); var expectedProjectDescription = fullProject.Description; // Precondition SqLiteDatabaseHelper.CreateValidRingtoetsDatabase(tempRingtoetsFile, fullProject); - using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings())) + using (var gui = new GuiCore(new MainWindow(), projectStore, new RingtoetsProjectFactory(), new GuiCoreSettings())) { // When Action action = () => gui.Run(tempRingtoetsFile); @@ -145,7 +144,8 @@ Assert.AreEqual(expectedProjectName, gui.Project.Name); Assert.AreEqual(expectedProjectDescription, gui.Project.Description); - AssertProjectsAreEqual(gui.Project, fullProject); + Assert.IsInstanceOf(gui.Project); + AssertProjectsAreEqual((RingtoetsProject) gui.Project, fullProject); } } @@ -157,7 +157,7 @@ var testFile = "SomeFile"; var projectStore = new StorageSqLite(); - using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings())) + using (var gui = new GuiCore(new MainWindow(), projectStore, new RingtoetsProjectFactory(), new GuiCoreSettings())) { // When Action action = () => gui.Run(testFile); @@ -175,7 +175,8 @@ Assert.NotNull(gui.Project); Assert.AreEqual("Project", gui.Project.Name); Assert.IsEmpty(gui.Project.Description); - CollectionAssert.IsEmpty(gui.Project.Items); + Assert.IsInstanceOf(gui.Project); + CollectionAssert.IsEmpty(((RingtoetsProject) gui.Project).Items); } } @@ -189,7 +190,7 @@ // Given var projectStore = new StorageSqLite(); - using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings())) + using (var gui = new GuiCore(new MainWindow(), projectStore, new RingtoetsProjectFactory(), new GuiCoreSettings())) { // When Action action = () => gui.Run(testFile); @@ -204,18 +205,19 @@ Assert.NotNull(gui.Project); Assert.AreEqual("Project", gui.Project.Name); Assert.IsEmpty(gui.Project.Description); - CollectionAssert.IsEmpty(gui.Project.Items); + Assert.IsInstanceOf(gui.Project); + CollectionAssert.IsEmpty(((RingtoetsProject) gui.Project).Items); } } - private static void AssertProjectsAreEqual(Project expectedProject, Project actualProject) + private void AssertProjectsAreEqual(RingtoetsProject expectedProject, RingtoetsProject actualProject) { Assert.NotNull(expectedProject); Assert.NotNull(actualProject); Assert.AreNotSame(expectedProject, actualProject); - AssessmentSection[] expectedProjectAssessmentSections = expectedProject.Items.OfType().ToArray(); - AssessmentSection[] actualProjectAssessmentSections = actualProject.Items.OfType().ToArray(); + AssessmentSection[] expectedProjectAssessmentSections = expectedProject.Items.ToArray(); + AssessmentSection[] actualProjectAssessmentSections = actualProject.Items.ToArray(); Assert.AreEqual(expectedProjectAssessmentSections.Length, actualProjectAssessmentSections.Length); for (var i = 0; i < expectedProjectAssessmentSections.Length; i++) { @@ -798,7 +800,7 @@ var expectedGrassCoverErosionInwardsCalculation = expectedChild as GrassCoverErosionInwardsCalculation; if (expectedGrassCoverErosionInwardsCalculation != null) { - AssertGrassCoverErosionInwardsCalculation(expectedGrassCoverErosionInwardsCalculation, (GrassCoverErosionInwardsCalculation)actualChild); + AssertGrassCoverErosionInwardsCalculation(expectedGrassCoverErosionInwardsCalculation, (GrassCoverErosionInwardsCalculation) actualChild); } } } Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/StorageSqLiteTest.cs =================================================================== diff -u -r669853e6468fcf1301a64f5df1400456fe6929eb -r1eed3e3f652618c52a462edc502cfd4250772314 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/StorageSqLiteTest.cs (.../StorageSqLiteTest.cs) (revision 669853e6468fcf1301a64f5df1400456fe6929eb) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/StorageSqLiteTest.cs (.../StorageSqLiteTest.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -30,6 +30,7 @@ using Core.Common.TestUtil; using NUnit.Framework; using Rhino.Mocks; +using Ringtoets.Integration.Data; using UtilsResources = Core.Common.Utils.Properties.Resources; namespace Application.Ringtoets.Storage.Test @@ -172,7 +173,7 @@ var projectName = Path.GetFileNameWithoutExtension(tempRingtoetsFile); var storage = new StorageSqLite(); var mockRepository = new MockRepository(); - var projectMock = mockRepository.StrictMock(); + var projectMock = mockRepository.StrictMock(); projectMock.Description = ""; projectMock.StorageId = 1L; @@ -183,10 +184,10 @@ SqLiteDatabaseHelper.CreateValidRingtoetsDatabase(tempRingtoetsFile, projectMock); // Call - Project loadedProject = storage.LoadProject(tempRingtoetsFile); + IProject loadedProject = storage.LoadProject(tempRingtoetsFile); // Assert - Assert.IsInstanceOf(loadedProject); + Assert.IsInstanceOf(loadedProject); Assert.AreEqual(1L, loadedProject.StorageId); Assert.AreEqual(projectName, loadedProject.Name); Assert.AreEqual(projectMock.Description, loadedProject.Description); @@ -205,7 +206,7 @@ public void SaveProjectAs_InvalidPath_ThrowsArgumentException(string invalidPath) { // Setup - Project project = new Project(); + RingtoetsProject project = new RingtoetsProject(); var expectedMessage = String.Format("Fout bij het lezen van bestand '{0}': {1}", invalidPath, UtilsResources.Error_Path_must_be_specified); @@ -243,7 +244,7 @@ public void SaveProjectAs_ValidPathToNonExistingFile_DoesNotThrowException() { // Setup - var project = new Project(); + var project = new RingtoetsProject(); var storage = new StorageSqLite(); FileDisposeHelper fileDisposeHelper = new FileDisposeHelper(tempRingtoetsFile); @@ -266,7 +267,7 @@ public void SaveProjectAs_ValidPathToExistingFile_DoesNotThrowException() { // Setup - var project = new Project(); + var project = new RingtoetsProject(); var storage = new StorageSqLite(); FileDisposeHelper fileDisposeHelper = new FileDisposeHelper(tempRingtoetsFile); @@ -290,9 +291,9 @@ { // Setup var expectedMessage = string.Format( - @"Kan geen tijdelijk bestand maken van het originele bestand ({0}). Probeer ergens anders op te slaan.", + @"Kan geen tijdelijk bestand maken van het originele bestand ({0}). Probeer ergens anders op te slaan.", tempRingtoetsFile); - var project = new Project(); + var project = new RingtoetsProject(); var storage = new StorageSqLite(); FileDisposeHelper fileDisposeHelper = new FileDisposeHelper(tempRingtoetsFile); @@ -327,7 +328,7 @@ public void SaveProject_InvalidPath_ThrowsArgumentException(string invalidPath) { // Setup - Project project = new Project(); + RingtoetsProject project = new RingtoetsProject(); var expectedMessage = String.Format("Fout bij het lezen van bestand '{0}': {1}", invalidPath, UtilsResources.Error_Path_must_be_specified); @@ -344,7 +345,7 @@ { // Setup var storage = new StorageSqLite(); - Project storedProject = new Project(); + RingtoetsProject storedProject = new RingtoetsProject(); FileDisposeHelper fileDisposeHelper = new FileDisposeHelper(tempRingtoetsFile); try @@ -369,7 +370,7 @@ public void SaveProject_ValidProjectNonExistingPath_NewFileCreated() { // Setup - var project = new Project + var project = new RingtoetsProject { StorageId = 1234L }; @@ -395,11 +396,11 @@ public void SaveProject_EmptyDatabaseFile_ThrowsStorageException() { // Setup - var savedProject = new Project + var savedProject = new RingtoetsProject { StorageId = 1L }; - var projectWithIncorrectStorageId = new Project + var projectWithIncorrectStorageId = new RingtoetsProject { StorageId = 1234L }; @@ -431,7 +432,7 @@ public void SaveProject_CorruptRingtoetsFileThatPassesValidation_ThrowsStorageExceptionWithFullStackTrace() { // Setup - var project = new Project + var project = new RingtoetsProject { StorageId = 1234L }; @@ -476,7 +477,7 @@ long projectId = 1234L; var projectName = Path.GetFileNameWithoutExtension(tempRingtoetsFile); - var project = new Project() + var project = new RingtoetsProject() { StorageId = projectId }; @@ -509,7 +510,7 @@ StorageSqLite storageSqLite = new StorageSqLite(); // Call - bool hasChanges = storageSqLite.HasChanges(new Project()); + bool hasChanges = storageSqLite.HasChanges(new RingtoetsProject()); // Assert Assert.IsTrue(hasChanges); @@ -520,13 +521,13 @@ { // Setup StorageSqLite storageSqLite = new StorageSqLite(); - Project storedProject = new Project(); + RingtoetsProject storedProject = new RingtoetsProject(); FileDisposeHelper fileDisposeHelper = new FileDisposeHelper(tempRingtoetsFile); try { SqLiteDatabaseHelper.CreateValidRingtoetsDatabase(tempRingtoetsFile, storedProject); - Project loadedProject = storageSqLite.LoadProject(tempRingtoetsFile); + IProject loadedProject = storageSqLite.LoadProject(tempRingtoetsFile); // Call bool hasChanges = storageSqLite.HasChanges(loadedProject); @@ -546,13 +547,13 @@ { // Setup StorageSqLite storageSqLite = new StorageSqLite(); - Project storedProject = new Project(); + RingtoetsProject storedProject = new RingtoetsProject(); FileDisposeHelper fileDisposeHelper = new FileDisposeHelper(tempRingtoetsFile); try { SqLiteDatabaseHelper.CreateValidRingtoetsDatabase(tempRingtoetsFile, storedProject); - Project loadedProject = storageSqLite.LoadProject(tempRingtoetsFile); + IProject loadedProject = storageSqLite.LoadProject(tempRingtoetsFile); storageSqLite.CloseProject(); // Call @@ -573,14 +574,14 @@ { // Setup StorageSqLite storageSqLite = new StorageSqLite(); - Project storedProject = new Project(); + RingtoetsProject storedProject = new RingtoetsProject(); var changedName = "some name"; FileDisposeHelper fileDisposeHelper = new FileDisposeHelper(tempRingtoetsFile); try { SqLiteDatabaseHelper.CreateValidRingtoetsDatabase(tempRingtoetsFile, storedProject); - Project loadedProject = storageSqLite.LoadProject(tempRingtoetsFile); + IProject loadedProject = storageSqLite.LoadProject(tempRingtoetsFile); // Call loadedProject.Name = changedName; @@ -601,14 +602,14 @@ { // Setup StorageSqLite storageSqLite = new StorageSqLite(); - Project storedProject = new Project(); + RingtoetsProject storedProject = new RingtoetsProject(); var changedDescription = "some description"; FileDisposeHelper fileDisposeHelper = new FileDisposeHelper(tempRingtoetsFile); try { SqLiteDatabaseHelper.CreateValidRingtoetsDatabase(tempRingtoetsFile, storedProject); - Project loadedProject = storageSqLite.LoadProject(tempRingtoetsFile); + IProject loadedProject = storageSqLite.LoadProject(tempRingtoetsFile); // Call loadedProject.Description = changedDescription; @@ -629,7 +630,7 @@ { // Setup var mockRepository = new MockRepository(); - var projectMock = mockRepository.StrictMock(); + var projectMock = mockRepository.StrictMock(); projectMock.StorageId = 1234L; mockRepository.ReplayAll(); var storage = new StorageSqLite(); Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/ProjectUpdateExtensionsTest.cs =================================================================== diff -u -r93f4c75ba2309bb82de7e2362bafca5aa516d545 -r1eed3e3f652618c52a462edc502cfd4250772314 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/ProjectUpdateExtensionsTest.cs (.../ProjectUpdateExtensionsTest.cs) (revision 93f4c75ba2309bb82de7e2362bafca5aa516d545) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/ProjectUpdateExtensionsTest.cs (.../ProjectUpdateExtensionsTest.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -41,7 +41,7 @@ public void Update_WithoutContext_ThrowsArgumentNullException() { // Setup - var project = new Project(); + var project = new RingtoetsProject(); // Call TestDelegate test = () => project.Update(new PersistenceRegistry(), null); @@ -55,7 +55,7 @@ public void Update_WithoutPersistenceRegistry_ThrowsArgumentNullException() { // Setup - var project = new Project(); + var project = new RingtoetsProject(); // Call TestDelegate test = () => @@ -75,7 +75,7 @@ public void Update_ContextWithNoProject_ThrowsEntityNotFoundException() { // Setup - var project = new Project(); + var project = new RingtoetsProject(); // Call TestDelegate test = () => @@ -100,7 +100,7 @@ mocks.ReplayAll(); var storageId = 1; - var project = new Project + var project = new RingtoetsProject { StorageId = storageId }; @@ -131,7 +131,7 @@ mocks.ReplayAll(); var storageId = 1; - var project = new Project + var project = new RingtoetsProject { StorageId = storageId }; @@ -171,7 +171,7 @@ mocks.ReplayAll(); var newDescription = "newDescription"; - var project = new Project + var project = new RingtoetsProject { StorageId = 1, Description = newDescription @@ -202,7 +202,7 @@ mocks.ReplayAll(); - var project = new Project + var project = new RingtoetsProject { StorageId = 1, Items = @@ -326,7 +326,7 @@ StorageId = 1 } }; - var project = new Project + var project = new RingtoetsProject { StorageId = 1, Items = Index: Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil.Test/Application.Ringtoets.Storage.TestUtil.Test.csproj =================================================================== diff -u -re0ef393f7069a18d7e160aceaf91f603dfc8c5ae -r1eed3e3f652618c52a462edc502cfd4250772314 --- Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil.Test/Application.Ringtoets.Storage.TestUtil.Test.csproj (.../Application.Ringtoets.Storage.TestUtil.Test.csproj) (revision e0ef393f7069a18d7e160aceaf91f603dfc8c5ae) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil.Test/Application.Ringtoets.Storage.TestUtil.Test.csproj (.../Application.Ringtoets.Storage.TestUtil.Test.csproj) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -68,7 +68,7 @@ - + Fisheye: Tag 1eed3e3f652618c52a462edc502cfd4250772314 refers to a dead (removed) revision in file `Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil.Test/RingtoetsProjectHelperTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil.Test/RingtoetsProjectTestHelperTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil.Test/RingtoetsProjectTestHelperTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil.Test/RingtoetsProjectTestHelperTest.cs (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -0,0 +1,117 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU 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 General Public License for more details. +// +// You should have received a copy of the GNU 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.Linq; +using Core.Common.Base.Geometry; +using NUnit.Framework; +using Ringtoets.HydraRing.Data; +using Ringtoets.Integration.Data; +using Ringtoets.Piping.Data; +using Ringtoets.Piping.Primitives; + +namespace Application.Ringtoets.Storage.TestUtil.Test +{ + [TestFixture] + public class RingtoetsProjectTestHelperTest + { + [Test] + public void RingtoetsProjectHelper_Always_ReturnsFullProject() + { + // Setup + string expectedProjectName = "tempProjectFile"; + string expectedDescription = "description"; + string expectedAssessmentSectionName = "assessmentSection"; + + string hydraulicDatabaseFilePath = "/temp/test"; + string hydraulicDatabaseVersion = "1.0"; + + long locationId = 13001; + string locationName = "test"; + double locationX = 152.3; + double locationY = 2938.5; + double designWaterLevel = 12.4; + + // Call + RingtoetsProject project = RingtoetsProjectTestHelper.GetFullTestProject(); + + // Assert + Assert.AreEqual(expectedProjectName, project.Name); + Assert.AreEqual(expectedDescription, project.Description); + + AssessmentSection assessmentSection = project.Items.FirstOrDefault(); + Assert.NotNull(assessmentSection); + Assert.AreEqual(expectedAssessmentSectionName, assessmentSection.Name); + + Assert.NotNull(assessmentSection.HydraulicBoundaryDatabase); + Assert.AreEqual(hydraulicDatabaseVersion, assessmentSection.HydraulicBoundaryDatabase.Version); + Assert.AreEqual(hydraulicDatabaseFilePath, assessmentSection.HydraulicBoundaryDatabase.FilePath); + Assert.AreEqual(1, assessmentSection.HydraulicBoundaryDatabase.Locations.Count); + + HydraulicBoundaryLocation hydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(); + Assert.AreEqual(locationId, hydraulicBoundaryLocation.Id); + Assert.AreEqual(locationName, hydraulicBoundaryLocation.Name); + Assert.AreEqual(locationX, hydraulicBoundaryLocation.Location.X); + Assert.AreEqual(locationY, hydraulicBoundaryLocation.Location.Y); + Assert.AreEqual(designWaterLevel, hydraulicBoundaryLocation.DesignWaterLevel); + + PipingFailureMechanism pipingFailureMechanism = assessmentSection.PipingFailureMechanism; + Assert.AreEqual(1, pipingFailureMechanism.StochasticSoilModels.Count); + StochasticSoilModel soilModel = pipingFailureMechanism.StochasticSoilModels[0]; + Assert.AreEqual(-1, soilModel.Id); + Assert.AreEqual("modelName", soilModel.Name); + Assert.AreEqual("modelSegmentName", soilModel.SegmentName); + Assert.AreEqual(2, soilModel.StochasticSoilProfiles.Count); + StochasticSoilProfile stochasticSoilProfile1 = soilModel.StochasticSoilProfiles[0]; + Assert.AreEqual(0.2, stochasticSoilProfile1.Probability); + Assert.AreEqual(SoilProfileType.SoilProfile1D, stochasticSoilProfile1.SoilProfileType); + Assert.AreEqual(-1, stochasticSoilProfile1.SoilProfileId); + StochasticSoilProfile stochasticSoilProfile2 = soilModel.StochasticSoilProfiles[1]; + Assert.AreEqual(0.8, stochasticSoilProfile2.Probability); + Assert.AreEqual(SoilProfileType.SoilProfile1D, stochasticSoilProfile2.SoilProfileType); + Assert.AreEqual(-1, stochasticSoilProfile2.SoilProfileId); + + Assert.AreEqual(1, pipingFailureMechanism.SurfaceLines.Count); + RingtoetsPipingSurfaceLine surfaceLine = pipingFailureMechanism.SurfaceLines.First(); + Assert.AreEqual("Surfaceline", surfaceLine.Name); + Assert.AreEqual(new Point2D(4.0, 6.0), surfaceLine.ReferenceLineIntersectionWorldPoint); + var geometryPoints = new[] + { + new Point3D(6.0, 6.0, -2.3), + new Point3D(5.8, 6.0, -2.3), + new Point3D(5.6, 6.0, 3.4), + new Point3D(4.2, 6.0, 3.5), + new Point3D(4.0, 6.0, 0.5), + new Point3D(3.8, 6.0, 0.5), + new Point3D(3.6, 6.0, 0.2), + new Point3D(3.4, 6.0, 0.25), + new Point3D(3.2, 6.0, 0.5), + new Point3D(3.0, 6.0, 0.5) + }; + CollectionAssert.AreEqual(geometryPoints, surfaceLine.Points); + Assert.AreSame(surfaceLine.Points[1], surfaceLine.DikeToeAtRiver); + Assert.AreSame(surfaceLine.Points[4], surfaceLine.DikeToeAtPolder); + Assert.AreSame(surfaceLine.Points[5], surfaceLine.DitchDikeSide); + Assert.AreSame(surfaceLine.Points[6], surfaceLine.BottomDitchDikeSide); + Assert.AreSame(surfaceLine.Points[7], surfaceLine.BottomDitchPolderSide); + Assert.AreSame(surfaceLine.Points[8], surfaceLine.DitchPolderSide); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil.Test/SqLiteDatabaseHelperTest.cs =================================================================== diff -u -rde4477561032a5d95d5e65e50b719724466648ed -r1eed3e3f652618c52a462edc502cfd4250772314 --- Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil.Test/SqLiteDatabaseHelperTest.cs (.../SqLiteDatabaseHelperTest.cs) (revision de4477561032a5d95d5e65e50b719724466648ed) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil.Test/SqLiteDatabaseHelperTest.cs (.../SqLiteDatabaseHelperTest.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -22,10 +22,9 @@ using System; using System.Data.SQLite; using System.IO; -using Core.Common.Base.Data; using Core.Common.TestUtil; using NUnit.Framework; -using Rhino.Mocks; +using Ringtoets.Integration.Data; namespace Application.Ringtoets.Storage.TestUtil.Test { @@ -141,19 +140,18 @@ { // Setup string validPath = Path.Combine(testDataPath, "tempFile.rtd"); - MockRepository mockRepository = new MockRepository(); - var projectMock = mockRepository.StrictMock(); + var project = new RingtoetsProject(); FileDisposeHelper fileDisposeHelper = new FileDisposeHelper(validPath); try { // Call - TestDelegate test = () => SqLiteDatabaseHelper.CreateValidRingtoetsDatabase(validPath, projectMock); + TestDelegate test = () => SqLiteDatabaseHelper.CreateValidRingtoetsDatabase(validPath, project); // Assert Assert.DoesNotThrow(test); Assert.IsTrue(File.Exists(validPath)); - } + } finally { CallGarbageCollector(); Index: Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/Application.Ringtoets.Storage.TestUtil.csproj =================================================================== diff -u -r8ed108b83f575f6cb7dc1b89224606894a4bcb7a -r1eed3e3f652618c52a462edc502cfd4250772314 --- Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/Application.Ringtoets.Storage.TestUtil.csproj (.../Application.Ringtoets.Storage.TestUtil.csproj) (revision 8ed108b83f575f6cb7dc1b89224606894a4bcb7a) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/Application.Ringtoets.Storage.TestUtil.csproj (.../Application.Ringtoets.Storage.TestUtil.csproj) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -64,7 +64,7 @@ - + Fisheye: Tag 1eed3e3f652618c52a462edc502cfd4250772314 refers to a dead (removed) revision in file `Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsProjectHelper.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsProjectTestHelper.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsProjectTestHelper.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsProjectTestHelper.cs (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -0,0 +1,611 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU 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 General Public License for more details. +// +// You should have received a copy of the GNU 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.Drawing; +using System.Linq; +using Core.Common.Base.Data; +using Core.Common.Base.Geometry; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Calculation; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.GrassCoverErosionInwards.Data; +using Ringtoets.HeightStructures.Data; +using Ringtoets.HydraRing.Data; +using Ringtoets.Integration.Data; +using Ringtoets.Integration.Data.StandAlone.SectionResults; +using Ringtoets.Piping.Data; +using Ringtoets.Piping.KernelWrapper.TestUtil; +using Ringtoets.Piping.Primitives; + +namespace Application.Ringtoets.Storage.TestUtil +{ + /// + /// This class can be used to create instances which have their properties set and can be used in tests. + /// + public static class RingtoetsProjectTestHelper + { + /// + /// Returns a new complete instance of . + /// + /// A new complete instance of . + public static RingtoetsProject GetFullTestProject() + { + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) + { + Name = "assessmentSection", + HydraulicBoundaryDatabase = GetHydraulicBoundaryDatabase(), + ReferenceLine = GetReferenceLine() + }; + PipingFailureMechanism pipingFailureMechanism = assessmentSection.PipingFailureMechanism; + ConfigurePipingFailureMechanism(pipingFailureMechanism, assessmentSection); + AddSections(pipingFailureMechanism); + SetSectionResults(pipingFailureMechanism.SectionResults); + + GrassCoverErosionInwardsFailureMechanism grassCoverErosionInwardsFailureMechanism = assessmentSection.GrassCoverErosionInwards; + ConfigureGrassCoverErosionInwardsFailureMechanism(grassCoverErosionInwardsFailureMechanism); + AddSections(grassCoverErosionInwardsFailureMechanism); + SetSectionResults(grassCoverErosionInwardsFailureMechanism.SectionResults); + + AddSections(assessmentSection.MacrostabilityInwards); + SetSectionResults(assessmentSection.MacrostabilityInwards.SectionResults); + AddSections(assessmentSection.MacrostabilityOutwards); + SetSectionResults(assessmentSection.MacrostabilityOutwards.SectionResults); + AddSections(assessmentSection.Microstability); + SetSectionResults(assessmentSection.Microstability.SectionResults); + AddSections(assessmentSection.StabilityStoneCover); + SetSectionResults(assessmentSection.StabilityStoneCover.SectionResults); + AddSections(assessmentSection.WaveImpactAsphaltCover); + SetSectionResults(assessmentSection.WaveImpactAsphaltCover.SectionResults); + AddSections(assessmentSection.WaterPressureAsphaltCover); + SetSectionResults(assessmentSection.WaterPressureAsphaltCover.SectionResults); + AddSections(assessmentSection.GrassCoverErosionOutwards); + SetSectionResults(assessmentSection.GrassCoverErosionOutwards.SectionResults); + AddSections(assessmentSection.GrassCoverSlipOffInwards); + SetSectionResults(assessmentSection.GrassCoverSlipOffInwards.SectionResults); + AddSections(assessmentSection.GrassCoverSlipOffOutwards); + SetSectionResults(assessmentSection.GrassCoverSlipOffOutwards.SectionResults); + AddSections(assessmentSection.HeightStructures); + SetSectionResults(assessmentSection.HeightStructures.SectionResults); + AddSections(assessmentSection.ClosingStructure); + SetSectionResults(assessmentSection.ClosingStructure.SectionResults); + AddSections(assessmentSection.StrengthStabilityPointConstruction); + SetSectionResults(assessmentSection.StrengthStabilityPointConstruction.SectionResults); + AddSections(assessmentSection.StrengthStabilityLengthwiseConstruction); + SetSectionResults(assessmentSection.StrengthStabilityLengthwiseConstruction.SectionResults); + AddSections(assessmentSection.PipingStructure); + SetSectionResults(assessmentSection.PipingStructure.SectionResults); + AddSections(assessmentSection.DuneErosion); + SetSectionResults(assessmentSection.DuneErosion.SectionResults); + AddSections(assessmentSection.TechnicalInnovation); + SetSectionResults(assessmentSection.TechnicalInnovation.SectionResults); + + var fullTestProject = new RingtoetsProject + { + Name = "tempProjectFile", + Description = "description", + Items = + { + assessmentSection + } + }; + return fullTestProject; + } + + private static void ConfigurePipingFailureMechanism(PipingFailureMechanism pipingFailureMechanism, AssessmentSection assessmentSection) + { + var referenceLineGeometryPoints = assessmentSection.ReferenceLine.Points.ToArray(); + + PipingSoilProfile pipingSoilProfile = new TestPipingSoilProfile(); + PipingSoilLayer pipingSoilLayer = pipingSoilProfile.Layers.First(); + pipingSoilLayer.BelowPhreaticLevelMean = 2.2; + pipingSoilLayer.BelowPhreaticLevelDeviation = 1.2; + pipingSoilLayer.BelowPhreaticLevelShift = 3.2; + pipingSoilLayer.DiameterD70Mean = 2.42; + pipingSoilLayer.DiameterD70Deviation = 21.002; + pipingSoilLayer.PermeabilityMean = 0.9982; + pipingSoilLayer.PermeabilityDeviation = 0.220; + pipingSoilLayer.Color = Color.HotPink; + pipingSoilLayer.MaterialName = "HotPinkLayer"; + + pipingFailureMechanism.StochasticSoilModels.Add(new StochasticSoilModel(-1, "modelName", "modelSegmentName") + { + Geometry = + { + referenceLineGeometryPoints[1], + referenceLineGeometryPoints[2], + referenceLineGeometryPoints[3] + }, + StochasticSoilProfiles = + { + new StochasticSoilProfile(0.2, SoilProfileType.SoilProfile1D, -1) + { + SoilProfile = pipingSoilProfile + }, + new StochasticSoilProfile(0.8, SoilProfileType.SoilProfile1D, -1) + { + SoilProfile = new TestPipingSoilProfile() + } + } + }); + pipingFailureMechanism.SurfaceLines.Add(GetSurfaceLine()); + + CalculationGroup pipingCalculationGroup = pipingFailureMechanism.CalculationsGroup; + pipingCalculationGroup.Children.Add(new CalculationGroup + { + Name = "A", + Children = + { + new PipingCalculationScenario(pipingFailureMechanism.GeneralInput) + { + Name = "AA", + IsRelevant = true, + Contribution = (RoundedDouble) 1.0, + Comments = "Nice comment about this calculation!", + InputParameters = + { + SurfaceLine = pipingFailureMechanism.SurfaceLines.First(), + HydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(), + StochasticSoilModel = pipingFailureMechanism.StochasticSoilModels.First(), + StochasticSoilProfile = pipingFailureMechanism.StochasticSoilModels.First() + .StochasticSoilProfiles.First(), + EntryPointL = (RoundedDouble) 1.0, + ExitPointL = (RoundedDouble) 2.0, + PhreaticLevelExit = + { + Mean = (RoundedDouble) 1.1, + StandardDeviation = (RoundedDouble) 2.2 + }, + DampingFactorExit = + { + Mean = (RoundedDouble) 3.3, + StandardDeviation = (RoundedDouble) 4.4 + }, + SaturatedVolumicWeightOfCoverageLayer = + { + Mean = (RoundedDouble) 5.5, + StandardDeviation = (RoundedDouble) 6.6, + Shift = (RoundedDouble) 7.7 + }, + Diameter70 = + { + Mean = (RoundedDouble) 8.8, + StandardDeviation = (RoundedDouble) 9.9 + }, + DarcyPermeability = + { + Mean = (RoundedDouble) 10.10, + StandardDeviation = (RoundedDouble) 11.11 + } + }, + Output = new PipingOutput(1.1, 2.2, 3.3, 4.4, 5.5, 6.6), + SemiProbabilisticOutput = new PipingSemiProbabilisticOutput(7.7, 8.8, 0.9, + 10.10, 11.11, 0.12, + 13.13, 14.14, 0.15, + 0.16, 17.17, + 0.18, 19.19, 20.20) + } + } + }); + pipingCalculationGroup.Children.Add(new CalculationGroup + { + Name = "B" + }); + pipingCalculationGroup.Children.Add(new PipingCalculationScenario(pipingFailureMechanism.GeneralInput) + { + Name = "C", + IsRelevant = false, + Contribution = (RoundedDouble) 0.5, + Comments = "Another great comment", + InputParameters = + { + SurfaceLine = pipingFailureMechanism.SurfaceLines.First(), + HydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(), + StochasticSoilModel = pipingFailureMechanism.StochasticSoilModels.First(), + StochasticSoilProfile = pipingFailureMechanism.StochasticSoilModels.First() + .StochasticSoilProfiles.Skip(1).First(), + EntryPointL = (RoundedDouble) 0.3, + ExitPointL = (RoundedDouble) 2.3, + PhreaticLevelExit = + { + Mean = (RoundedDouble) 12.12, + StandardDeviation = (RoundedDouble) 13.13 + }, + DampingFactorExit = + { + Mean = (RoundedDouble) 14.14, + StandardDeviation = (RoundedDouble) 15.15 + }, + SaturatedVolumicWeightOfCoverageLayer = + { + Mean = (RoundedDouble) 16.16, + StandardDeviation = (RoundedDouble) 17.17, + Shift = (RoundedDouble) 18.18 + }, + Diameter70 = + { + Mean = (RoundedDouble) 19.19, + StandardDeviation = (RoundedDouble) 20.20 + }, + DarcyPermeability = + { + Mean = (RoundedDouble) 21.21, + StandardDeviation = (RoundedDouble) 22.22 + } + }, + Output = null, + SemiProbabilisticOutput = null + }); + } + + private static void ConfigureGrassCoverErosionInwardsFailureMechanism(GrassCoverErosionInwardsFailureMechanism failureMechanism) + { + failureMechanism.GeneralInput.N = 15; + failureMechanism.DikeProfiles.Add(new DikeProfile(new Point2D(1, 2), + new[] + { + new RoughnessPoint(new Point2D(1, 2), 1), + new RoughnessPoint(new Point2D(3, 4), 0.5), + }, + new[] + { + new Point2D(5, 6), + new Point2D(7, 8), + }, + null, new DikeProfile.ConstructionProperties + { + DikeHeight = 1.1, + Name = "2.2", + Orientation = 3.3, + X0 = 4.4 + })); + failureMechanism.DikeProfiles.Add(new DikeProfile(new Point2D(9, 10), + new[] + { + new RoughnessPoint(new Point2D(11, 12), 1), + new RoughnessPoint(new Point2D(13, 14), 0.5), + }, + new Point2D[0], + new BreakWater(BreakWaterType.Caisson, 15), + new DikeProfile.ConstructionProperties + { + DikeHeight = 5.5, + Name = "6.6", + Orientation = 7.7, + X0 = 8.8 + })); + failureMechanism.CalculationsGroup.Children.Add(new CalculationGroup + { + Name = "GEKB A", + Children = + { + new GrassCoverErosionInwardsCalculation + { + Name = "Calculation 1", + Comments = "Comments for Calculation 1" + } + } + }); + failureMechanism.CalculationsGroup.Children.Add(new CalculationGroup + { + Name = "GEKB B" + }); + failureMechanism.CalculationsGroup.Children.Add(new CalculationGroup + { + Name = "GEKB C", + Children = + { + new GrassCoverErosionInwardsCalculation + { + Name = "Calculation 2", + Comments = "Comments about Calculation 2" + } + } + }); + } + + private static void SetSectionResults(IEnumerable sectionResults) + { + var random = new Random(21); + foreach (var sectionResult in sectionResults) + { + sectionResult.AssessmentLayerOne = Convert.ToBoolean(random.Next(0, 2)); + sectionResult.AssessmentLayerThree = (RoundedDouble) random.NextDouble(); + } + } + + private static void SetSectionResults(IEnumerable sectionResults) + { + var random = new Random(21); + foreach (var sectionResult in sectionResults) + { + sectionResult.AssessmentLayerOne = Convert.ToBoolean(random.Next(0, 2)); + sectionResult.AssessmentLayerThree = (RoundedDouble) random.NextDouble(); + } + } + + private static void SetSectionResults(IEnumerable sectionResults) + { + var random = new Random(21); + foreach (var sectionResult in sectionResults) + { + sectionResult.AssessmentLayerOne = Convert.ToBoolean(random.Next(0, 2)); + sectionResult.AssessmentLayerThree = (RoundedDouble) random.NextDouble(); + } + } + + private static void SetSectionResults(IEnumerable sectionResults) + { + var random = new Random(21); + foreach (var sectionResult in sectionResults) + { + sectionResult.AssessmentLayerOne = Convert.ToBoolean(random.Next(0, 2)); + sectionResult.AssessmentLayerThree = (RoundedDouble) random.NextDouble(); + } + } + + private static void SetSectionResults(IEnumerable sectionResults) + { + var random = new Random(21); + foreach (var sectionResult in sectionResults) + { + sectionResult.AssessmentLayerOne = Convert.ToBoolean(random.Next(0, 2)); + sectionResult.AssessmentLayerThree = (RoundedDouble) random.NextDouble(); + } + } + + private static void SetSectionResults(IEnumerable sectionResults) + { + var random = new Random(21); + foreach (var sectionResult in sectionResults) + { + sectionResult.AssessmentLayerOne = Convert.ToBoolean(random.Next(0, 2)); + sectionResult.AssessmentLayerThree = (RoundedDouble) random.NextDouble(); + } + } + + private static void SetSectionResults(IEnumerable sectionResults) + { + var random = new Random(21); + foreach (var sectionResult in sectionResults) + { + sectionResult.AssessmentLayerOne = Convert.ToBoolean(random.Next(0, 2)); + sectionResult.AssessmentLayerTwoA = (RoundedDouble) random.NextDouble(); + sectionResult.AssessmentLayerThree = (RoundedDouble) random.NextDouble(); + } + } + + private static void SetSectionResults(IEnumerable sectionResults) + { + var random = new Random(21); + foreach (var sectionResult in sectionResults) + { + sectionResult.AssessmentLayerOne = Convert.ToBoolean(random.Next(0, 2)); + sectionResult.AssessmentLayerTwoA = (RoundedDouble) random.NextDouble(); + sectionResult.AssessmentLayerThree = (RoundedDouble) random.NextDouble(); + } + } + + private static void SetSectionResults(IEnumerable sectionResults) + { + var random = new Random(21); + foreach (var sectionResult in sectionResults) + { + sectionResult.AssessmentLayerOne = Convert.ToBoolean(random.Next(0, 2)); + sectionResult.AssessmentLayerTwoA = (RoundedDouble) random.NextDouble(); + sectionResult.AssessmentLayerThree = (RoundedDouble) random.NextDouble(); + } + } + + private static void SetSectionResults(IEnumerable sectionResults) + { + var random = new Random(21); + foreach (var sectionResult in sectionResults) + { + sectionResult.AssessmentLayerOne = Convert.ToBoolean(random.Next(0, 2)); + sectionResult.AssessmentLayerTwoA = (RoundedDouble) random.NextDouble(); + sectionResult.AssessmentLayerThree = (RoundedDouble) random.NextDouble(); + } + } + + private static void SetSectionResults(IEnumerable sectionResults) + { + var random = new Random(21); + foreach (var sectionResult in sectionResults) + { + var randomLayer2AResult = (AssessmentLayerTwoAResult) random.Next(0, Enum.GetValues(typeof(AssessmentLayerTwoAResult)).Length); + + sectionResult.AssessmentLayerOne = Convert.ToBoolean(random.Next(0, 2)); + sectionResult.AssessmentLayerTwoA = randomLayer2AResult; + sectionResult.AssessmentLayerThree = (RoundedDouble) random.NextDouble(); + } + } + + private static void SetSectionResults(IEnumerable sectionResults) + { + var random = new Random(21); + foreach (var sectionResult in sectionResults) + { + var randomLayer2AResult = (AssessmentLayerTwoAResult) random.Next(0, Enum.GetValues(typeof(AssessmentLayerTwoAResult)).Length); + + sectionResult.AssessmentLayerOne = Convert.ToBoolean(random.Next(0, 2)); + sectionResult.AssessmentLayerTwoA = randomLayer2AResult; + sectionResult.AssessmentLayerThree = (RoundedDouble) random.NextDouble(); + } + } + + private static void SetSectionResults(IEnumerable sectionResults) + { + var random = new Random(21); + foreach (var sectionResult in sectionResults) + { + var randomLayer2AResult = (AssessmentLayerTwoAResult) random.Next(0, Enum.GetValues(typeof(AssessmentLayerTwoAResult)).Length); + + sectionResult.AssessmentLayerOne = Convert.ToBoolean(random.Next(0, 2)); + sectionResult.AssessmentLayerTwoA = randomLayer2AResult; + sectionResult.AssessmentLayerThree = (RoundedDouble) random.NextDouble(); + } + } + + private static void SetSectionResults(IEnumerable sectionResults) + { + var random = new Random(21); + foreach (var sectionResult in sectionResults) + { + var randomLayer2AResult = (AssessmentLayerTwoAResult) random.Next(0, Enum.GetValues(typeof(AssessmentLayerTwoAResult)).Length); + + sectionResult.AssessmentLayerOne = Convert.ToBoolean(random.Next(0, 2)); + sectionResult.AssessmentLayerTwoA = randomLayer2AResult; + sectionResult.AssessmentLayerThree = (RoundedDouble) random.NextDouble(); + } + } + + private static void SetSectionResults(IEnumerable sectionResults) + { + var random = new Random(21); + foreach (var sectionResult in sectionResults) + { + var randomLayer2AResult = (AssessmentLayerTwoAResult) random.Next(0, Enum.GetValues(typeof(AssessmentLayerTwoAResult)).Length); + + sectionResult.AssessmentLayerOne = Convert.ToBoolean(random.Next(0, 2)); + sectionResult.AssessmentLayerTwoA = randomLayer2AResult; + sectionResult.AssessmentLayerThree = (RoundedDouble) random.NextDouble(); + } + } + + private static void SetSectionResults(IEnumerable sectionResults) + { + var random = new Random(21); + foreach (var sectionResult in sectionResults) + { + var randomLayer2AResult = (AssessmentLayerTwoAResult) random.Next(0, Enum.GetValues(typeof(AssessmentLayerTwoAResult)).Length); + + sectionResult.AssessmentLayerTwoA = randomLayer2AResult; + sectionResult.AssessmentLayerThree = (RoundedDouble) random.NextDouble(); + } + } + + private static void SetSectionResults(IEnumerable sectionResults) + { + var random = new Random(21); + foreach (var sectionResult in sectionResults) + { + var randomLayer2AResult = (AssessmentLayerTwoAResult) random.Next(0, Enum.GetValues(typeof(AssessmentLayerTwoAResult)).Length); + + sectionResult.AssessmentLayerTwoA = randomLayer2AResult; + sectionResult.AssessmentLayerThree = (RoundedDouble) random.NextDouble(); + } + } + + private static void SetSectionResults(IEnumerable sectionResults) + { + var random = new Random(21); + foreach (var sectionResult in sectionResults) + { + sectionResult.AssessmentLayerTwoA = (RoundedDouble) random.NextDouble(); + sectionResult.AssessmentLayerThree = (RoundedDouble) random.NextDouble(); + } + } + + private static void AddSections(IFailureMechanism failureMechanism) + { + failureMechanism.AddSection(new FailureMechanismSection("section 1", new[] + { + new Point2D(0, 2), + new Point2D(2, 3) + })); + failureMechanism.AddSection(new FailureMechanismSection("section 2", new[] + { + new Point2D(2, 3), + new Point2D(4, 5) + })); + failureMechanism.AddSection(new FailureMechanismSection("section 3", new[] + { + new Point2D(4, 5), + new Point2D(2, 3) + })); + } + + private static RingtoetsPipingSurfaceLine GetSurfaceLine() + { + var surfaceLine = new RingtoetsPipingSurfaceLine + { + Name = "Surfaceline", + ReferenceLineIntersectionWorldPoint = new Point2D(4.0, 6.0) + }; + + var geometryPoints = new[] + { + new Point3D(6.0, 6.0, -2.3), + new Point3D(5.8, 6.0, -2.3), // Dike toe at river + new Point3D(5.6, 6.0, 3.4), + new Point3D(4.2, 6.0, 3.5), + new Point3D(4.0, 6.0, 0.5), // Dike toe at polder + new Point3D(3.8, 6.0, 0.5), // Ditch dike side + new Point3D(3.6, 6.0, 0.2), // Bottom ditch dike side + new Point3D(3.4, 6.0, 0.25), // Bottom ditch polder side + new Point3D(3.2, 6.0, 0.5), // Ditch polder side + new Point3D(3.0, 6.0, 0.5), + }; + surfaceLine.SetGeometry(geometryPoints); + + surfaceLine.SetDikeToeAtRiverAt(geometryPoints[1]); + surfaceLine.SetDikeToeAtPolderAt(geometryPoints[4]); + surfaceLine.SetDitchDikeSideAt(geometryPoints[5]); + surfaceLine.SetBottomDitchDikeSideAt(geometryPoints[6]); + surfaceLine.SetBottomDitchPolderSideAt(geometryPoints[7]); + surfaceLine.SetDitchPolderSideAt(geometryPoints[8]); + + return surfaceLine; + } + + private static ReferenceLine GetReferenceLine() + { + IEnumerable points = new[] + { + new Point2D(2, 3), + new Point2D(5, 4), + new Point2D(5, 8), + new Point2D(-3, 2) + }; + + var referenceLine = new ReferenceLine(); + referenceLine.SetGeometry(points); + return referenceLine; + } + + private static HydraulicBoundaryDatabase GetHydraulicBoundaryDatabase() + { + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = "/temp/test", + Version = "1.0" + }; + hydraulicBoundaryDatabase.Locations.Add(new HydraulicBoundaryLocation(13001, "test", 152.3, 2938.5) + { + DesignWaterLevel = 12.4 + }); + + return hydraulicBoundaryDatabase; + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/SqLiteDatabaseHelper.cs =================================================================== diff -u -r3b98a31be73aaf05d1631972ec1c339dd2816504 -r1eed3e3f652618c52a462edc502cfd4250772314 --- Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/SqLiteDatabaseHelper.cs (.../SqLiteDatabaseHelper.cs) (revision 3b98a31be73aaf05d1631972ec1c339dd2816504) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/SqLiteDatabaseHelper.cs (.../SqLiteDatabaseHelper.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -22,8 +22,8 @@ using System; using System.Data.SQLite; using Application.Ringtoets.Storage.Properties; -using Core.Common.Base.Data; using NUnit.Framework; +using Ringtoets.Integration.Data; namespace Application.Ringtoets.Storage.TestUtil { @@ -71,8 +71,8 @@ /// Converts the into a new Ringtoets database file. /// /// Path to database file. - /// to save. - public static void CreateValidRingtoetsDatabase(string databaseFilePath, Project project) + /// to save. + public static void CreateValidRingtoetsDatabase(string databaseFilePath, RingtoetsProject project) { try { Index: Core/Common/src/Core.Common.Base/Core.Common.Base.csproj =================================================================== diff -u -r62866464bfe7d4dc1949370f577365d51c25bfa0 -r1eed3e3f652618c52a462edc502cfd4250772314 --- Core/Common/src/Core.Common.Base/Core.Common.Base.csproj (.../Core.Common.Base.csproj) (revision 62866464bfe7d4dc1949370f577365d51c25bfa0) +++ Core/Common/src/Core.Common.Base/Core.Common.Base.csproj (.../Core.Common.Base.csproj) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -87,11 +87,12 @@ Properties\GlobalAssembly.cs + + - Index: Core/Common/src/Core.Common.Base/Data/IProject.cs =================================================================== diff -u --- Core/Common/src/Core.Common.Base/Data/IProject.cs (revision 0) +++ Core/Common/src/Core.Common.Base/Data/IProject.cs (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -0,0 +1,41 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets 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.Common.Base.Storage; + +namespace Core.Common.Base.Data +{ + /// + /// Interface for a project. + /// + public interface IProject : IStorable, IObservable + { + /// + /// Gets or sets the name of the . + /// + string Name { get; set; } + + /// + /// Gets or sets the description of the . + /// + string Description { get; set; } + } +} \ No newline at end of file Index: Core/Common/src/Core.Common.Base/Data/IProjectFactory.cs =================================================================== diff -u --- Core/Common/src/Core.Common.Base/Data/IProjectFactory.cs (revision 0) +++ Core/Common/src/Core.Common.Base/Data/IProjectFactory.cs (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -0,0 +1,35 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets 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. + +namespace Core.Common.Base.Data +{ + /// + /// Factory for creating objects. + /// + public interface IProjectFactory + { + /// + /// Creates a new instance of . + /// + /// An empty object. + IProject CreateNewProject(); + } +} \ No newline at end of file Index: Core/Common/src/Core.Common.Base/Data/Project.cs =================================================================== diff -u -rb45253e05c4d283273a39672c5ca8aaf1b398d71 -r1eed3e3f652618c52a462edc502cfd4250772314 --- Core/Common/src/Core.Common.Base/Data/Project.cs (.../Project.cs) (revision b45253e05c4d283273a39672c5ca8aaf1b398d71) +++ Core/Common/src/Core.Common.Base/Data/Project.cs (.../Project.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -20,15 +20,15 @@ // All rights reserved. using System.Collections.Generic; +using System.Linq; using Core.Common.Base.Properties; -using Core.Common.Base.Storage; namespace Core.Common.Base.Data { /// /// Class that holds all items in a project. /// - public class Project : Observable, IStorable + public class Project : Observable, IProject { /// /// Constructs a new . @@ -48,6 +48,11 @@ } /// + /// Gets or sets the items of the . + /// + public IList Items { get; private set; } + + /// /// Gets or sets the name of the . /// public string Name { get; set; } @@ -58,13 +63,43 @@ public string Description { get; set; } /// - /// Gets or sets the items of the . - /// - public IList Items { get; private set; } - - /// /// Gets or sets the unique identifier for the storage of the . /// public long StorageId { get; set; } + + public bool Equals(IProject other) + { + var otherProject = other as Project; + if (otherProject == null) + { + return false; + } + return string.Equals(Name, otherProject.Name) && + string.Equals(Description, otherProject.Description) && + StorageId == otherProject.StorageId && + Items.SequenceEqual(otherProject.Items); + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + if (ReferenceEquals(this, obj)) + { + return true; + } + if (obj.GetType() != GetType()) + { + return false; + } + return Equals((Project)obj); + } + + public override int GetHashCode() + { + return StorageId.GetHashCode() ^ Name.GetHashCode() ^ Description.GetHashCode(); + } } } \ No newline at end of file Fisheye: Tag 1eed3e3f652618c52a462edc502cfd4250772314 refers to a dead (removed) revision in file `Core/Common/src/Core.Common.Base/Data/ProjectComparer.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Core/Common/src/Core.Common.Base/Storage/IStoreProject.cs =================================================================== diff -u -r669853e6468fcf1301a64f5df1400456fe6929eb -r1eed3e3f652618c52a462edc502cfd4250772314 --- Core/Common/src/Core.Common.Base/Storage/IStoreProject.cs (.../IStoreProject.cs) (revision 669853e6468fcf1301a64f5df1400456fe6929eb) +++ Core/Common/src/Core.Common.Base/Storage/IStoreProject.cs (.../IStoreProject.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -37,9 +37,8 @@ /// /// Converts to a new storage entry. /// - /// to save. + /// to save. /// Arguments required to connect to the storage. - /// Returns the number of changes that were saved. /// is invalid. /// Thrown when no new storage was created. /// Thrown when @@ -50,14 +49,13 @@ /// The connection to the storage failed. /// /// - void SaveProjectAs(string connectionArguments, Project project); + void SaveProjectAs(string connectionArguments, IProject project); /// /// Converts to an existing entity in the storage. /// /// Arguments required to connect to the storage. - /// The to save. - /// Returns the number of changes that were saved. + /// The to save. /// Thrown when is null. /// is invalid. /// Thrown when @@ -69,13 +67,13 @@ /// The related entity was not found in the storage. Therefore, no update was possible. /// /// - void SaveProject(string connectionArguments, Project project); + void SaveProject(string connectionArguments, IProject project); /// - /// Attempts to load the from the storage. + /// Attempts to load the from the storage. /// /// Arguments required to connect to the storage. - /// Returns a new instance of with the data from the storage or null when not found. + /// Returns a new instance of with the data from the storage or null when not found. /// is invalid. /// Thrown when /// @@ -85,18 +83,19 @@ /// The related entity was not found in the storage. /// /// - Project LoadProject(string connectionArguments); + IProject LoadProject(string connectionArguments); /// /// Removes the connection to a database that has been made previously. /// void CloseProject(); /// - /// Checks if differs from the last saved or loaded , if any. + /// Checks if differs from the last saved or loaded , if any. /// - /// The to save. - /// true if last was set and is different from , false otherwise. - bool HasChanges(Project project); + /// The to save. + /// true if last was set and is different from , false otherwise. + /// Thrown when is null. + bool HasChanges(IProject project); } } \ No newline at end of file Index: Core/Common/src/Core.Common.Gui/Commands/ICommandsOwner.cs =================================================================== diff -u -r4512af7782ee31b36941bb280b54d9da2953dd71 -r1eed3e3f652618c52a462edc502cfd4250772314 --- Core/Common/src/Core.Common.Gui/Commands/ICommandsOwner.cs (.../ICommandsOwner.cs) (revision 4512af7782ee31b36941bb280b54d9da2953dd71) +++ Core/Common/src/Core.Common.Gui/Commands/ICommandsOwner.cs (.../ICommandsOwner.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -19,8 +19,6 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. -using Core.Common.Base.Data; - namespace Core.Common.Gui.Commands { /// @@ -39,11 +37,6 @@ IStorageCommands StorageCommands { get; } /// - /// Gets the commands related to dealing with the application's . - /// - IProjectCommands ProjectCommands { get; } - - /// /// Gets the commands related to view manipulation. /// IViewCommands ViewCommands { get; } Fisheye: Tag 1eed3e3f652618c52a462edc502cfd4250772314 refers to a dead (removed) revision in file `Core/Common/src/Core.Common.Gui/Commands/IProjectCommands.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Core/Common/src/Core.Common.Gui/Commands/IStorageCommands.cs =================================================================== diff -u -r669853e6468fcf1301a64f5df1400456fe6929eb -r1eed3e3f652618c52a462edc502cfd4250772314 --- Core/Common/src/Core.Common.Gui/Commands/IStorageCommands.cs (.../IStorageCommands.cs) (revision 669853e6468fcf1301a64f5df1400456fe6929eb) +++ Core/Common/src/Core.Common.Gui/Commands/IStorageCommands.cs (.../IStorageCommands.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -24,7 +24,7 @@ namespace Core.Common.Gui.Commands { /// - /// Interface for exposing commands/methods related to saving/loading a . + /// Interface for exposing commands/methods related to saving/loading a . /// public interface IStorageCommands { @@ -51,15 +51,15 @@ /// Asks the user to select the file to load a project from, then proceeds to perform /// the read of the project data. /// - /// true if an existing has been loaded, + /// true if an existing has been loaded, /// false otherwise (for example, user cancelled). bool OpenExistingProject(); /// /// Loads a project from a given file-location. /// /// Location of the storage file. - /// true if an existing has been loaded, + /// true if an existing has been loaded, /// false otherwise. bool OpenExistingProject(string filePath); } Fisheye: Tag 1eed3e3f652618c52a462edc502cfd4250772314 refers to a dead (removed) revision in file `Core/Common/src/Core.Common.Gui/Commands/ProjectCommandHandler.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Core/Common/src/Core.Common.Gui/Commands/StorageCommandHandler.cs =================================================================== diff -u -r3ce8a0c103af363c8e00798d95588ebe4d1e04a5 -r1eed3e3f652618c52a462edc502cfd4250772314 --- Core/Common/src/Core.Common.Gui/Commands/StorageCommandHandler.cs (.../StorageCommandHandler.cs) (revision 3ce8a0c103af363c8e00798d95588ebe4d1e04a5) +++ Core/Common/src/Core.Common.Gui/Commands/StorageCommandHandler.cs (.../StorageCommandHandler.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -30,7 +30,7 @@ namespace Core.Common.Gui.Commands { /// - /// Class responsible for persistency of . + /// Class responsible for persistency of . /// public class StorageCommandHandler : IStorageCommands { @@ -60,13 +60,15 @@ public bool ContinueIfHasChanges() { var project = projectOwner.Project; - if (project == null || ProjectComparer.EqualsToNew(project) || !projectPersistor.HasChanges(project)) + if (project == null || projectOwner.EqualsToNew(project) || !projectPersistor.HasChanges(project)) { return true; } return OpenSaveOrDiscardProjectDialog(); } + public void Dispose() {} + public void CreateNewProject() { if (!ContinueIfHasChanges()) @@ -77,7 +79,7 @@ CloseProject(); log.Info(Resources.StorageCommandHandler_NewProject_Creating_new_project); - projectOwner.Project = new Project(); + projectOwner.CreateNewProject(); projectOwner.ProjectFilePath = ""; log.Info(Resources.StorageCommandHandler_NewProject_Created_new_project_succesful); } @@ -112,30 +114,18 @@ if (!isOpenProjectSuccessful) { log.Error(Resources.StorageCommandHandler_OpeningExistingProject_Opening_existing_project_failed); - newProject = new Project(); } else { log.Info(Resources.StorageCommandHandler_OpeningExistingProject_Opening_existing_project_successful); newProject.Name = Path.GetFileNameWithoutExtension(filePath); projectOwner.ProjectFilePath = filePath; + projectOwner.Project = newProject; } - projectOwner.Project = newProject; return isOpenProjectSuccessful; } - private void CloseProject() - { - if (projectOwner.Project == null) - { - return; - } - projectOwner.Project = null; - projectOwner.ProjectFilePath = ""; - projectPersistor.CloseProject(); - } - public bool SaveProjectAs() { var project = projectOwner.Project; @@ -187,8 +177,15 @@ return true; } - public void Dispose() + private void CloseProject() { + if (projectOwner.Project == null) + { + return; + } + projectOwner.CloseProject(); + projectOwner.ProjectFilePath = ""; + projectPersistor.CloseProject(); } private bool OpenSaveOrDiscardProjectDialog() @@ -217,9 +214,9 @@ /// The loaded from or null if the project /// could not be loaded from . /// is invalid. - private Project LoadProjectFromStorage(string filePath) + private IProject LoadProjectFromStorage(string filePath) { - Project loadedProject = null; + IProject loadedProject = null; try { Index: Core/Common/src/Core.Common.Gui/Commands/ViewCommandHandler.cs =================================================================== diff -u -r223b2a4edc4ac816051c7eeecb735c34a6246574 -r1eed3e3f652618c52a462edc502cfd4250772314 --- Core/Common/src/Core.Common.Gui/Commands/ViewCommandHandler.cs (.../ViewCommandHandler.cs) (revision 223b2a4edc4ac816051c7eeecb735c34a6246574) +++ Core/Common/src/Core.Common.Gui/Commands/ViewCommandHandler.cs (.../ViewCommandHandler.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -32,20 +32,20 @@ { private readonly IViewController viewController; private readonly IApplicationSelection applicationSelection; - private readonly IGuiPluginsHost guiPluginsHost; + private readonly IPluginsHost pluginsHost; /// /// Initializes a new instance of the class. /// /// The controller for views. /// The application selection mechanism. - /// The gui-plugins host. + /// The plugins host. public ViewCommandHandler(IViewController viewController, IApplicationSelection applicationSelection, - IGuiPluginsHost guiPluginsHost) + IPluginsHost pluginsHost) { this.viewController = viewController; this.applicationSelection = applicationSelection; - this.guiPluginsHost = guiPluginsHost; + this.pluginsHost = pluginsHost; } public void OpenViewForSelection() @@ -75,7 +75,7 @@ dataObject }; - objectsToRemoveViewsFor.AddRange(guiPluginsHost.GetAllDataWithViewDefinitionsRecursively(dataObject).Cast()); + objectsToRemoveViewsFor.AddRange(pluginsHost.GetAllDataWithViewDefinitionsRecursively(dataObject).Cast()); foreach (var data in objectsToRemoveViewsFor) { Index: Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj =================================================================== diff -u -r62866464bfe7d4dc1949370f577365d51c25bfa0 -r1eed3e3f652618c52a462edc502cfd4250772314 --- Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj (.../Core.Common.Gui.csproj) (revision 62866464bfe7d4dc1949370f577365d51c25bfa0) +++ Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj (.../Core.Common.Gui.csproj) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -123,10 +123,8 @@ - - @@ -148,7 +146,7 @@ - + @@ -395,6 +393,8 @@ + + Index: Core/Common/src/Core.Common.Gui/Forms/IProjectExplorer.cs =================================================================== diff -u -r652b03cb8115830641e05bffb356bcf5779bc9f0 -r1eed3e3f652618c52a462edc502cfd4250772314 --- Core/Common/src/Core.Common.Gui/Forms/IProjectExplorer.cs (.../IProjectExplorer.cs) (revision 652b03cb8115830641e05bffb356bcf5779bc9f0) +++ Core/Common/src/Core.Common.Gui/Forms/IProjectExplorer.cs (.../IProjectExplorer.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -26,7 +26,7 @@ namespace Core.Common.Gui.Forms { /// - /// View to show the contents of a instance. + /// View to show the contents of a instance. /// public interface IProjectExplorer : IView { Index: Core/Common/src/Core.Common.Gui/Forms/MainWindow/MainWindow.xaml.cs =================================================================== diff -u -r3fdd2bee85bdf8b556c52d6706ed887c2b70bed4 -r1eed3e3f652618c52a462edc502cfd4250772314 --- Core/Common/src/Core.Common.Gui/Forms/MainWindow/MainWindow.xaml.cs (.../MainWindow.xaml.cs) (revision 3fdd2bee85bdf8b556c52d6706ed887c2b70bed4) +++ Core/Common/src/Core.Common.Gui/Forms/MainWindow/MainWindow.xaml.cs (.../MainWindow.xaml.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -572,10 +572,10 @@ ValidateItems(); } - private void UpdateRibbonExtensions(IGuiPluginsHost guiPluginsHost) + private void UpdateRibbonExtensions(IPluginsHost pluginsHost) { // get all ribbon controls - ribbonCommandHandlers = guiPluginsHost.Plugins.Where(p => p.RibbonCommandHandler != null).Select(p => p.RibbonCommandHandler).ToArray(); + ribbonCommandHandlers = pluginsHost.Plugins.Where(p => p.RibbonCommandHandler != null).Select(p => p.RibbonCommandHandler).ToArray(); foreach (var ribbonExtension in ribbonCommandHandlers) { Index: Core/Common/src/Core.Common.Gui/GuiCore.cs =================================================================== diff -u -rb78b6d08e4be8dfe938718d5e65085aa8bd72dcc -r1eed3e3f652618c52a462edc502cfd4250772314 --- Core/Common/src/Core.Common.Gui/GuiCore.cs (.../GuiCore.cs) (revision b78b6d08e4be8dfe938718d5e65085aa8bd72dcc) +++ Core/Common/src/Core.Common.Gui/GuiCore.cs (.../GuiCore.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -64,6 +64,8 @@ private static bool isAlreadyRunningInstanceOfIGui; private static string instanceCreationStackTrace; + private readonly IProjectFactory projectFactory; + private SplashScreen splashScreen; private bool runFinished; @@ -74,11 +76,12 @@ /// /// The main window. /// The project store. + /// The project factory. /// The fixed settings. /// When another /// instance is running. /// When any parameter is null. - public GuiCore(IMainWindow mainWindow, IStoreProject projectStore, GuiCoreSettings fixedSettings) + public GuiCore(IMainWindow mainWindow, IStoreProject projectStore, IProjectFactory projectFactory, GuiCoreSettings fixedSettings) { // error detection code, make sure we use only a single instance of GuiCore at a time if (isAlreadyRunningInstanceOfIGui) @@ -95,10 +98,16 @@ { throw new ArgumentNullException("projectStore"); } + if (projectFactory == null) + { + throw new ArgumentNullException("projectFactory"); + } if (fixedSettings == null) { throw new ArgumentNullException("fixedSettings"); } + this.projectFactory = projectFactory; + MainWindow = mainWindow; FixedSettings = fixedSettings; @@ -114,7 +123,6 @@ exportImportCommandHandler = new ExportImportCommandHandler(MainWindow, Plugins.SelectMany(p => p.GetFileImporters()), Plugins.SelectMany(p => p.GetFileExporters())); - projectCommandHandler = new ProjectCommandHandler(this, MainWindow, Plugins.SelectMany(p => p.GetDataItemInfos()), this, this); WindowsApplication.EnableVisualStyles(); ViewPropertyEditor.ViewCommands = ViewCommands; @@ -203,6 +211,14 @@ #endregion + private IProjectExplorer ProjectExplorer + { + get + { + return ViewHost.ToolViews.OfType().FirstOrDefault(); + } + } + private void Dispose(bool disposing) { if (disposing) @@ -327,14 +343,6 @@ isAlreadyRunningInstanceOfIGui = false; } - private IProjectExplorer ProjectExplorer - { - get - { - return ViewHost.ToolViews.OfType().FirstOrDefault(); - } - } - private void InitializeProjectFromPath(string projectPath) { var setDefaultProject = string.IsNullOrWhiteSpace(projectPath); @@ -345,7 +353,7 @@ if (setDefaultProject) { log.Info(Resources.GuiCore_Run_Creating_new_project); - Project = new Project(); + CreateNewProject(); } } @@ -373,7 +381,7 @@ } } - private void ApplicationProjectOpened(Project project) + private void ApplicationProjectOpened(IProject newProject) { ResumeUI(); } @@ -592,14 +600,14 @@ #region Implementation: IProjectOwner - private Project project; + private IProject project; private readonly Observer projectObserver; - public event Action ProjectOpened; + public event Action ProjectOpened; public string ProjectFilePath { get; set; } - public Project Project + public IProject Project { get { @@ -626,6 +634,21 @@ } } + public bool EqualsToNew(IProject other) + { + return Project != null && Project.Equals(projectFactory.CreateNewProject()); + } + + public void CreateNewProject() + { + Project = projectFactory.CreateNewProject(); + } + + public void CloseProject() + { + Project = null; + } + #endregion #region Implementation: IApplicationSelection @@ -678,7 +701,6 @@ private ApplicationFeatureCommandHandler applicationFeatureCommands; private readonly ViewCommandHandler viewCommandHandler; - private readonly ProjectCommandHandler projectCommandHandler; private readonly ExportImportCommandHandler exportImportCommandHandler; private StorageCommandHandler storageCommandHandler; @@ -698,14 +720,6 @@ } } - public IProjectCommands ProjectCommands - { - get - { - return projectCommandHandler; - } - } - public IViewCommands ViewCommands { get Index: Core/Common/src/Core.Common.Gui/IGui.cs =================================================================== diff -u -rb78b6d08e4be8dfe938718d5e65085aa8bd72dcc -r1eed3e3f652618c52a462edc502cfd4250772314 --- Core/Common/src/Core.Common.Gui/IGui.cs (.../IGui.cs) (revision b78b6d08e4be8dfe938718d5e65085aa8bd72dcc) +++ Core/Common/src/Core.Common.Gui/IGui.cs (.../IGui.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -34,7 +34,7 @@ /// public interface IGui : ICommandsOwner, ISettingsOwner, IProjectOwner, IApplicationSelection, IViewController, IContextMenuBuilderProvider, - IMainWindowController, IGuiPluginsHost, IDisposable + IMainWindowController, IPluginsHost, IDisposable { /// /// Gets the object responsible for retrieving the Fisheye: Tag 1eed3e3f652618c52a462edc502cfd4250772314 refers to a dead (removed) revision in file `Core/Common/src/Core.Common.Gui/IGuiPluginsHost.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Core/Common/src/Core.Common.Gui/IPluginsHost.cs =================================================================== diff -u --- Core/Common/src/Core.Common.Gui/IPluginsHost.cs (revision 0) +++ Core/Common/src/Core.Common.Gui/IPluginsHost.cs (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -0,0 +1,53 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets 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.Collections; +using System.Collections.Generic; +using Core.Common.Controls.TreeView; +using Core.Common.Gui.Plugin; + +namespace Core.Common.Gui +{ + /// + /// Interface describing the object that hosts all the loaded graphical user interface + /// plugins of the application. + /// + public interface IPluginsHost + { + /// + /// Gets the list of plugins. + /// + IList Plugins { get; } + + /// + /// Queries the plugins to get all data with view definitions recursively, given a + /// piece of hierarchical data. + /// + /// The root data object. + /// An enumeration of all (child)data that have view definitions declared. + IEnumerable GetAllDataWithViewDefinitionsRecursively(object rootDataObject); + + /// + /// Retrieves all the defined on the configured plugins. + /// + IEnumerable GetTreeNodeInfos(); + } +} \ No newline at end of file Index: Core/Common/src/Core.Common.Gui/IProjectOwner.cs =================================================================== diff -u -rb78b6d08e4be8dfe938718d5e65085aa8bd72dcc -r1eed3e3f652618c52a462edc502cfd4250772314 --- Core/Common/src/Core.Common.Gui/IProjectOwner.cs (.../IProjectOwner.cs) (revision b78b6d08e4be8dfe938718d5e65085aa8bd72dcc) +++ Core/Common/src/Core.Common.Gui/IProjectOwner.cs (.../IProjectOwner.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -20,29 +20,45 @@ // All rights reserved. using System; - using Core.Common.Base.Data; namespace Core.Common.Gui { /// - /// Interface declaring members related to owning a . + /// Interface declaring members related to owning a . /// public interface IProjectOwner { /// - /// Occurs when a new instance is available at . + /// Occurs when a new instance is available at . /// - event Action ProjectOpened; + event Action ProjectOpened; /// /// Gets or sets the project of the application. /// - Project Project { get; set; } + IProject Project { get; set; } /// /// Gets or sets the project path of the application. /// - string ProjectFilePath { get; set; } + string ProjectFilePath { get; set; } + + /// + /// Indicates whether the current is equal to . + /// + /// The to compare with . + /// true if is equal to ; false otherwise. + bool EqualsToNew(IProject other); + + /// + /// Creates a new . + /// + void CreateNewProject(); + + /// + /// Closes the current . + /// + void CloseProject(); } } \ No newline at end of file Index: Core/Common/src/Core.Common.Gui/Properties/Resources.Designer.cs =================================================================== diff -u -ra1ec5faebf7ccf8e67fa34a2b73cd1063ab48840 -r1eed3e3f652618c52a462edc502cfd4250772314 --- Core/Common/src/Core.Common.Gui/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision a1ec5faebf7ccf8e67fa34a2b73cd1063ab48840) +++ Core/Common/src/Core.Common.Gui/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -976,6 +976,16 @@ } /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap PlusIcon { + get { + object obj = ResourceManager.GetObject("PlusIcon", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// /// Looks up a localized string similar to Fout bij het opslaan van de instellingen in {0}.. /// public static string PortableSettingsProvider_SetPropertyValues_Error_storing_settings_to_0_ { @@ -1004,6 +1014,16 @@ } /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap ProjectIcon { + get { + object obj = ResourceManager.GetObject("ProjectIcon", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// /// Looks up a localized string similar to Ei&genschappen. /// public static string Properties { Index: Core/Common/src/Core.Common.Gui/Properties/Resources.resx =================================================================== diff -u -ra1ec5faebf7ccf8e67fa34a2b73cd1063ab48840 -r1eed3e3f652618c52a462edc502cfd4250772314 --- Core/Common/src/Core.Common.Gui/Properties/Resources.resx (.../Resources.resx) (revision a1ec5faebf7ccf8e67fa34a2b73cd1063ab48840) +++ Core/Common/src/Core.Common.Gui/Properties/Resources.resx (.../Resources.resx) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -595,4 +595,10 @@ Fout + + ..\Resources\plus.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\project-16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file Index: Core/Common/src/Core.Common.Gui/Resources/plus.png =================================================================== diff -u Binary files differ Index: Core/Common/src/Core.Common.Gui/Resources/project-16.png =================================================================== diff -u -rdc41fb966f99f5200c570d70e16397087ffa87c8 -r1eed3e3f652618c52a462edc502cfd4250772314 Binary files differ Index: Core/Common/test/Core.Common.Base.Test/Core.Common.Base.Test.csproj =================================================================== diff -u -r62866464bfe7d4dc1949370f577365d51c25bfa0 -r1eed3e3f652618c52a462edc502cfd4250772314 --- Core/Common/test/Core.Common.Base.Test/Core.Common.Base.Test.csproj (.../Core.Common.Base.Test.csproj) (revision 62866464bfe7d4dc1949370f577365d51c25bfa0) +++ Core/Common/test/Core.Common.Base.Test/Core.Common.Base.Test.csproj (.../Core.Common.Base.Test.csproj) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -89,7 +89,6 @@ - Fisheye: Tag 1eed3e3f652618c52a462edc502cfd4250772314 refers to a dead (removed) revision in file `Core/Common/test/Core.Common.Base.Test/Data/ProjectComparerTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Core/Common/test/Core.Common.Base.Test/Data/ProjectTest.cs =================================================================== diff -u -r151bab16a7ebc1bffc0621ab56c6dc219db1e90f -r1eed3e3f652618c52a462edc502cfd4250772314 --- Core/Common/test/Core.Common.Base.Test/Data/ProjectTest.cs (.../ProjectTest.cs) (revision 151bab16a7ebc1bffc0621ab56c6dc219db1e90f) +++ Core/Common/test/Core.Common.Base.Test/Data/ProjectTest.cs (.../ProjectTest.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -35,7 +35,7 @@ var project = new Project(); // Assert - Assert.IsInstanceOf(project); + Assert.IsInstanceOf(project); Assert.AreEqual("Project", project.Name); Assert.AreEqual("", project.Description); CollectionAssert.IsEmpty(project.Items); @@ -51,7 +51,7 @@ var project = new Project(someName); // Assert - Assert.IsInstanceOf(project); + Assert.IsInstanceOf(project); Assert.AreEqual(someName, project.Name); Assert.AreEqual("", project.Description); CollectionAssert.IsEmpty(project.Items); @@ -77,6 +77,114 @@ } [Test] + public void Equals_NewProject_ReturnsTrue() + { + // Setup + Project newProjectA = new Project(); + Project newProjectB = new Project(); + + // Call + bool result = newProjectA.Equals(newProjectB); + bool result2 = newProjectB.Equals(newProjectA); + + // Assert + Assert.IsTrue(result); + Assert.IsTrue(result2); + } + + [Test] + public void Equals_ProjectNameChanged_ReturnsFalse() + { + // Setup + Project newProject = new Project(); + Project changedProject = new Project + { + Name = "" + }; + + // Call + bool result = newProject.Equals(changedProject); + bool result2 = changedProject.Equals(newProject); + + // Assert + Assert.IsFalse(result); + Assert.IsFalse(result2); + } + + [Test] + public void Equals_ProjectDescriptionChanged_ReturnsFalse() + { + // Setup + Project newProject = new Project(); + Project changedProject = new Project + { + Description = "" + }; + + // Call + bool result = newProject.Equals(changedProject); + bool result2 = changedProject.Equals(newProject); + + // Assert + Assert.IsFalse(result); + Assert.IsFalse(result2); + } + + [Test] + public void Equals_ProjectStorageIdChanged_ReturnsFalse() + { + // Setup + Project newProject = new Project(); + Project changedProject = new Project + { + StorageId = 1L + }; + + // Call + bool result = newProject.Equals(changedProject); + bool result2 = changedProject.Equals(newProject); + + // Assert + Assert.IsFalse(result); + Assert.IsFalse(result2); + } + + [Test] + public void Equals_ProjectItemsChanged_ReturnsFalse() + { + // Setup + Project newProject = new Project(); + Project changedProject = new Project(); + newProject.Items.Add(new object()); + + // Call + bool result = newProject.Equals(changedProject); + bool result2 = changedProject.Equals(newProject); + + // Assert + Assert.IsFalse(result); + Assert.IsFalse(result2); + } + + [Test] + public void GetHashCode_ProjectsAreEqual_ReturnsEqualHashes() + { + // Setup + const long storageId = 1234; + const string name = "Some name"; + const string desctiption = "Some desctiption"; + var project = new Project(name){StorageId=storageId,Description=desctiption}; + var otherProject = new Project(name) { StorageId = storageId, Description = desctiption }; + + // Call + var result = project.GetHashCode(); + var otherResult = otherProject.GetHashCode(); + + // Assert + Assert.AreEqual(result, otherResult); + } + + [Test] public void NotifyObservers_WithObserverAttached_ObserverIsNotified() { // Setup Fisheye: Tag 1eed3e3f652618c52a462edc502cfd4250772314 refers to a dead (removed) revision in file `Core/Common/test/Core.Common.Gui.Test/Commands/ProjectCommandHandlerTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Core/Common/test/Core.Common.Gui.Test/Commands/StorageCommandHandlerTest.cs =================================================================== diff -u -r669853e6468fcf1301a64f5df1400456fe6929eb -r1eed3e3f652618c52a462edc502cfd4250772314 --- Core/Common/test/Core.Common.Gui.Test/Commands/StorageCommandHandlerTest.cs (.../StorageCommandHandlerTest.cs) (revision 669853e6468fcf1301a64f5df1400456fe6929eb) +++ Core/Common/test/Core.Common.Gui.Test/Commands/StorageCommandHandlerTest.cs (.../StorageCommandHandlerTest.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -49,9 +49,8 @@ { // Setup var projectStorage = mocks.Stub(); - var projectOwner = mocks.Stub(); - + projectOwner.Expect(po => po.CreateNewProject()); var mainWindowController = mocks.Stub(); mocks.ReplayAll(); @@ -71,8 +70,6 @@ "Nieuw Ringtoetsproject succesvol geopend." }; TestHelper.AssertLogMessagesAreGenerated(call, expectedMessages, 2); - - Assert.IsInstanceOf(projectOwner.Project); Assert.AreEqual("", projectOwner.ProjectFilePath); mocks.VerifyAll(); } @@ -83,15 +80,14 @@ // Setup const string savedProjectPath = @"C:\savedProject.rtd"; - var projectMock = mocks.StrictMock(); - projectMock.Name = "test"; - projectMock.StorageId = 1234L; - + var projectMock = mocks.StrictMock(); var projectStorage = mocks.Stub(); - var projectOwner = mocks.Stub(); projectOwner.Project = projectMock; projectOwner.ProjectFilePath = savedProjectPath; + projectOwner.Expect(po => po.CreateNewProject()); + projectOwner.Expect(po => po.EqualsToNew(projectMock)).Return(true); + projectOwner.Expect(po => po.CloseProject()); var mainWindowController = mocks.Stub(); @@ -113,10 +109,7 @@ }; TestHelper.AssertLogMessagesAreGenerated(call, expectedMessages, 2); - Assert.IsInstanceOf(projectOwner.Project); - Assert.AreNotEqual(projectMock, projectOwner.Project); - Assert.AreNotEqual(projectMock.StorageId, projectOwner.Project.StorageId); - Assert.AreNotEqual(savedProjectPath, projectOwner.ProjectFilePath); + Assert.IsInstanceOf(projectOwner.Project); Assert.AreEqual("", projectOwner.ProjectFilePath); mocks.VerifyAll(); @@ -406,7 +399,7 @@ { // Setup var mainWindowController = mocks.Stub(); - var projectMock = mocks.StrictMock(); + var projectMock = mocks.StrictMock(); var projectStorageMock = mocks.Stub(); var projectOwnerMock = mocks.Stub(); projectOwnerMock.Project = projectMock; @@ -432,7 +425,9 @@ { // Setup var mainWindowController = mocks.Stub(); - var projectMock = mocks.StrictMock(); + var projectMock = mocks.Stub(); + const string projectName = "Project"; + projectMock.Name = projectName; projectMock.StorageId = 1234L; var projectStorageMock = mocks.Stub(); projectStorageMock.Expect(p => p.HasChanges(null)).IgnoreArguments().Return(true); @@ -442,7 +437,7 @@ mocks.ReplayAll(); string messageBoxText = null; - string expectedMessage = "Sla wijzigingen in het project op: Project?"; + string expectedMessage = string.Format("Sla wijzigingen in het project op: {0}?", projectName); var storageCommandHandler = new StorageCommandHandler( projectStorageMock, @@ -472,7 +467,9 @@ { // Setup var mainWindowController = mocks.Stub(); - var projectMock = mocks.StrictMock(); + var projectMock = mocks.Stub(); + const string projectName = "Project"; + projectMock.Name = projectName; projectMock.StorageId = 1234L; var projectStorageMock = mocks.Stub(); projectStorageMock.Expect(p => p.HasChanges(null)).IgnoreArguments().Return(true); @@ -482,7 +479,7 @@ mocks.ReplayAll(); string messageBoxText = null; - string expectedMessage = "Sla wijzigingen in het project op: Project?"; + string expectedMessage = string.Format("Sla wijzigingen in het project op: {0}?", projectName); var storageCommandHandler = new StorageCommandHandler( projectStorageMock, @@ -512,7 +509,9 @@ { // Setup var mainWindowController = mocks.Stub(); - var projectMock = mocks.StrictMock(); + var projectMock = mocks.Stub(); + const string projectName = "Project"; + projectMock.Name = projectName; projectMock.StorageId = 1234L; var projectFilePath = "some path"; @@ -527,7 +526,7 @@ mocks.ReplayAll(); string messageBoxText = null; - string expectedMessage = "Sla wijzigingen in het project op: Project?"; + string expectedMessage = string.Format("Sla wijzigingen in het project op: {0}?", projectName); var storageCommandHandler = new StorageCommandHandler( projectStorageMock, @@ -557,7 +556,9 @@ { // Setup var mainWindowController = mocks.Stub(); - var projectMock = mocks.StrictMock(); + var projectMock = mocks.Stub(); + const string projectName = "Project"; + projectMock.Name = projectName; projectMock.StorageId = 1234L; var projectStorageMock = mocks.Stub(); projectStorageMock.Expect(p => p.HasChanges(null)).IgnoreArguments().Return(true); @@ -567,7 +568,7 @@ mocks.ReplayAll(); string messageBoxText = null; - string expectedMessage = "Sla wijzigingen in het project op: Project?"; + string expectedMessage = string.Format("Sla wijzigingen in het project op: {0}?", projectName); var storageCommandHandler = new StorageCommandHandler( projectStorageMock, Index: Core/Common/test/Core.Common.Gui.Test/Commands/ViewCommandHandlerTest.cs =================================================================== diff -u -r223b2a4edc4ac816051c7eeecb735c34a6246574 -r1eed3e3f652618c52a462edc502cfd4250772314 --- Core/Common/test/Core.Common.Gui.Test/Commands/ViewCommandHandlerTest.cs (.../ViewCommandHandlerTest.cs) (revision 223b2a4edc4ac816051c7eeecb735c34a6246574) +++ Core/Common/test/Core.Common.Gui.Test/Commands/ViewCommandHandlerTest.cs (.../ViewCommandHandlerTest.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -20,15 +20,12 @@ // All rights reserved. using System.Collections.Generic; - using Core.Common.Controls.Views; using Core.Common.Gui.Commands; using Core.Common.Gui.Forms.ViewHost; using Core.Common.Gui.Plugin; using Core.Common.Gui.Selection; - using NUnit.Framework; - using Rhino.Mocks; namespace Core.Common.Gui.Test.Commands @@ -49,10 +46,10 @@ viewController.Stub(c => c.DocumentViewController).Return(documentViewController); var applicationSelection = mocks.Stub(); applicationSelection.Selection = selectedObject; - var guiPluginsHost = mocks.Stub(); + var pluginsHost = mocks.Stub(); mocks.ReplayAll(); - var commandHandler = new ViewCommandHandler(viewController, applicationSelection, guiPluginsHost); + var commandHandler = new ViewCommandHandler(viewController, applicationSelection, pluginsHost); // Call commandHandler.OpenViewForSelection(); @@ -75,10 +72,10 @@ var viewController = mocks.Stub(); viewController.Stub(c => c.DocumentViewController).Return(documentViewController); var applicationSelection = mocks.Stub(); - var guiPluginsHost = mocks.Stub(); + var pluginsHost = mocks.Stub(); mocks.ReplayAll(); - var commandHandler = new ViewCommandHandler(viewController, applicationSelection, guiPluginsHost); + var commandHandler = new ViewCommandHandler(viewController, applicationSelection, pluginsHost); // Call var hasViewDefinitionsForData = commandHandler.CanOpenViewFor(viewObject); @@ -108,10 +105,10 @@ var viewController = mocks.Stub(); viewController.Stub(c => c.DocumentViewController).Return(documentViewController); var applicationSelection = mocks.Stub(); - var guiPluginsHost = mocks.Stub(); + var pluginsHost = mocks.Stub(); mocks.ReplayAll(); - var commandHandler = new ViewCommandHandler(viewController, applicationSelection, guiPluginsHost); + var commandHandler = new ViewCommandHandler(viewController, applicationSelection, pluginsHost); // Call var hasViewDefinitionsForData = commandHandler.CanOpenViewFor(viewObject); @@ -133,10 +130,10 @@ var viewController = mocks.Stub(); viewController.Stub(c => c.DocumentViewController).Return(documentViewController); var applicationSelection = mocks.Stub(); - var guiPluginsHost = mocks.Stub(); + var pluginsHost = mocks.Stub(); mocks.ReplayAll(); - var commandHandler = new ViewCommandHandler(viewController, applicationSelection, guiPluginsHost); + var commandHandler = new ViewCommandHandler(viewController, applicationSelection, pluginsHost); // Call commandHandler.OpenView(viewObject); @@ -152,10 +149,10 @@ var mocks = new MockRepository(); var viewController = mocks.StrictMock(); var applicationSelection = mocks.StrictMock(); - var guiPluginsHost = mocks.StrictMock(); + var pluginsHost = mocks.StrictMock(); mocks.ReplayAll(); - var commandHandler = new ViewCommandHandler(viewController, applicationSelection, guiPluginsHost); + var commandHandler = new ViewCommandHandler(viewController, applicationSelection, pluginsHost); // Call commandHandler.RemoveAllViewsForItem(null); @@ -172,10 +169,10 @@ var viewController = mocks.StrictMock(); viewController.Expect(c => c.ViewHost).Return(null); var applicationSelection = mocks.StrictMock(); - var guiPluginsHost = mocks.StrictMock(); + var pluginsHost = mocks.StrictMock(); mocks.ReplayAll(); - var commandHandler = new ViewCommandHandler(viewController, applicationSelection, guiPluginsHost); + var commandHandler = new ViewCommandHandler(viewController, applicationSelection, pluginsHost); // Call commandHandler.RemoveAllViewsForItem(new object()); @@ -211,8 +208,8 @@ viewHost.Stub(ws => ws.DocumentViews).Return(viewsArray); var applicationSelection = mocks.Stub(); - var guiPluginsHost = mocks.Stub(); - guiPluginsHost.Expect(g => g.GetAllDataWithViewDefinitionsRecursively(data)).Return(new[] + var pluginsHost = mocks.Stub(); + pluginsHost.Expect(g => g.GetAllDataWithViewDefinitionsRecursively(data)).Return(new[] { childData }); @@ -221,7 +218,7 @@ viewController.Stub(g => g.DocumentViewController).Return(documentViewsResolver); mocks.ReplayAll(); - var viewCommandHandler = new ViewCommandHandler(viewController, applicationSelection, guiPluginsHost); + var viewCommandHandler = new ViewCommandHandler(viewController, applicationSelection, pluginsHost); // Call viewCommandHandler.RemoveAllViewsForItem(data); Index: Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Test.csproj =================================================================== diff -u -r62866464bfe7d4dc1949370f577365d51c25bfa0 -r1eed3e3f652618c52a462edc502cfd4250772314 --- Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Test.csproj (.../Core.Common.Gui.Test.csproj) (revision 62866464bfe7d4dc1949370f577365d51c25bfa0) +++ Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Test.csproj (.../Core.Common.Gui.Test.csproj) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -104,7 +104,6 @@ - Index: Core/Common/test/Core.Common.Gui.Test/GuiCoreTest.cs =================================================================== diff -u -rb78b6d08e4be8dfe938718d5e65085aa8bd72dcc -r1eed3e3f652618c52a462edc502cfd4250772314 --- Core/Common/test/Core.Common.Gui.Test/GuiCoreTest.cs (.../GuiCoreTest.cs) (revision b78b6d08e4be8dfe938718d5e65085aa8bd72dcc) +++ Core/Common/test/Core.Common.Gui.Test/GuiCoreTest.cs (.../GuiCoreTest.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -77,14 +77,15 @@ // Setup var mocks = new MockRepository(); var projectStore = mocks.Stub(); + var projectFactory = mocks.Stub(); mocks.ReplayAll(); var guiCoreSettings = new GuiCoreSettings(); // Call using (var mainWindow = new MainWindow()) { - using (var gui = new GuiCore(mainWindow, projectStore, guiCoreSettings)) + using (var gui = new GuiCore(mainWindow, projectStore, projectFactory, guiCoreSettings)) { // Assert Assert.AreEqual(null, gui.PropertyResolver); @@ -94,7 +95,6 @@ Assert.AreEqual(null, gui.Selection); - Assert.IsInstanceOf(gui.ProjectCommands); Assert.IsInstanceOf(gui.StorageCommands); Assert.IsInstanceOf(gui.ViewCommands); Assert.AreEqual(null, gui.ApplicationCommands); @@ -140,6 +140,7 @@ // Setup var mocks = new MockRepository(); IStoreProject projectStore = nullArgumentIndex == 1 ? null : mocks.Stub(); + var projectFactory = mocks.Stub(); mocks.ReplayAll(); GuiCoreSettings guiCoreSettings = nullArgumentIndex == 2 ? null : new GuiCoreSettings(); @@ -149,7 +150,7 @@ { // Call - TestDelegate call = () => new GuiCore(nullArgumentIndex == 0 ? null : mainWindow, projectStore, guiCoreSettings); + TestDelegate call = () => new GuiCore(nullArgumentIndex == 0 ? null : mainWindow, projectStore, projectFactory, guiCoreSettings); // Assert TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "Value cannot be null."); @@ -165,17 +166,18 @@ // Setup var mocks = new MockRepository(); var projectStore = mocks.Stub(); + var projectFactory = mocks.Stub(); mocks.ReplayAll(); var guiCoreSettings = new GuiCoreSettings(); // Call using (var mainWindow = new MainWindow()) { - using (var gui = new GuiCore(mainWindow, projectStore, guiCoreSettings)) + using (var gui = new GuiCore(mainWindow, projectStore, projectFactory, guiCoreSettings)) { // Call - using (var gui2 = new GuiCore(mainWindow, projectStore, guiCoreSettings)) + using (var gui2 = new GuiCore(mainWindow, projectStore, projectFactory, guiCoreSettings)) { // Assert Assert.Fail("Expected an InvalidOperationException to be thrown."); @@ -195,9 +197,10 @@ var pluginMock = mocks.Stub(); pluginMock.Expect(p => p.Deactivate()); pluginMock.Expect(p => p.Dispose()); + var projectFactory = mocks.Stub(); mocks.ReplayAll(); - var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings()); + var gui = new GuiCore(new MainWindow(), projectStore, projectFactory, new GuiCoreSettings()); gui.Plugins.Add(pluginMock); // Call @@ -218,9 +221,10 @@ var pluginMock = mocks.Stub(); pluginMock.Expect(p => p.Deactivate()).Throw(new Exception("Bad stuff happening!")); pluginMock.Expect(p => p.Dispose()); + var projectFactory = mocks.Stub(); mocks.ReplayAll(); - var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings()); + var gui = new GuiCore(new MainWindow(), projectStore, projectFactory, new GuiCoreSettings()); gui.Plugins.Add(pluginMock); // Call @@ -239,9 +243,10 @@ // Setup var mocks = new MockRepository(); var projectStore = mocks.Stub(); + var projectFactory = mocks.Stub(); mocks.ReplayAll(); - var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings()) + var gui = new GuiCore(new MainWindow(), projectStore, projectFactory, new GuiCoreSettings()) { Selection = new object() }; @@ -261,11 +266,13 @@ // Setup var mocks = new MockRepository(); var projectStore = mocks.Stub(); + var projectMock = mocks.Stub(); + var projectFactory = mocks.Stub(); mocks.ReplayAll(); - var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings()) + var gui = new GuiCore(new MainWindow(), projectStore, projectFactory, new GuiCoreSettings()) { - Project = new Project() + Project = projectMock }; // Call @@ -283,11 +290,12 @@ // Setup var mocks = new MockRepository(); var projectStore = mocks.Stub(); + var projectFactory = mocks.Stub(); mocks.ReplayAll(); using (var mainWindow = new MainWindow()) { - var gui = new GuiCore(mainWindow, projectStore, new GuiCoreSettings()); + var gui = new GuiCore(mainWindow, projectStore, projectFactory, new GuiCoreSettings()); // Call gui.Dispose(); @@ -306,6 +314,7 @@ // Setup var mocks = new MockRepository(); var projectStore = mocks.Stub(); + var projectFactory = mocks.Stub(); mocks.ReplayAll(); var messageWindowLogAppender = new MessageWindowLogAppender(); @@ -315,7 +324,7 @@ try { - using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings())) + using (var gui = new GuiCore(new MainWindow(), projectStore, projectFactory, new GuiCoreSettings())) { gui.Run(); @@ -346,11 +355,12 @@ // Setup var mocks = new MockRepository(); var projectStore = mocks.Stub(); + var projectFactory = mocks.Stub(); mocks.ReplayAll(); using (var toolView = new TestView()) { - using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings())) + using (var gui = new GuiCore(new MainWindow(), projectStore, projectFactory, new GuiCoreSettings())) { gui.Run(); @@ -374,11 +384,12 @@ // Setup var mocks = new MockRepository(); var projectStore = mocks.Stub(); + var projectFactory = mocks.Stub(); mocks.ReplayAll(); using (var documentView = new TestView()) { - using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings())) + using (var gui = new GuiCore(new MainWindow(), projectStore, projectFactory, new GuiCoreSettings())) { gui.Run(); @@ -403,6 +414,7 @@ // Setup var mocks = new MockRepository(); var projectStore = mocks.Stub(); + var projectFactory = mocks.Stub(); mocks.ReplayAll(); Logger rootLogger = ((Hierarchy) LogManager.GetRepository()).Root; @@ -411,7 +423,7 @@ try { - using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings())) + using (var gui = new GuiCore(new MainWindow(), projectStore, projectFactory, new GuiCoreSettings())) { // Call gui.Run(); @@ -444,6 +456,7 @@ // Setup var mocks = new MockRepository(); var projectStore = mocks.Stub(); + var projectFactory = mocks.Stub(); mocks.ReplayAll(); var appender = new MessageWindowLogAppender(); @@ -456,7 +469,7 @@ try { - using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings())) + using (var gui = new GuiCore(new MainWindow(), projectStore, projectFactory, new GuiCoreSettings())) { // Call gui.Run(); @@ -489,11 +502,11 @@ const string fileName = "SomeFile"; string testFile = string.Format("{0}.rtd", fileName); - var deserializedProject = new Project(); - var mocks = new MockRepository(); var projectStore = mocks.Stub(); + var deserializedProject = mocks.Stub(); projectStore.Expect(ps => ps.LoadProject(testFile)).Return(deserializedProject); + var projectFactory = mocks.Stub(); mocks.ReplayAll(); var fixedSettings = new GuiCoreSettings @@ -503,7 +516,7 @@ using (var mainWindow = new MainWindow()) { - using (var gui = new GuiCore(mainWindow, projectStore, fixedSettings)) + using (var gui = new GuiCore(mainWindow, projectStore, projectFactory, fixedSettings)) { // Call Action call = () => gui.Run(testFile); @@ -541,6 +554,11 @@ var mocks = new MockRepository(); var projectStore = mocks.Stub(); projectStore.Expect(ps => ps.LoadProject(testFile)).Throw(new StorageException(storageExceptionText)); + const string expectedProjectName = "Project"; + var project = mocks.Stub(); + project.Name = expectedProjectName; + var projectFactory = mocks.Stub(); + projectFactory.Expect(ph => ph.CreateNewProject()).Return(project); mocks.ReplayAll(); var fixedSettings = new GuiCoreSettings @@ -550,7 +568,7 @@ using (var mainWindow = new MainWindow()) { - using (var gui = new GuiCore(mainWindow, projectStore, fixedSettings)) + using (var gui = new GuiCore(mainWindow, projectStore, projectFactory, fixedSettings)) { // Call Action call = () => gui.Run(testFile); @@ -566,12 +584,6 @@ TestHelper.AssertLogMessagesAreGenerated(call, expectedMessages); Assert.IsNull(gui.ProjectFilePath); - const string expectedProjectName = "Project"; - Assert.AreEqual(expectedProjectName, gui.Project.Name); - Assert.AreEqual(string.Empty, gui.Project.Description); - CollectionAssert.IsEmpty(gui.Project.Items); - Assert.AreEqual(0, gui.Project.StorageId); - var expectedTitle = string.Format("{0} - {1} {2}", expectedProjectName, fixedSettings.MainWindowTitle, SettingsHelper.ApplicationVersion); Assert.AreEqual(expectedTitle, mainWindow.Title); @@ -590,6 +602,12 @@ // Setup var mocks = new MockRepository(); var projectStore = mocks.StrictMock(); + + const string expectedProjectName = "Project"; + var project = mocks.Stub(); + project.Name = expectedProjectName; + var projectFactory = mocks.Stub(); + projectFactory.Expect(ph => ph.CreateNewProject()).Return(project); mocks.ReplayAll(); var fixedSettings = new GuiCoreSettings @@ -599,21 +617,14 @@ using (var mainWindow = new MainWindow()) { - using (var gui = new GuiCore(mainWindow, projectStore, fixedSettings)) + using (var gui = new GuiCore(mainWindow, projectStore, projectFactory, fixedSettings)) { // Call Action call = () => gui.Run(path); // Assert TestHelper.AssertLogMessageIsGenerated(call, "Nieuw project aanmaken..."); - Assert.IsNull(gui.ProjectFilePath); - const string expectedProjectName = "Project"; - Assert.AreEqual(expectedProjectName, gui.Project.Name); - Assert.AreEqual(string.Empty, gui.Project.Description); - CollectionAssert.IsEmpty(gui.Project.Items); - Assert.AreEqual(0, gui.Project.StorageId); - var expectedTitle = string.Format("{0} - {1} {2}", expectedProjectName, fixedSettings.MainWindowTitle, SettingsHelper.ApplicationVersion); Assert.AreEqual(expectedTitle, mainWindow.Title); @@ -634,10 +645,11 @@ plugin.Expect(p => p.Activate()); plugin.Expect(p => p.GetViewInfos()).Return(Enumerable.Empty()); plugin.Expect(p => p.GetPropertyInfos()).Return(Enumerable.Empty()); + var projectFactory = mocks.Stub(); mocks.ReplayAll(); // Setup - using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings())) + using (var gui = new GuiCore(new MainWindow(), projectStore, projectFactory, new GuiCoreSettings())) { gui.Plugins.Add(plugin); @@ -662,10 +674,11 @@ plugin.Stub(p => p.Activate()).Throw(new Exception("ERROR!")); plugin.Expect(p => p.Deactivate()); plugin.Expect(p => p.Dispose()); + var projectFactory = mocks.Stub(); mocks.ReplayAll(); // Setup - using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings())) + using (var gui = new GuiCore(new MainWindow(), projectStore, projectFactory, new GuiCoreSettings())) { gui.Plugins.Add(plugin); @@ -688,10 +701,11 @@ plugin.Stub(p => p.Activate()).Throw(new Exception("ERROR!")); plugin.Stub(p => p.Deactivate()).Throw(new Exception("MORE ERROR!")); plugin.Expect(p => p.Dispose()); + var projectFactory = mocks.Stub(); mocks.ReplayAll(); // Setup - using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings())) + using (var gui = new GuiCore(new MainWindow(), projectStore, projectFactory, new GuiCoreSettings())) { gui.Plugins.Add(plugin); @@ -712,9 +726,10 @@ // Setup var mocks = new MockRepository(); var projectStore = mocks.Stub(); + var projectFactory = mocks.Stub(); mocks.ReplayAll(); - using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings())) + using (var gui = new GuiCore(new MainWindow(), projectStore, projectFactory, new GuiCoreSettings())) { // Call gui.Run(); @@ -740,9 +755,10 @@ // Setup var mocks = new MockRepository(); var projectStore = mocks.Stub(); + var projectFactory = mocks.Stub(); mocks.ReplayAll(); - using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings())) + using (var gui = new GuiCore(new MainWindow(), projectStore, projectFactory, new GuiCoreSettings())) { var rootData = new object(); @@ -779,9 +795,10 @@ }); plugin2.Stub(p => p.Dispose()); plugin2.Stub(p => p.Deactivate()); + var projectFactory = mocks.Stub(); mocks.ReplayAll(); - using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings())) + using (var gui = new GuiCore(new MainWindow(), projectStore, projectFactory, new GuiCoreSettings())) { gui.Plugins.Add(plugin1); gui.Plugins.Add(plugin2); @@ -833,9 +850,10 @@ }); plugin2.Stub(p => p.Dispose()); plugin2.Stub(p => p.Deactivate()); + var projectFactory = mocks.Stub(); mocks.ReplayAll(); - using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings())) + using (var gui = new GuiCore(new MainWindow(), projectStore, projectFactory, new GuiCoreSettings())) { gui.Plugins.Add(plugin1); gui.Plugins.Add(plugin2); @@ -861,9 +879,10 @@ // Setup var mocks = new MockRepository(); var projectStore = mocks.Stub(); + var projectFactory = mocks.Stub(); mocks.ReplayAll(); - using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings())) + using (var gui = new GuiCore(new MainWindow(), projectStore, projectFactory, new GuiCoreSettings())) { // Call var result = gui.GetTreeNodeInfos(); @@ -909,9 +928,10 @@ pluginC.Stub(p => p.GetTreeNodeInfos()).Return(nodesPluginC); pluginC.Stub(p => p.Dispose()); pluginC.Stub(p => p.Deactivate()); + var projectFactory = mocks.Stub(); mocks.ReplayAll(); - using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings())) + using (var gui = new GuiCore(new MainWindow(), projectStore, projectFactory, new GuiCoreSettings())) { gui.Plugins.Add(pluginA); gui.Plugins.Add(pluginB); @@ -935,11 +955,12 @@ // Setup var mocks = new MockRepository(); var projectStore = mocks.Stub(); + var projectFactory = mocks.Stub(); mocks.ReplayAll(); using (var treeView = new TreeViewControl()) { - using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings())) + using (var gui = new GuiCore(new MainWindow(), projectStore, projectFactory, new GuiCoreSettings())) { // Call TestDelegate call = () => gui.Get(new object(), treeView); @@ -959,11 +980,12 @@ // Setup var mocks = new MockRepository(); var projectStore = mocks.Stub(); + var projectFactory = mocks.Stub(); mocks.ReplayAll(); using (var treeView = new TreeViewControl()) { - using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings())) + using (var gui = new GuiCore(new MainWindow(), projectStore, projectFactory, new GuiCoreSettings())) { gui.Run(); @@ -994,24 +1016,24 @@ // Setup var mocks = new MockRepository(); var storeProject = mocks.Stub(); + var projectFactory = mocks.Stub(); + var oldProjectMock = mocks.Stub(); + var newProjectMock = mocks.Stub(); mocks.ReplayAll(); - using (var gui = new GuiCore(new MainWindow(), storeProject, new GuiCoreSettings())) + using (var gui = new GuiCore(new MainWindow(), storeProject, projectFactory, new GuiCoreSettings())) { - var oldProject = new Project("A"); - var newProject = new Project("B"); + gui.Project = oldProjectMock; - gui.Project = oldProject; - int openedCallCount = 0; gui.ProjectOpened += project => { - Assert.AreSame(newProject, project); + Assert.AreSame(newProjectMock, project); openedCallCount++; }; // Call - gui.Project = newProject; + gui.Project = newProjectMock; // Assert Assert.AreEqual(1, openedCallCount); Index: Core/Common/test/Core.Common.Integration.Test/Ringtoets/Application.Ringtoets/GuiCoreIntegrationTest.cs =================================================================== diff -u -rb78b6d08e4be8dfe938718d5e65085aa8bd72dcc -r1eed3e3f652618c52a462edc502cfd4250772314 --- Core/Common/test/Core.Common.Integration.Test/Ringtoets/Application.Ringtoets/GuiCoreIntegrationTest.cs (.../GuiCoreIntegrationTest.cs) (revision b78b6d08e4be8dfe938718d5e65085aa8bd72dcc) +++ Core/Common/test/Core.Common.Integration.Test/Ringtoets/Application.Ringtoets/GuiCoreIntegrationTest.cs (.../GuiCoreIntegrationTest.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -21,6 +21,7 @@ using System.Windows.Controls; using System.Windows.Threading; +using Core.Common.Base.Data; using Core.Common.Base.Storage; using Core.Common.Gui; using Core.Common.Gui.Forms.MainWindow; @@ -54,9 +55,10 @@ { var mocks = new MockRepository(); var projectStore = mocks.Stub(); + var projectFactory = mocks.Stub(); mocks.ReplayAll(); - using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings())) + using (var gui = new GuiCore(new MainWindow(), projectStore, projectFactory, new GuiCoreSettings())) { gui.Plugins.Add(new RingtoetsPlugin()); gui.Run(); @@ -79,9 +81,10 @@ //could be tested separately but the combination is vital to many tests. That's why this test is here. var mocks = new MockRepository(); var projectStore = mocks.Stub(); + var projectFactory = mocks.Stub(); mocks.ReplayAll(); - using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings())) + using (var gui = new GuiCore(new MainWindow(), projectStore, projectFactory, new GuiCoreSettings())) { gui.Run(); int callCount = 0; @@ -95,9 +98,10 @@ { var mocks = new MockRepository(); var projectStore = mocks.Stub(); + var projectFactory = mocks.Stub(); mocks.ReplayAll(); - using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings())) + using (var gui = new GuiCore(new MainWindow(), projectStore, projectFactory, new GuiCoreSettings())) { gui.Plugins.Add(new RingtoetsPlugin()); gui.Plugins.Add(new ProjectExplorerPlugin()); Index: Core/Plugins/src/Core.Plugins.CommonTools/CommonToolsPlugin.cs =================================================================== diff -u -r90f09f42b0e182615dba7007fc5866d90a92b605 -r1eed3e3f652618c52a462edc502cfd4250772314 --- Core/Plugins/src/Core.Plugins.CommonTools/CommonToolsPlugin.cs (.../CommonToolsPlugin.cs) (revision 90f09f42b0e182615dba7007fc5866d90a92b605) +++ Core/Plugins/src/Core.Plugins.CommonTools/CommonToolsPlugin.cs (.../CommonToolsPlugin.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -35,7 +35,7 @@ { public override IEnumerable GetPropertyInfos() { - yield return new PropertyInfo(); + yield return new PropertyInfo(); } public override IEnumerable GetViewInfos() Index: Core/Plugins/src/Core.Plugins.CommonTools/Property/ProjectProperties.cs =================================================================== diff -u -r4512af7782ee31b36941bb280b54d9da2953dd71 -r1eed3e3f652618c52a462edc502cfd4250772314 --- Core/Plugins/src/Core.Plugins.CommonTools/Property/ProjectProperties.cs (.../ProjectProperties.cs) (revision 4512af7782ee31b36941bb280b54d9da2953dd71) +++ Core/Plugins/src/Core.Plugins.CommonTools/Property/ProjectProperties.cs (.../ProjectProperties.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -28,9 +28,9 @@ namespace Core.Plugins.CommonTools.Property { /// - /// This class describes the presentation of properties of a . + /// This class describes the presentation of properties of a . /// - public class ProjectProperties : ObjectProperties + public class ProjectProperties : ObjectProperties { [PropertyOrder(1)] [ResourcesCategory(typeof(Resources), "Categories_General")] Index: Core/Plugins/src/Core.Plugins.ProjectExplorer/Core.Plugins.ProjectExplorer.csproj =================================================================== diff -u -ra1ec5faebf7ccf8e67fa34a2b73cd1063ab48840 -r1eed3e3f652618c52a462edc502cfd4250772314 --- Core/Plugins/src/Core.Plugins.ProjectExplorer/Core.Plugins.ProjectExplorer.csproj (.../Core.Plugins.ProjectExplorer.csproj) (revision a1ec5faebf7ccf8e67fa34a2b73cd1063ab48840) +++ Core/Plugins/src/Core.Plugins.ProjectExplorer/Core.Plugins.ProjectExplorer.csproj (.../Core.Plugins.ProjectExplorer.csproj) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -148,8 +148,6 @@ - - ProjectExplorer.cs Index: Core/Plugins/src/Core.Plugins.ProjectExplorer/ProjectExplorerPlugin.cs =================================================================== diff -u -rb78b6d08e4be8dfe938718d5e65085aa8bd72dcc -r1eed3e3f652618c52a462edc502cfd4250772314 --- Core/Plugins/src/Core.Plugins.ProjectExplorer/ProjectExplorerPlugin.cs (.../ProjectExplorerPlugin.cs) (revision b78b6d08e4be8dfe938718d5e65085aa8bd72dcc) +++ Core/Plugins/src/Core.Plugins.ProjectExplorer/ProjectExplorerPlugin.cs (.../ProjectExplorerPlugin.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -21,12 +21,10 @@ using System; using System.Collections.Generic; -using System.Linq; using Core.Common.Base.Data; using Core.Common.Controls.TreeView; using Core.Common.Gui; using Core.Common.Gui.Commands; -using Core.Common.Gui.ContextMenu; using Core.Common.Gui.Forms; using Core.Common.Gui.Plugin; using Core.Common.Gui.Selection; @@ -84,48 +82,6 @@ } } - public override IEnumerable GetTreeNodeInfos() - { - yield return new TreeNodeInfo - { - Text = project => project.Name, - Image = project => ProjectExplorerResources.ProjectIcon, - ChildNodeObjects = project => project.Items.ToArray(), - ContextMenuStrip = (project, parentData, treeViewControl) => - { - var addItem = new StrictContextMenuItem( - ProjectExplorerResources.AddItem, - ProjectExplorerResources.AddItem_ToolTip, - ProjectExplorerResources.PlusIcon, - (s, e) => Gui.ProjectCommands.AddNewItem(project)); - - return Gui.Get(project, treeViewControl) - .AddCustomItem(addItem) - .AddSeparator() - .AddImportItem() - .AddExportItem() - .AddSeparator() - .AddExpandAllItem() - .AddCollapseAllItem() - .AddSeparator() - .AddPropertiesItem() - .Build(); - } - }; - } - - public override IEnumerable GetChildDataWithViewDefinitions(object dataObject) - { - var project = dataObject as Project; - if (project != null) - { - foreach (var item in project.Items) - { - yield return item; - } - } - } - /// /// Activates the /// @@ -180,7 +136,7 @@ } } - private void ApplicationProjectOpened(Project project) + private void ApplicationProjectOpened(IProject project) { UpdateProject(); } Index: Core/Plugins/src/Core.Plugins.ProjectExplorer/ProjectExplorerViewController.cs =================================================================== diff -u -rb78b6d08e4be8dfe938718d5e65085aa8bd72dcc -r1eed3e3f652618c52a462edc502cfd4250772314 --- Core/Plugins/src/Core.Plugins.ProjectExplorer/ProjectExplorerViewController.cs (.../ProjectExplorerViewController.cs) (revision b78b6d08e4be8dfe938718d5e65085aa8bd72dcc) +++ Core/Plugins/src/Core.Plugins.ProjectExplorer/ProjectExplorerViewController.cs (.../ProjectExplorerViewController.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -119,15 +119,23 @@ /// /// Updates the with a . /// - /// The to set. - public void Update(Project project) + /// The to set. + public void Update(IProject project) { if (IsProjectExplorerOpen) { projectExplorer.Data = project; } } + public void Dispose() + { + if (projectExplorer != null) + { + projectExplorer.Dispose(); + } + } + private void OpenProjectExplorer() { projectExplorer = new ProjectExplorer(applicationSelection, viewCommands, treeNodeInfos); @@ -145,13 +153,5 @@ { viewController.ViewHost.Remove(projectExplorer); } - - public void Dispose() - { - if (projectExplorer != null) - { - projectExplorer.Dispose(); - } - } } } \ No newline at end of file Index: Core/Plugins/src/Core.Plugins.ProjectExplorer/Properties/Resources.Designer.cs =================================================================== diff -u -ra1ec5faebf7ccf8e67fa34a2b73cd1063ab48840 -r1eed3e3f652618c52a462edc502cfd4250772314 --- Core/Plugins/src/Core.Plugins.ProjectExplorer/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision a1ec5faebf7ccf8e67fa34a2b73cd1063ab48840) +++ Core/Plugins/src/Core.Plugins.ProjectExplorer/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -61,24 +61,6 @@ } /// - /// Looks up a localized string similar to &Nieuw element.... - /// - public static string AddItem { - get { - return ResourceManager.GetString("AddItem", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Voeg een nieuw element toe aan het project.. - /// - public static string AddItem_ToolTip { - get { - return ResourceManager.GetString("AddItem_ToolTip", resourceCulture); - } - } - - /// /// Looks up a localized string similar to Projectverkenner. /// public static string General_ProjectExplorer { @@ -90,16 +72,6 @@ /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// - public static System.Drawing.Bitmap PlusIcon { - get { - object obj = ResourceManager.GetObject("PlusIcon", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// public static System.Drawing.Bitmap ProjectExplorerIcon { get { object obj = ResourceManager.GetObject("ProjectExplorerIcon", resourceCulture); @@ -126,16 +98,6 @@ } /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - public static System.Drawing.Bitmap ProjectIcon { - get { - object obj = ResourceManager.GetObject("ProjectIcon", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// /// Looks up a localized string similar to Weergeven/Verbergen. /// public static string Ribbon_GroupBox_ShowHide { Index: Core/Plugins/src/Core.Plugins.ProjectExplorer/Properties/Resources.resx =================================================================== diff -u -ra1ec5faebf7ccf8e67fa34a2b73cd1063ab48840 -r1eed3e3f652618c52a462edc502cfd4250772314 --- Core/Plugins/src/Core.Plugins.ProjectExplorer/Properties/Resources.resx (.../Resources.resx) (revision a1ec5faebf7ccf8e67fa34a2b73cd1063ab48840) +++ Core/Plugins/src/Core.Plugins.ProjectExplorer/Properties/Resources.resx (.../Resources.resx) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -118,18 +118,6 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - ..\Resources\project-16.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\plus.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - &Nieuw element... - - - Voeg een nieuw element toe aan het project. - ..\resources\folder_wrench.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a Index: Core/Plugins/src/Core.Plugins.ProjectExplorer/Resources/plus.png =================================================================== diff -u -ra950714ad9510756331d862aa35695fa0b2ed03b -r1eed3e3f652618c52a462edc502cfd4250772314 Binary files differ Index: Core/Plugins/src/Core.Plugins.ProjectExplorer/Resources/project-16.png =================================================================== diff -u -ra950714ad9510756331d862aa35695fa0b2ed03b -r1eed3e3f652618c52a462edc502cfd4250772314 Binary files differ Index: Core/Plugins/test/Core.Plugins.Chart.Test/ChartPluginTest.cs =================================================================== diff -u -r31d4921763c045040f9300542aed356147966cc8 -r1eed3e3f652618c52a462edc502cfd4250772314 --- Core/Plugins/test/Core.Plugins.Chart.Test/ChartPluginTest.cs (.../ChartPluginTest.cs) (revision 31d4921763c045040f9300542aed356147966cc8) +++ Core/Plugins/test/Core.Plugins.Chart.Test/ChartPluginTest.cs (.../ChartPluginTest.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -22,6 +22,7 @@ using System; using System.Windows; using System.Windows.Threading; +using Core.Common.Base.Data; using Core.Common.Base.Storage; using Core.Common.Controls.Views; using Core.Common.Gui; @@ -109,9 +110,10 @@ // Given var mocks = new MockRepository(); var projectStore = mocks.Stub(); + var projectFactory = mocks.Stub(); mocks.ReplayAll(); - using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings())) + using (var gui = new GuiCore(new MainWindow(), projectStore, projectFactory, new GuiCoreSettings())) { var plugin = new ChartPlugin(); var testChartView = new TestChartView(); Index: Core/Plugins/test/Core.Plugins.CommonTools.Test/CommonToolsPluginTest.cs =================================================================== diff -u -r90f09f42b0e182615dba7007fc5866d90a92b605 -r1eed3e3f652618c52a462edc502cfd4250772314 --- Core/Plugins/test/Core.Plugins.CommonTools.Test/CommonToolsPluginTest.cs (.../CommonToolsPluginTest.cs) (revision 90f09f42b0e182615dba7007fc5866d90a92b605) +++ Core/Plugins/test/Core.Plugins.CommonTools.Test/CommonToolsPluginTest.cs (.../CommonToolsPluginTest.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -44,7 +44,7 @@ // Assert Assert.AreEqual(1, propertyInfos.Count); - var projectPropertyInfo = propertyInfos.First(pi => pi.DataType == typeof(Project)); + var projectPropertyInfo = propertyInfos.First(pi => pi.DataType == typeof(IProject)); Assert.AreEqual(typeof(ProjectProperties), projectPropertyInfo.PropertyObjectType); } Index: Core/Plugins/test/Core.Plugins.Map.Test/MapPluginTest.cs =================================================================== diff -u -rc5717eada81586126cbf53266abb0fc925382393 -r1eed3e3f652618c52a462edc502cfd4250772314 --- Core/Plugins/test/Core.Plugins.Map.Test/MapPluginTest.cs (.../MapPluginTest.cs) (revision c5717eada81586126cbf53266abb0fc925382393) +++ Core/Plugins/test/Core.Plugins.Map.Test/MapPluginTest.cs (.../MapPluginTest.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -22,6 +22,7 @@ using System; using System.Windows; using System.Windows.Threading; +using Core.Common.Base.Data; using Core.Common.Base.Storage; using Core.Common.Controls.Views; using Core.Common.Gui; @@ -113,9 +114,10 @@ // Given var mocks = new MockRepository(); var projectStore = mocks.Stub(); + var projectFactory = mocks.Stub(); mocks.ReplayAll(); - using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings())) + using (var gui = new GuiCore(new MainWindow(), projectStore, projectFactory, new GuiCoreSettings())) { var plugin = new MapPlugin(); var testMapView = new TestMapView(); Index: Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/Core.Plugins.ProjectExplorer.Test.csproj =================================================================== diff -u -ra1ec5faebf7ccf8e67fa34a2b73cd1063ab48840 -r1eed3e3f652618c52a462edc502cfd4250772314 --- Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/Core.Plugins.ProjectExplorer.Test.csproj (.../Core.Plugins.ProjectExplorer.Test.csproj) (revision a1ec5faebf7ccf8e67fa34a2b73cd1063ab48840) +++ Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/Core.Plugins.ProjectExplorer.Test.csproj (.../Core.Plugins.ProjectExplorer.Test.csproj) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -100,7 +100,6 @@ - Index: Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/ProjectExplorerPluginTest.cs =================================================================== diff -u -ra1ec5faebf7ccf8e67fa34a2b73cd1063ab48840 -r1eed3e3f652618c52a462edc502cfd4250772314 --- Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/ProjectExplorerPluginTest.cs (.../ProjectExplorerPluginTest.cs) (revision a1ec5faebf7ccf8e67fa34a2b73cd1063ab48840) +++ Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/ProjectExplorerPluginTest.cs (.../ProjectExplorerPluginTest.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -76,7 +76,6 @@ var guiStub = mocks.Stub(); var viewHost = mocks.Stub(); guiStub.Stub(g => g.ApplicationCommands).Return(mocks.Stub()); - guiStub.Stub(g => g.ProjectCommands).Return(mocks.Stub()); guiStub.Stub(g => g.ViewCommands).Return(mocks.Stub()); guiStub.Stub(g => g.GetTreeNodeInfos()).Return(Enumerable.Empty()); viewHost.Stub(vm => vm.ToolViews).Return(new IView[0]); @@ -111,7 +110,6 @@ var guiStub = mocks.Stub(); var viewHost = mocks.Stub(); guiStub.Stub(g => g.ApplicationCommands).Return(mocks.Stub()); - guiStub.Stub(g => g.ProjectCommands).Return(mocks.Stub()); guiStub.Stub(g => g.ViewCommands).Return(mocks.Stub()); guiStub.Stub(g => g.GetTreeNodeInfos()).Return(Enumerable.Empty()); viewHost.Stub(vm => vm.ToolViews).Return(new IView[0]); @@ -151,7 +149,6 @@ var guiStub = mocks.Stub(); var viewHost = mocks.Stub(); guiStub.Stub(g => g.ApplicationCommands).Return(mocks.Stub()); - guiStub.Stub(g => g.ProjectCommands).Return(mocks.Stub()); guiStub.Stub(g => g.ViewCommands).Return(mocks.Stub()); guiStub.Stub(g => g.GetTreeNodeInfos()).Return(Enumerable.Empty()); viewHost.Stub(vm => vm.ToolViews).Return(new IView[0]); @@ -210,57 +207,6 @@ } [Test] - [RequiresSTA] - public void GetTreeNodeInfos_ReturnsSupportedTreeNodeInfos() - { - // Setup - var mocks = new MockRepository(); - - var guiStub = mocks.Stub(); - guiStub.Stub(g => g.ApplicationCommands).Return(mocks.Stub()); - guiStub.Stub(g => g.ProjectCommands).Return(mocks.Stub()); - guiStub.Stub(g => g.ViewCommands).Return(mocks.Stub()); - guiStub.Stub(g => g.GetTreeNodeInfos()).Return(Enumerable.Empty()); - - mocks.ReplayAll(); - - using (var plugin = new ProjectExplorerPlugin - { - Gui = guiStub - }) - { - // Call - TreeNodeInfo[] treeNodeInfos = plugin.GetTreeNodeInfos().ToArray(); - - // Assert - Assert.AreEqual(1, treeNodeInfos.Length); - Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(Project))); - } - - mocks.VerifyAll(); - } - - [Test] - public void GetChildDataWithViewDefinitions_DataIsProjectWithChildren_ReturnChildren() - { - // Setup - var project = new Project(); - project.Items.Add(1); - project.Items.Add(2); - project.Items.Add(3); - - using (var plugin = new ProjectExplorerPlugin()) - { - // Call - var childrenWithViewDefinitions = plugin.GetChildDataWithViewDefinitions(project); - - // Assert - var expectedResult = project.Items; - CollectionAssert.AreEquivalent(expectedResult, childrenWithViewDefinitions); - } - } - - [Test] public void GetChildDataWithViewDefinitions_UnsupportedDataType_ReturnEmpty() { // Setup @@ -283,13 +229,12 @@ var guiStub = mocks.Stub(); var viewHost = mocks.StrictMock(); guiStub.Stub(g => g.ApplicationCommands).Return(mocks.Stub()); - guiStub.Stub(g => g.ProjectCommands).Return(mocks.Stub()); guiStub.Stub(g => g.ViewCommands).Return(mocks.Stub()); guiStub.Stub(g => g.GetTreeNodeInfos()).Return(new[] { new TreeNodeInfo { - TagType = typeof(Project) + TagType = typeof(IProject) } }); guiStub.Stub(g => g.ViewHost).Return(viewHost); Index: Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/ProjectExplorerTest.cs =================================================================== diff -u -rb78b6d08e4be8dfe938718d5e65085aa8bd72dcc -r1eed3e3f652618c52a462edc502cfd4250772314 --- Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/ProjectExplorerTest.cs (.../ProjectExplorerTest.cs) (revision b78b6d08e4be8dfe938718d5e65085aa8bd72dcc) +++ Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/ProjectExplorerTest.cs (.../ProjectExplorerTest.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -94,7 +94,7 @@ IViewCommands viewCommands = mocks.StrictMock(); IEnumerable treeNodeInfos = Enumerable.Empty(); - + mocks.ReplayAll(); var explorer = new ProjectExplorer(applicationSelection, viewCommands, treeNodeInfos); @@ -116,7 +116,7 @@ { new TreeNodeInfo { - TagType = typeof(Project) + TagType = typeof(IProject) } }; @@ -146,7 +146,7 @@ { new TreeNodeInfo { - TagType = typeof(Project), + TagType = typeof(IProject), CanRemove = (item, parent) => true } }; @@ -192,7 +192,7 @@ { new TreeNodeInfo { - TagType = typeof(Project), + TagType = typeof(IProject), ChildNodeObjects = o => new[] { stringA, @@ -251,7 +251,7 @@ { new TreeNodeInfo { - TagType = typeof(Project) + TagType = typeof(IProject) } }; Index: Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/ProjectExplorerViewControllerTest.cs =================================================================== diff -u -r669853e6468fcf1301a64f5df1400456fe6929eb -r1eed3e3f652618c52a462edc502cfd4250772314 --- Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/ProjectExplorerViewControllerTest.cs (.../ProjectExplorerViewControllerTest.cs) (revision 669853e6468fcf1301a64f5df1400456fe6929eb) +++ Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/ProjectExplorerViewControllerTest.cs (.../ProjectExplorerViewControllerTest.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -197,7 +197,7 @@ { new TreeNodeInfo { - TagType = typeof(Project) + TagType = typeof(IProject) } }; Fisheye: Tag 1eed3e3f652618c52a462edc502cfd4250772314 refers to a dead (removed) revision in file `Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/TreeNodeInfos/ProjectTreeNodeInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Demo/Ringtoets/src/Demo.Ringtoets/Commands/AddNewDemoAssessmentSectionCommand.cs =================================================================== diff -u -r01af2589fd96232cd78a1ba09dc4fc9681e4b9ff -r1eed3e3f652618c52a462edc502cfd4250772314 --- Demo/Ringtoets/src/Demo.Ringtoets/Commands/AddNewDemoAssessmentSectionCommand.cs (.../AddNewDemoAssessmentSectionCommand.cs) (revision 01af2589fd96232cd78a1ba09dc4fc9681e4b9ff) +++ Demo/Ringtoets/src/Demo.Ringtoets/Commands/AddNewDemoAssessmentSectionCommand.cs (.../AddNewDemoAssessmentSectionCommand.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -52,7 +52,7 @@ public void Execute(params object[] arguments) { - var project = projectOwner.Project; + var project = (RingtoetsProject) projectOwner.Project; project.Items.Add(CreateNewDemoAssessmentSection()); project.NotifyObservers(); } Index: Demo/Ringtoets/test/Demo.Ringtoets.Test/Commands/AddNewDemoAssessmentSectionCommandTest.cs =================================================================== diff -u -r80c86231452b9beb7e8b8eba3698ceb9c0551de3 -r1eed3e3f652618c52a462edc502cfd4250772314 --- Demo/Ringtoets/test/Demo.Ringtoets.Test/Commands/AddNewDemoAssessmentSectionCommandTest.cs (.../AddNewDemoAssessmentSectionCommandTest.cs) (revision 80c86231452b9beb7e8b8eba3698ceb9c0551de3) +++ Demo/Ringtoets/test/Demo.Ringtoets.Test/Commands/AddNewDemoAssessmentSectionCommandTest.cs (.../AddNewDemoAssessmentSectionCommandTest.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -47,7 +47,7 @@ public void Execute_GuiIsProperlyInitialized_AddNewAssessmentSectionWithDemoDataToRootProject() { // Setup - var project = new Project(); + var project = new RingtoetsProject(); var mocks = new MockRepository(); var projectOwnerStub = mocks.Stub(); @@ -67,7 +67,7 @@ // Assert Assert.AreEqual(1, project.Items.Count); - var demoAssessmentSection = (AssessmentSection) project.Items[0]; + var demoAssessmentSection = project.Items[0]; Assert.AreEqual("Demo traject", demoAssessmentSection.Name); Assert.IsNotEmpty(demoAssessmentSection.HydraulicBoundaryDatabase.FilePath); Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.Designer.cs =================================================================== diff -u -r74b9f5cca517fbccca3fe27bac059966233e432a -r1eed3e3f652618c52a462edc502cfd4250772314 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 74b9f5cca517fbccca3fe27bac059966233e432a) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -938,6 +938,24 @@ } /// + /// Looks up a localized string similar to &Nieuw traject.... + /// + public static string RingtoetsProject_DisplayName { + get { + return ResourceManager.GetString("RingtoetsProject_DisplayName", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Voeg een nieuw traject toe aan het project.. + /// + public static string RingtoetsProject_ToolTip { + get { + return ResourceManager.GetString("RingtoetsProject_ToolTip", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Scenario's. /// public static string Scenarios_DisplayName { Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.resx =================================================================== diff -u -r74b9f5cca517fbccca3fe27bac059966233e432a -r1eed3e3f652618c52a462edc502cfd4250772314 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.resx (.../Resources.resx) (revision 74b9f5cca517fbccca3fe27bac059966233e432a) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.resx (.../Resources.resx) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -433,4 +433,10 @@ ..\Resources\application_form.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + &Nieuw traject... + + + Voeg een nieuw traject toe aan het project. + \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/Ringtoets.Integration.Data.csproj =================================================================== diff -u -rbe9428984d28fcbd8f6089f1c1184cd9763c18bf -r1eed3e3f652618c52a462edc502cfd4250772314 --- Ringtoets/Integration/src/Ringtoets.Integration.Data/Ringtoets.Integration.Data.csproj (.../Ringtoets.Integration.Data.csproj) (revision be9428984d28fcbd8f6089f1c1184cd9763c18bf) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/Ringtoets.Integration.Data.csproj (.../Ringtoets.Integration.Data.csproj) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -41,6 +41,8 @@ Properties\GlobalAssembly.cs + + Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/RingtoetsProject.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.Data/RingtoetsProject.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/RingtoetsProject.cs (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -0,0 +1,104 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU 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 General Public License for more details. +// +// You should have received a copy of the GNU 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.Collections.Generic; +using System.Linq; +using Core.Common.Base; +using Core.Common.Base.Data; +using Core.Common.Base.Properties; + +namespace Ringtoets.Integration.Data +{ + public class RingtoetsProject : Observable, IProject + { + /// + /// Constructs a new . + /// + public RingtoetsProject() : this(Resources.Project_Constructor_Default_name) {} + + /// + /// Constructs a new . + /// + /// The name of the . + public RingtoetsProject(string name) + { + Name = name; + Description = ""; + + Items = new List(); + } + + /// + /// Gets or sets the items of the . + /// + public IList Items { get; private set; } + + /// + /// Gets or sets the name of the . + /// + public string Name { get; set; } + + /// + /// Gets or sets the description of the . + /// + public string Description { get; set; } + + /// + /// Gets or sets the unique identifier for the storage of the . + /// + public long StorageId { get; set; } + + public bool Equals(IProject other) + { + var otherProject = other as RingtoetsProject; + if (otherProject == null) + { + return false; + } + return string.Equals(Name, otherProject.Name) && + string.Equals(Description, otherProject.Description) && + StorageId == otherProject.StorageId && + Items.SequenceEqual(otherProject.Items); + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + if (ReferenceEquals(this, obj)) + { + return true; + } + if (obj.GetType() != GetType()) + { + return false; + } + return Equals((RingtoetsProject) obj); + } + + public override int GetHashCode() + { + return StorageId.GetHashCode() ^ Name.GetHashCode() ^ Description.GetHashCode(); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/RingtoetsProjectFactory.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.Data/RingtoetsProjectFactory.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/RingtoetsProjectFactory.cs (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -0,0 +1,33 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU 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 General Public License for more details. +// +// You should have received a copy of the GNU 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.Common.Base.Data; + +namespace Ringtoets.Integration.Data +{ + public class RingtoetsProjectFactory : IProjectFactory + { + public IProject CreateNewProject() + { + return new RingtoetsProject(); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs =================================================================== diff -u -rd510069b9f0375adf108e8c9ffdb7668e7bb11f4 -r1eed3e3f652618c52a462edc502cfd4250772314 --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision d510069b9f0375adf108e8c9ffdb7668e7bb11f4) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -55,6 +55,7 @@ using Ringtoets.HeightStructures.Forms.PresentationObjects; using Ringtoets.HydraRing.Data; using Ringtoets.HydraRing.IO; +using Ringtoets.Integration.Data; using Ringtoets.Integration.Data.StandAlone; using Ringtoets.Integration.Data.StandAlone.SectionResults; using Ringtoets.Integration.Forms; @@ -74,6 +75,7 @@ using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; using UtilsResources = Core.Common.Utils.Properties.Resources; using BaseResources = Core.Common.Base.Properties.Resources; +using GuiResources = Core.Common.Gui.Properties.Resources; namespace Ringtoets.Integration.Plugin { @@ -222,6 +224,50 @@ } } + public IAssessmentSection GetAssessmentSectionFromFile() + { + if (Gui == null) + { + return null; + } + + IAssessmentSection assessmentSection = null; + try + { + var assessmentSectionHandler = new AssessmentSectionFromFileCommandHandler(Gui.MainWindow); + var path = RingtoetsSettingsHelper.GetCommonDocumentsRingtoetsShapeFileDirectory(); + assessmentSection = assessmentSectionHandler.CreateAssessmentSectionFromFile(path); + } + catch (CriticalFileValidationException exception) + { + MessageBox.Show(exception.Message, BaseResources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error); + log.Warn(exception.Message, exception.InnerException); + } + catch (CriticalFileReadException exception) + { + log.Error(exception.Message, exception.InnerException); + } + + return assessmentSection; + } + + public void SetAssessmentSectionToProject(RingtoetsProject ringtoetsProject, AssessmentSection assessmentSection) + { + if (assessmentSection == null) + { + return; + } + assessmentSection.Name = GetUniqueForAssessmentSectionName(ringtoetsProject.Items, assessmentSection.Name); + ringtoetsProject.Items.Add(assessmentSection); + ringtoetsProject.NotifyObservers(); + + if (Gui != null && (Gui.Selection == null || Gui.Selection.Equals(assessmentSection))) + { + Gui.Selection = assessmentSection; + Gui.DocumentViewController.OpenViewForData(Gui.Selection); + } + } + /// /// Returns all instances provided for data of . /// @@ -322,31 +368,10 @@ public override IEnumerable GetDataItemInfos() { - if (Gui == null) - { - return Enumerable.Empty(); - } + IAssessmentSection assessmentSection = GetAssessmentSectionFromFile(); - IAssessmentSection assessmentSection = null; - try - { - var assessmentSectionHandler = new AssessmentSectionFromFileCommandHandler(Gui.MainWindow); - var path = RingtoetsSettingsHelper.GetCommonDocumentsRingtoetsShapeFileDirectory(); - assessmentSection = assessmentSectionHandler.CreateAssessmentSectionFromFile(path); - } - catch (CriticalFileValidationException exception) - { - MessageBox.Show(exception.Message, BaseResources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error); - log.Warn(exception.Message, exception.InnerException); - } - catch (CriticalFileReadException exception) - { - log.Error(exception.Message, exception.InnerException); - } - if (assessmentSection == null) { - return Enumerable.Empty(); } return new DataItemInfo[] @@ -358,8 +383,8 @@ Image = RingtoetsFormsResources.AssessmentSectionFolderIcon, CreateData = owner => { - var project = (Project) owner; - assessmentSection.Name = GetUniqueForAssessmentSectionName(project, assessmentSection.Name); + var project = (RingtoetsProject) owner; + assessmentSection.Name = GetUniqueForAssessmentSectionName(project.Items, assessmentSection.Name); return assessmentSection; } } @@ -373,6 +398,15 @@ /// Sequence of child data. public override IEnumerable GetChildDataWithViewDefinitions(object dataObject) { + var project = dataObject as RingtoetsProject; + if (project != null) + { + foreach (var item in project.Items) + { + yield return item; + } + } + var assessmentSection = dataObject as IAssessmentSection; if (assessmentSection != null) { @@ -490,10 +524,42 @@ .AddPropertiesItem() .Build() }; + + yield return new TreeNodeInfo + { + Text = project => project.Name, + Image = project => GuiResources.ProjectIcon, + ChildNodeObjects = nodeData => nodeData.Items.Cast().ToArray(), + ContextMenuStrip = (nodeData, parentData, treeViewControl) => + { + var addItem = new StrictContextMenuItem( + RingtoetsCommonFormsResources.RingtoetsProject_DisplayName, + RingtoetsCommonFormsResources.RingtoetsProject_ToolTip, + GuiResources.PlusIcon, + (s, e) => SetAssessmentSectionFromFileToProject(nodeData)); + + return Gui.Get(nodeData, treeViewControl) + .AddCustomItem(addItem) + .AddSeparator() + .AddImportItem() + .AddExportItem() + .AddSeparator() + .AddExpandAllItem() + .AddCollapseAllItem() + .AddSeparator() + .AddPropertiesItem() + .Build(); + } + }; } - private static ViewInfo, IEnumerable, TView> - CreateFailureMechanismResultViewInfo() + private void SetAssessmentSectionFromFileToProject(RingtoetsProject ringtoetsProject) + { + var assessmentSection = GetAssessmentSectionFromFile(); + SetAssessmentSectionToProject(ringtoetsProject, (AssessmentSection) assessmentSection); + } + + private static ViewInfo, IEnumerable, TView> CreateFailureMechanismResultViewInfo() where TResult : FailureMechanismSectionResult where TView : FailureMechanismResultView { @@ -510,7 +576,8 @@ }; } - private TreeNodeInfo> CreateFailureMechanismSectionResultTreeNodeInfo() where T : FailureMechanismSectionResult + private TreeNodeInfo> CreateFailureMechanismSectionResultTreeNodeInfo() + where T : FailureMechanismSectionResult { return new TreeNodeInfo> { @@ -538,11 +605,16 @@ } } - private static void VerifyHydraulicBoundaryDatabasePath(Project project) + private static void VerifyHydraulicBoundaryDatabasePath(IProject project) { - var sectionsWithDatabase = project.Items.OfType().Where(i => i.HydraulicBoundaryDatabase != null); - foreach (IAssessmentSection section in sectionsWithDatabase) + var ringtoetsProject = project as RingtoetsProject; + if (ringtoetsProject == null) { + return; + } + var sectionsWithDatabase = ringtoetsProject.Items.Where(i => i.HydraulicBoundaryDatabase != null); + foreach (AssessmentSection section in sectionsWithDatabase) + { string selectedFile = section.HydraulicBoundaryDatabase.FilePath; var validationProblem = HydraulicDatabaseHelper.ValidatePathForCalculation(selectedFile); if (validationProblem != null) @@ -695,9 +767,9 @@ #region AssessmentSection - private static string GetUniqueForAssessmentSectionName(Project project, string baseName) + private static string GetUniqueForAssessmentSectionName(IEnumerable assessmentSections, string baseName) { - return NamingHelper.GetUniqueName(project.Items.OfType(), baseName, a => a.Name); + return NamingHelper.GetUniqueName(assessmentSections, baseName, a => a.Name); } private object[] AssessmentSectionChildNodeObjects(IAssessmentSection nodeData) @@ -734,9 +806,9 @@ private void AssessmentSectionOnNodeRemoved(IAssessmentSection nodeData, object parentNodeData) { - var parentProject = (Project) parentNodeData; - - parentProject.Items.Remove(nodeData); + var parentProject = (RingtoetsProject) parentNodeData; + var assessmentSection = (AssessmentSection) nodeData; + parentProject.Items.Remove(assessmentSection); parentProject.NotifyObservers(); } Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/Ringtoets.Integration.Data.Test.csproj =================================================================== diff -u -rce94b8228bc7e51779b3754217580f13cb35e475 -r1eed3e3f652618c52a462edc502cfd4250772314 --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/Ringtoets.Integration.Data.Test.csproj (.../Ringtoets.Integration.Data.Test.csproj) (revision ce94b8228bc7e51779b3754217580f13cb35e475) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/Ringtoets.Integration.Data.Test.csproj (.../Ringtoets.Integration.Data.Test.csproj) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -44,11 +44,16 @@ ..\..\..\..\packages\NUnit.2.6.4\lib\nunit.framework.dll True + + ..\..\..\..\packages\RhinoMocks.3.6.1\lib\net\Rhino.Mocks.dll + + + Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/RingtoetsProjectFactoryTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/RingtoetsProjectFactoryTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/RingtoetsProjectFactoryTest.cs (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -0,0 +1,43 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU 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 General Public License for more details. +// +// You should have received a copy of the GNU 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.Common.Base.Data; +using NUnit.Framework; + +namespace Ringtoets.Integration.Data.Test +{ + [TestFixture] + public class RingtoetsProjectFactoryTest + { + [Test] + public void CreateNewProject_ReturnsNewRingtoetsProject() + { + // Setup + RingtoetsProjectFactory projectFactory = new RingtoetsProjectFactory(); + + // Call + IProject result = projectFactory.CreateNewProject(); + + // Assert + Assert.IsInstanceOf(result); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/RingtoetsProjectTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/RingtoetsProjectTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/RingtoetsProjectTest.cs (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -0,0 +1,229 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU 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 General Public License for more details. +// +// You should have received a copy of the GNU 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.Common.Base; +using Core.Common.Base.Data; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; + +namespace Ringtoets.Integration.Data.Test +{ + [TestFixture] + public class RingtoetsProjectTest + { + [Test] + public void DefaultConstructor_ExpectedValue() + { + // Call + var project = new RingtoetsProject(); + + // Assert + Assert.IsInstanceOf(project); + Assert.AreEqual("Project", project.Name); + Assert.AreEqual("", project.Description); + CollectionAssert.IsEmpty(project.Items); + } + + [Test] + public void NameConstructor_SetNameAndInitializeOtherProperties() + { + // Setup + const string someName = ""; + + // Call + var project = new RingtoetsProject(someName); + + // Assert + Assert.IsInstanceOf(project); + Assert.AreEqual(someName, project.Name); + Assert.AreEqual("", project.Description); + CollectionAssert.IsEmpty(project.Items); + } + + [Test] + public void AutomaticProperties_SetAndGettingValue_ShouldReturnSetValue() + { + // Setup + const string niceProjectName = "Nice project name"; + const string nicerDescription = "Nicer description"; + + // Call + var project = new RingtoetsProject + { + Name = niceProjectName, + Description = nicerDescription, + }; + + // Assert + Assert.AreEqual(niceProjectName, project.Name); + Assert.AreEqual(nicerDescription, project.Description); + } + + [Test] + public void Equals_NewProject_ReturnsTrue() + { + // Setup + RingtoetsProject newProjectA = new RingtoetsProject(); + RingtoetsProject newProjectB = new RingtoetsProject(); + + // Call + bool result = newProjectA.Equals(newProjectB); + bool result2 = newProjectB.Equals(newProjectA); + + // Assert + Assert.IsTrue(result); + Assert.IsTrue(result2); + } + + [Test] + public void Equals_ProjectNameChanged_ReturnsFalse() + { + // Setup + RingtoetsProject newProject = new RingtoetsProject(); + RingtoetsProject changedProject = new RingtoetsProject + { + Name = "" + }; + + // Call + bool result = newProject.Equals(changedProject); + bool result2 = changedProject.Equals(newProject); + + // Assert + Assert.IsFalse(result); + Assert.IsFalse(result2); + } + + [Test] + public void Equals_ProjectDescriptionChanged_ReturnsFalse() + { + // Setup + RingtoetsProject newProject = new RingtoetsProject(); + RingtoetsProject changedProject = new RingtoetsProject + { + Description = "" + }; + + // Call + bool result = newProject.Equals(changedProject); + bool result2 = changedProject.Equals(newProject); + + // Assert + Assert.IsFalse(result); + Assert.IsFalse(result2); + } + + [Test] + public void Equals_ProjectStorageIdChanged_ReturnsFalse() + { + // Setup + RingtoetsProject newProject = new RingtoetsProject(); + RingtoetsProject changedProject = new RingtoetsProject + { + StorageId = 1L + }; + + // Call + bool result = newProject.Equals(changedProject); + bool result2 = changedProject.Equals(newProject); + + // Assert + Assert.IsFalse(result); + Assert.IsFalse(result2); + } + + [Test] + public void Equals_ProjectItemsChanged_ReturnsFalse() + { + // Setup + RingtoetsProject newProject = new RingtoetsProject(); + RingtoetsProject changedProject = new RingtoetsProject(); + newProject.Items.Add(new AssessmentSection(AssessmentSectionComposition.Dike)); + + // Call + bool result = newProject.Equals(changedProject); + bool result2 = changedProject.Equals(newProject); + + // Assert + Assert.IsFalse(result); + Assert.IsFalse(result2); + } + + [Test] + public void GetHashCode_ProjectsAreEqual_ReturnsEqualHashes() + { + // Setup + const long storageId = 1234; + const string name = "Some name"; + const string desctiption = "Some desctiption"; + var project = new RingtoetsProject(name) { StorageId = storageId, Description = desctiption }; + var otherProject = new RingtoetsProject(name) { StorageId = storageId, Description = desctiption }; + + // Call + var result = project.GetHashCode(); + var otherResult = otherProject.GetHashCode(); + + // Assert + Assert.AreEqual(result, otherResult); + } + + [Test] + public void NotifyObservers_WithObserverAttached_ObserverIsNotified() + { + // Setup + var mockRepository = new MockRepository(); + var observerMock = mockRepository.StrictMock(); + observerMock.Expect(o => o.UpdateObserver()); + mockRepository.ReplayAll(); + + var project = new RingtoetsProject(); + project.Attach(observerMock); + + // Call + project.NotifyObservers(); + + // Assert + mockRepository.VerifyAll(); + } + + [Test] + public void NotifyObservers_AttachedObserverHasBeenDetached_ObserverShouldNoLongerBeNotified() + { + // Setup + var mockRepository = new MockRepository(); + var observerMock = mockRepository.StrictMock(); + observerMock.Expect(o => o.UpdateObserver()); + mockRepository.ReplayAll(); + + var project = new RingtoetsProject(); + project.Attach(observerMock); + project.NotifyObservers(); + + // Call + project.Detach(observerMock); + project.NotifyObservers(); + + // Assert + mockRepository.VerifyAll(); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/AssessmentSectionTreeNodeInfoTest.cs =================================================================== diff -u -ra1ec5faebf7ccf8e67fa34a2b73cd1063ab48840 -r1eed3e3f652618c52a462edc502cfd4250772314 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/AssessmentSectionTreeNodeInfoTest.cs (.../AssessmentSectionTreeNodeInfoTest.cs) (revision a1ec5faebf7ccf8e67fa34a2b73cd1063ab48840) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/AssessmentSectionTreeNodeInfoTest.cs (.../AssessmentSectionTreeNodeInfoTest.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -21,7 +21,6 @@ using System.Linq; using Core.Common.Base; -using Core.Common.Base.Data; using Core.Common.Controls.TreeView; using Core.Common.Gui; using Core.Common.Gui.ContextMenu; @@ -37,6 +36,7 @@ using Ringtoets.GrassCoverErosionInwards.Forms.PresentationObjects; using Ringtoets.HeightStructures.Data; using Ringtoets.HeightStructures.Forms.PresentationObjects; +using Ringtoets.Integration.Data; using Ringtoets.Integration.Data.StandAlone; using Ringtoets.Integration.Forms.PresentationObjects; using Ringtoets.Integration.Plugin; @@ -367,13 +367,13 @@ { // Setup var observerMock = mocks.StrictMock(); - var assessmentSection = mocks.Stub(); + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); observerMock.Expect(o => o.UpdateObserver()); mocks.ReplayAll(); - var project = new Project(); + var project = new RingtoetsProject(); project.Items.Add(assessmentSection); project.Attach(observerMock); Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs =================================================================== diff -u -rb954fb6f2dd56ffb96be7b61ab129f19d879d2ab -r1eed3e3f652618c52a462edc502cfd4250772314 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs (.../RingtoetsPluginTest.cs) (revision b954fb6f2dd56ffb96be7b61ab129f19d879d2ab) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs (.../RingtoetsPluginTest.cs) (revision 1eed3e3f652618c52a462edc502cfd4250772314) @@ -83,15 +83,15 @@ var projectStore = mocks.Stub(); mocks.ReplayAll(); - using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings())) + using (var gui = new GuiCore(new MainWindow(), projectStore, new RingtoetsProjectFactory(), new GuiCoreSettings())) { using (var plugin = new RingtoetsPlugin()) { plugin.Gui = gui; gui.Run(); // When - Action action = () => gui.Project = new Project(); + Action action = () => gui.Project = new RingtoetsProject(); // Then TestHelper.AssertLogMessagesCount(action, 0); @@ -113,15 +113,15 @@ var testDataDir = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.HydraRing.IO, "HydraulicBoundaryLocationReader"); var testDataPath = Path.Combine(testDataDir, "complete.sqlite"); - using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings())) + using (var gui = new GuiCore(new MainWindow(), projectStore, new RingtoetsProjectFactory(), new GuiCoreSettings())) { using (var plugin = new RingtoetsPlugin()) { plugin.Gui = gui; gui.Run(); - var project = new Project(); - IAssessmentSection section = new AssessmentSection(AssessmentSectionComposition.Dike) + var project = new RingtoetsProject(); + var section = new AssessmentSection(AssessmentSectionComposition.Dike) { HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase { @@ -150,14 +150,14 @@ var projectStore = mocks.Stub(); mocks.ReplayAll(); - using (var gui = new GuiCore(new MainWindow(), projectStore, new GuiCoreSettings())) + using (var gui = new GuiCore(new MainWindow(), projectStore, new RingtoetsProjectFactory(), new GuiCoreSettings())) { using (var plugin = new RingtoetsPlugin()) { - var project = new Project(); + var project = new RingtoetsProject(); var notExistingFile = "not_existing_file"; - IAssessmentSection section = new AssessmentSection(AssessmentSectionComposition.Dike) + var section = new AssessmentSection(AssessmentSectionComposition.Dike) { HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase { @@ -352,7 +352,7 @@ TreeNodeInfo[] treeNodeInfos = plugin.GetTreeNodeInfos().ToArray(); // Assert - Assert.AreEqual(24, treeNodeInfos.Length); + Assert.AreEqual(25, treeNodeInfos.Length); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(IAssessmentSection))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(ReferenceLineContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismContext))); @@ -377,6 +377,7 @@ Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismSectionResultContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(CommentContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(ProbabilityAssessmentOutput))); + Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(RingtoetsProject))); } mocks.VerifyAll(); } @@ -403,6 +404,26 @@ } [Test] + public void GetChildDataWithViewDefinitions_RingtoetsProjectWithChildren_ReturnChildren() + { + // Setup + var project = new RingtoetsProject(); + project.Items.Add(new AssessmentSection(AssessmentSectionComposition.Dike)); + project.Items.Add(new AssessmentSection(AssessmentSectionComposition.Dike)); + project.Items.Add(new AssessmentSection(AssessmentSectionComposition.Dike)); + + using (var plugin = new RingtoetsPlugin()) + { + // Call + var childrenWithViewDefinitions = plugin.GetChildDataWithViewDefinitions(project); + + // Assert + var expectedResult = project.Items; + CollectionAssert.AreEquivalent(expectedResult, childrenWithViewDefinitions); + } + } + + [Test] public void GetChildDataWithViewDefinitions_UnsupportedData_ReturnEmpty() { // Setup @@ -430,13 +451,21 @@ Assert.AreEqual(1, importers.Count(i => i is FailureMechanismSectionsImporter)); } - private static void AddAssessmentSectionToProject(Project project, RingtoetsPlugin plugin) + [Test] + public void WhenAddingAssessmentSection_GivenProjectHasAssessmentSection_ThenAddedAssessmentSectionHasUniqueName() { - var itemToAdd = plugin.GetDataItemInfos() - .First(di => di.ValueType == typeof(AssessmentSection)) - .CreateData(project); + // Setup + var project = new RingtoetsProject(); + var plugin = new RingtoetsPlugin(); + var assessmentSection1 = new AssessmentSection(AssessmentSectionComposition.Dike); + var assessmentSection2 = new AssessmentSection(AssessmentSectionComposition.Dike); + plugin.SetAssessmentSectionToProject(project, assessmentSection1); - project.Items.Add(itemToAdd); + // Call + plugin.SetAssessmentSectionToProject(project, assessmentSection2); + + // Assert + CollectionAssert.AllItemsAreUnique(project.Items.Select(section => section.Name)); } } } \ No newline at end of file