Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj =================================================================== diff -u -ra65bc56647a666fad39e7fe48fbce3a5c040dfee -rd180f991b1e2664695dc4e98118e3159256fe3cd --- Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision a65bc56647a666fad39e7fe48fbce3a5c040dfee) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision d180f991b1e2664695dc4e98118e3159256fe3cd) @@ -59,11 +59,9 @@ RingtoetsEntities.tt - RingtoetsEntities.tt - RingtoetsEntities.tt Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/DuneAssessmentSectionEntity.cs =================================================================== diff -u -r4512af7782ee31b36941bb280b54d9da2953dd71 -rd180f991b1e2664695dc4e98118e3159256fe3cd --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/DuneAssessmentSectionEntity.cs (.../DuneAssessmentSectionEntity.cs) (revision 4512af7782ee31b36941bb280b54d9da2953dd71) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/DuneAssessmentSectionEntity.cs (.../DuneAssessmentSectionEntity.cs) (revision d180f991b1e2664695dc4e98118e3159256fe3cd) @@ -39,7 +39,7 @@ public long ProjectEntityId { get; set; } public string Name { get; set; } public int Norm { get; set; } - public long Order { get; set; } + public int Order { get; set; } public virtual ProjectEntity ProjectEntity { get; set; } } Fisheye: Tag d180f991b1e2664695dc4e98118e3159256fe3cd refers to a dead (removed) revision in file `Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/PartialDikeAssessmentSectionEntity.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag d180f991b1e2664695dc4e98118e3159256fe3cd refers to a dead (removed) revision in file `Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/PartialDuneAssessmentSectionEntity.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx =================================================================== diff -u -re7acba10209b18e88bf89d9211f6fc031d0f992e -rd180f991b1e2664695dc4e98118e3159256fe3cd --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx (.../RingtoetsEntities.edmx) (revision e7acba10209b18e88bf89d9211f6fc031d0f992e) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx (.../RingtoetsEntities.edmx) (revision d180f991b1e2664695dc4e98118e3159256fe3cd) @@ -23,7 +23,7 @@ - + @@ -88,11 +88,11 @@ - + @@ -128,17 +128,6 @@ - - - - - - - - - - - @@ -151,6 +140,17 @@ + + + + + + + + + + + Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx.diagram =================================================================== diff -u -re7acba10209b18e88bf89d9211f6fc031d0f992e -rd180f991b1e2664695dc4e98118e3159256fe3cd --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx.diagram (.../RingtoetsEntities.edmx.diagram) (revision e7acba10209b18e88bf89d9211f6fc031d0f992e) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx.diagram (.../RingtoetsEntities.edmx.diagram) (revision d180f991b1e2664695dc4e98118e3159256fe3cd) @@ -8,8 +8,8 @@ - + Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/DikeAssessmentSectionEntityPersistor.cs =================================================================== diff -u -r4512af7782ee31b36941bb280b54d9da2953dd71 -rd180f991b1e2664695dc4e98118e3159256fe3cd --- Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/DikeAssessmentSectionEntityPersistor.cs (.../DikeAssessmentSectionEntityPersistor.cs) (revision 4512af7782ee31b36941bb280b54d9da2953dd71) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/DikeAssessmentSectionEntityPersistor.cs (.../DikeAssessmentSectionEntityPersistor.cs) (revision d180f991b1e2664695dc4e98118e3159256fe3cd) @@ -59,24 +59,13 @@ } /// - /// Loads the as from . + /// Loads the as . /// - /// Collection where objects can be searched. Usually, this collection is a navigation property of a . - /// List of . - public IEnumerable LoadModels(ICollection parentNavigationProperty) + /// The to load. + /// A new instance of , based on the properties of . + public DikeAssessmentSection LoadModel(DikeAssessmentSectionEntity entity) { - if (parentNavigationProperty == null) - { - throw new ArgumentNullException("parentNavigationProperty"); - } - var list = new List(); - var entities = parentNavigationProperty.ToList(); - entities.Sort(); - foreach (var entity in entities) - { - list.Add(converter.ConvertEntityToModel(entity)); - } - return list; + return converter.ConvertEntityToModel(entity); } /// Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/DuneAssessmentSectionEntityPersistor.cs =================================================================== diff -u -r4512af7782ee31b36941bb280b54d9da2953dd71 -rd180f991b1e2664695dc4e98118e3159256fe3cd --- Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/DuneAssessmentSectionEntityPersistor.cs (.../DuneAssessmentSectionEntityPersistor.cs) (revision 4512af7782ee31b36941bb280b54d9da2953dd71) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/DuneAssessmentSectionEntityPersistor.cs (.../DuneAssessmentSectionEntityPersistor.cs) (revision d180f991b1e2664695dc4e98118e3159256fe3cd) @@ -59,24 +59,13 @@ } /// - /// Loads the as from . + /// Loads the as . /// - /// Collection where objects can be searched. Usually, this collection is a navigation property of a . - /// List of . - public IEnumerable LoadModels(ICollection parentNavigationProperty) + /// The to load. + /// A new instance of , based on the properties of . + public DuneAssessmentSection LoadModel(DuneAssessmentSectionEntity entity) { - if (parentNavigationProperty == null) - { - throw new ArgumentNullException("parentNavigationProperty"); - } - var list = new List(); - var entities = parentNavigationProperty.ToList(); - entities.Sort(); - foreach (var entity in entities) - { - list.Add(converter.ConvertEntityToModel(entity)); - } - return list; + return converter.ConvertEntityToModel(entity); } /// Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/IPersistor.cs =================================================================== diff -u -r4512af7782ee31b36941bb280b54d9da2953dd71 -rd180f991b1e2664695dc4e98118e3159256fe3cd --- Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/IPersistor.cs (.../IPersistor.cs) (revision 4512af7782ee31b36941bb280b54d9da2953dd71) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/IPersistor.cs (.../IPersistor.cs) (revision d180f991b1e2664695dc4e98118e3159256fe3cd) @@ -61,11 +61,11 @@ void PerformPostSaveActions(); /// - /// Loads the as from . + /// Loads the as . /// - /// Collection where objects can be searched. Usually, this collection is a navigation property of a . - /// List of . - IEnumerable LoadModels(ICollection parentNavigationProperty); + /// The to load. + /// A new instance of , based on the properties of . + TModel LoadModel(TEntity entity); /// /// Updates the children of , in reference to , in the storage. Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/ProjectEntityPersistor.cs =================================================================== diff -u -r4512af7782ee31b36941bb280b54d9da2953dd71 -rd180f991b1e2664695dc4e98118e3159256fe3cd --- Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/ProjectEntityPersistor.cs (.../ProjectEntityPersistor.cs) (revision 4512af7782ee31b36941bb280b54d9da2953dd71) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/ProjectEntityPersistor.cs (.../ProjectEntityPersistor.cs) (revision d180f991b1e2664695dc4e98118e3159256fe3cd) @@ -80,23 +80,28 @@ return null; } var project = converter.ConvertEntityToModel(entry); - if (entry.DikeAssessmentSectionEntities.Count > 0) + + var nrOfItems = (entry.DikeAssessmentSectionEntities.Count + entry.DuneAssessmentSectionEntities.Count); + var assessmentSections = new object[nrOfItems]; + + var dikeAssessmentSectionEntities = entry.DikeAssessmentSectionEntities.ToList(); + foreach (var sectionEntity in dikeAssessmentSectionEntities) { - var list = dikeAssessmentSectionEntityPersistor.LoadModels(entry.DikeAssessmentSectionEntities); - foreach (var section in list) - { - project.Items.Add(section); - } + assessmentSections[sectionEntity.Order] = dikeAssessmentSectionEntityPersistor.LoadModel(sectionEntity); } - if (entry.DuneAssessmentSectionEntities.Count > 0) + + var duneAssessmentSectionEntities = entry.DuneAssessmentSectionEntities.ToList(); + foreach (var sectionEntity in duneAssessmentSectionEntities) { - var duneList = duneAssessmentSectionEntityPersistor.LoadModels(entry.DuneAssessmentSectionEntities); - foreach (var section in duneList) - { - project.Items.Add(section); - } + assessmentSections[sectionEntity.Order] = duneAssessmentSectionEntityPersistor.LoadModel(sectionEntity); } + // Add to items sorted + foreach (var assessmentSection in assessmentSections) + { + project.Items.Add(assessmentSection); + } + return project; } Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Persistors/DikeAssessmentSectionEntityPersistorTest.cs =================================================================== diff -u -re7acba10209b18e88bf89d9211f6fc031d0f992e -rd180f991b1e2664695dc4e98118e3159256fe3cd --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Persistors/DikeAssessmentSectionEntityPersistorTest.cs (.../DikeAssessmentSectionEntityPersistorTest.cs) (revision e7acba10209b18e88bf89d9211f6fc031d0f992e) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Persistors/DikeAssessmentSectionEntityPersistorTest.cs (.../DikeAssessmentSectionEntityPersistorTest.cs) (revision d180f991b1e2664695dc4e98118e3159256fe3cd) @@ -47,15 +47,15 @@ } [Test] - public void LoadModels_NullDataset_ThrowsArgumentNullException() + public void LoadModel_NullEntity_ThrowsArgumentNullException() { // Setup var ringtoetsEntities = mockRepository.StrictMock(); DikeAssessmentSectionEntityPersistor persistor = new DikeAssessmentSectionEntityPersistor(ringtoetsEntities); mockRepository.ReplayAll(); // Call - TestDelegate test = () => persistor.LoadModels(null); + TestDelegate test = () => persistor.LoadModel(null); // Assert Assert.Throws(test); @@ -64,48 +64,24 @@ } [Test] - public void LoadModels_EmptyDataset_DoesNotThrowException() + public void LoadModel_ValidEntity_EntityAsModelInList() { // Setup - var ringtoetsEntities = mockRepository.StrictMock(); - DikeAssessmentSectionEntityPersistor persistor = new DikeAssessmentSectionEntityPersistor(ringtoetsEntities); - ICollection parentNavigationProperty = new List(); - mockRepository.ReplayAll(); - - // Call - TestDelegate test = () => persistor.LoadModels(parentNavigationProperty); - - // Assert - Assert.DoesNotThrow(test); - - mockRepository.VerifyAll(); - } - - [Test] - public void LoadModels_SingleEntityInDataset_EntityAsModelInList() - { - // Setup const long storageId = 1234L; const string name = "test"; const int norm = 30000; var ringtoetsEntities = mockRepository.StrictMock(); DikeAssessmentSectionEntityPersistor persistor = new DikeAssessmentSectionEntityPersistor(ringtoetsEntities); - ICollection parentNavigationProperty = new List + var entity = new DikeAssessmentSectionEntity { - new DikeAssessmentSectionEntity - { - DikeAssessmentSectionEntityId = storageId, Name = name, Norm = norm - } + DikeAssessmentSectionEntityId = storageId, Name = name, Norm = norm }; mockRepository.ReplayAll(); // Call - IEnumerable loadedModels = persistor.LoadModels(parentNavigationProperty); + DikeAssessmentSection section = persistor.LoadModel(entity); // Assert - var loadedModelsList = loadedModels.ToList(); - Assert.AreEqual(parentNavigationProperty.Count, loadedModelsList.Count); - DikeAssessmentSection section = loadedModelsList[0]; Assert.AreEqual(storageId, section.StorageId); Assert.AreEqual(name, section.Name); Assert.AreEqual(norm, section.FailureMechanismContribution.Norm); @@ -114,7 +90,7 @@ } [Test] - public void LoadModels_MultipleEntitiesInDataset_EntitiesAsModelInList() + public void LoadModel_MultipleEntitiesInDataset_EntitiesAsModelInList() { // Setup var ringtoetsEntities = mockRepository.StrictMock(); @@ -133,7 +109,7 @@ mockRepository.ReplayAll(); // Call - IEnumerable loadedModels = persistor.LoadModels(parentNavigationProperty); + var loadedModels = parentNavigationProperty.Select(entity => persistor.LoadModel(entity)); // Assert var parentNavigationPropertyList = parentNavigationProperty.ToList(); @@ -669,7 +645,7 @@ { persistor.UpdateModel(parentNavigationPropertyMock, dikeAssessmentSection, 0); } - catch (Exception exception) + catch (Exception) { Assert.Fail("Precondition failed: persistor.UpdateModel"); } Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Persistors/DuneAssessmentSectionEntityPersistorTest.cs =================================================================== diff -u -re7acba10209b18e88bf89d9211f6fc031d0f992e -rd180f991b1e2664695dc4e98118e3159256fe3cd --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Persistors/DuneAssessmentSectionEntityPersistorTest.cs (.../DuneAssessmentSectionEntityPersistorTest.cs) (revision e7acba10209b18e88bf89d9211f6fc031d0f992e) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Persistors/DuneAssessmentSectionEntityPersistorTest.cs (.../DuneAssessmentSectionEntityPersistorTest.cs) (revision d180f991b1e2664695dc4e98118e3159256fe3cd) @@ -47,15 +47,15 @@ } [Test] - public void LoadModels_NullDataset_ThrowsArgumentNullException() + public void LoadModel_NullEntity_ThrowsArgumentNullException() { // Setup var ringtoetsEntities = mockRepository.StrictMock(); DuneAssessmentSectionEntityPersistor persistor = new DuneAssessmentSectionEntityPersistor(ringtoetsEntities); mockRepository.ReplayAll(); // Call - TestDelegate test = () => persistor.LoadModels(null); + TestDelegate test = () => persistor.LoadModel(null); // Assert Assert.Throws(test); @@ -64,48 +64,26 @@ } [Test] - public void LoadModels_EmptyDataset_DoesNotThrowException() + public void LoadModel_ValidEntity_EntityAsModelInList() { // Setup - var ringtoetsEntities = mockRepository.StrictMock(); - DuneAssessmentSectionEntityPersistor persistor = new DuneAssessmentSectionEntityPersistor(ringtoetsEntities); - ICollection parentNavigationProperty = new List(); - mockRepository.ReplayAll(); - - // Call - TestDelegate test = () => persistor.LoadModels(parentNavigationProperty); - - // Assert - Assert.DoesNotThrow(test); - - mockRepository.VerifyAll(); - } - - [Test] - public void LoadModels_SingleEntityInDataset_EntityAsModelInList() - { - // Setup const long storageId = 1234L; const string name = "test"; const int norm = 30000; var ringtoetsEntities = mockRepository.StrictMock(); DuneAssessmentSectionEntityPersistor persistor = new DuneAssessmentSectionEntityPersistor(ringtoetsEntities); - ICollection parentNavigationProperty = new List + var entity = new DuneAssessmentSectionEntity { - new DuneAssessmentSectionEntity - { - DuneAssessmentSectionEntityId = storageId, Name = name, Norm = norm - } + DuneAssessmentSectionEntityId = storageId, + Name = name, + Norm = norm }; mockRepository.ReplayAll(); // Call - IEnumerable loadedModels = persistor.LoadModels(parentNavigationProperty); + DuneAssessmentSection section = persistor.LoadModel(entity); // Assert - var loadedModelsList = loadedModels.ToList(); - Assert.AreEqual(parentNavigationProperty.Count, loadedModelsList.Count); - DuneAssessmentSection section = loadedModelsList[0]; Assert.AreEqual(storageId, section.StorageId); Assert.AreEqual(name, section.Name); Assert.AreEqual(norm, section.FailureMechanismContribution.Norm); @@ -114,7 +92,7 @@ } [Test] - public void LoadModels_MultipleEntitiesInDataset_EntitiesAsModelInList() + public void LoadModel_MultipleEntitiesInDataset_EntitiesAsModelInList() { // Setup var ringtoetsEntities = mockRepository.StrictMock(); @@ -133,7 +111,7 @@ mockRepository.ReplayAll(); // Call - IEnumerable loadedModels = persistor.LoadModels(parentNavigationProperty); + var loadedModels = parentNavigationProperty.Select(entity => persistor.LoadModel(entity)); // Assert var parentNavigationPropertyList = parentNavigationProperty.ToList(); @@ -312,7 +290,8 @@ { Norm = norm } - }; + } + ; mockRepository.ReplayAll(); // Call @@ -659,7 +638,7 @@ { persistor.UpdateModel(parentNavigationPropertyMock, duneAssessmentSection, 0); } - catch (Exception exception) + catch (Exception) { Assert.Fail("Precondition failed: persistor.UpdateModel"); } Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Persistors/ProjectEntityPersistorTest.cs =================================================================== diff -u -re7acba10209b18e88bf89d9211f6fc031d0f992e -rd180f991b1e2664695dc4e98118e3159256fe3cd --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Persistors/ProjectEntityPersistorTest.cs (.../ProjectEntityPersistorTest.cs) (revision e7acba10209b18e88bf89d9211f6fc031d0f992e) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Persistors/ProjectEntityPersistorTest.cs (.../ProjectEntityPersistorTest.cs) (revision d180f991b1e2664695dc4e98118e3159256fe3cd) @@ -174,14 +174,16 @@ { new DikeAssessmentSectionEntity { - Norm = 1 + Norm = 1, + Order = 0 } }, DuneAssessmentSectionEntities = new List { new DuneAssessmentSectionEntity { - Norm = 1 + Norm = 1, + Order = 1 } } } @@ -199,8 +201,8 @@ Assert.AreEqual(storageId, model.StorageId); Assert.AreEqual(description, model.Description); Assert.AreEqual(2, model.Items.Count); - Assert.AreEqual(1, model.Items.OfType().ToList().Count); - Assert.AreEqual(1, model.Items.OfType().ToList().Count); + Assert.AreEqual(1, model.Items.Count(i => i is DikeAssessmentSection)); + Assert.AreEqual(1, model.Items.Count(i => i is DuneAssessmentSection)); mockRepository.VerifyAll(); }