Index: Ringtoets/Common/src/Ringtoets.Common.IO/ReferenceLines/ReferenceLineImporter.cs
===================================================================
diff -u -rb2d9f258140f5f690bc585ce52d348a04f5a644a -rfd7a4666e62e74819c8bd9d027deb93b7227be6d
--- Ringtoets/Common/src/Ringtoets.Common.IO/ReferenceLines/ReferenceLineImporter.cs (.../ReferenceLineImporter.cs) (revision b2d9f258140f5f690bc585ce52d348a04f5a644a)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/ReferenceLines/ReferenceLineImporter.cs (.../ReferenceLineImporter.cs) (revision fd7a4666e62e74819c8bd9d027deb93b7227be6d)
@@ -31,24 +31,23 @@
namespace Ringtoets.Common.IO.ReferenceLines
{
///
- /// Imports a and stores it on an ,
- /// taking data from a shapefile containing a single polyline.
+ /// Imports a taking data from a shapefile containing a single polyline.
///
- public class ReferenceLineImporter : FileImporterBase
+ public class ReferenceLineImporter : FileImporterBase
{
private readonly List changedObservables = new List();
private readonly IReferenceLineReplaceHandler replacementHandler;
///
/// Initializes a new instance of the class.
///
- /// The assessment section to update.
+ /// The reference line to update.
/// The object responsible for replacing the
/// .
/// The path to the file to import from.
/// Thrown when
/// or is null.
- public ReferenceLineImporter(IAssessmentSection importTarget,
+ public ReferenceLineImporter(ReferenceLine importTarget,
IReferenceLineReplaceHandler replacementHandler,
string filePath)
: base(filePath, importTarget)
@@ -99,7 +98,7 @@
{
var clearReferenceLineDependentData = false;
- if (ImportTarget.ReferenceLine.Points.Any())
+ if (ImportTarget.Points.Any())
{
if (!replacementHandler.ConfirmReplace())
{
@@ -154,7 +153,7 @@
3, 3);
}
- changedObservables.AddRange(replacementHandler.Replace(ImportTarget, importedReferenceLine).Where(o => !ReferenceEquals(o, ImportTarget)));
+ changedObservables.AddRange(replacementHandler.Replace(assessmentSection, importedReferenceLine).Where(o => !ReferenceEquals(o, ImportTarget)));
}
}
}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/ReferenceLines/ReferenceLineImporterTest.cs
===================================================================
diff -u -r0e576d355cea018f0256f7d236c9e0ef444383b7 -rfd7a4666e62e74819c8bd9d027deb93b7227be6d
--- Ringtoets/Common/test/Ringtoets.Common.IO.Test/ReferenceLines/ReferenceLineImporterTest.cs (.../ReferenceLineImporterTest.cs) (revision 0e576d355cea018f0256f7d236c9e0ef444383b7)
+++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/ReferenceLines/ReferenceLineImporterTest.cs (.../ReferenceLineImporterTest.cs) (revision fd7a4666e62e74819c8bd9d027deb93b7227be6d)
@@ -39,7 +39,7 @@
public class ReferenceLineImporterTest
{
[Test]
- public void Constructor_AssessmentSectionNull_ThrowArgumentNullException()
+ public void Constructor_ReferenceLineNull_ThrowArgumentNullException()
{
var mocks = new MockRepository();
var handler = mocks.Stub();
@@ -59,15 +59,14 @@
{
// Setup
var mocks = new MockRepository();
- var assessmentSection = mocks.Stub();
var handler = mocks.Stub();
mocks.ReplayAll();
// Call
- var importer = new ReferenceLineImporter(assessmentSection, handler, "");
+ var importer = new ReferenceLineImporter(new ReferenceLine(), handler, "");
// Assert
- Assert.IsInstanceOf>(importer);
+ Assert.IsInstanceOf>(importer);
mocks.VerifyAll();
}
@@ -77,7 +76,6 @@
// Setup
var mocks = new MockRepository();
var assessmentSection = mocks.Stub();
- assessmentSection.Stub(a => a.ReferenceLine).Return(new ReferenceLine());
var handler = mocks.StrictMock();
handler.Expect(h => h.Replace(Arg.Is.Same(assessmentSection),
Arg.Is.NotNull))
@@ -95,7 +93,7 @@
string path = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO,
Path.Combine("ReferenceLine", "traject_10-2.shp"));
- var importer = new ReferenceLineImporter(assessmentSection, handler, path);
+ var importer = new ReferenceLineImporter(new ReferenceLine(), handler, path);
// Call
bool importSuccessful = importer.Import();
@@ -111,7 +109,6 @@
// Setup
var mocks = new MockRepository();
var assessmentSection = mocks.Stub();
- assessmentSection.Stub(a => a.ReferenceLine).Return(new ReferenceLine());
var handler = mocks.Stub();
handler.Expect(h => h.Replace(Arg.Is.Same(assessmentSection),
Arg.Is.NotNull))
@@ -137,7 +134,7 @@
}
};
var progressChangedCallCount = 0;
- var importer = new ReferenceLineImporter(assessmentSection, handler, path);
+ var importer = new ReferenceLineImporter(new ReferenceLine(), handler, path);
importer.SetProgressChanged((description, step, steps) =>
{
Assert.AreEqual(expectedProgressMessages[progressChangedCallCount].Text, description);
@@ -159,8 +156,6 @@
{
// Setup
var mocks = new MockRepository();
- var assessmentSection = mocks.Stub();
- assessmentSection.Stub(a => a.ReferenceLine).Return(new ReferenceLine());
var handler = mocks.StrictMock();
handler.Expect(h => h.ConfirmReplace())
.Repeat.Never();
@@ -171,7 +166,7 @@
string path = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, Path.DirectorySeparatorChar.ToString());
- var importer = new ReferenceLineImporter(assessmentSection, handler, path);
+ var importer = new ReferenceLineImporter(new ReferenceLine(), handler, path);
// Call
var importSuccessful = true;
@@ -190,8 +185,6 @@
{
// Setup
var mocks = new MockRepository();
- var assessmentSection = mocks.Stub();
- assessmentSection.Stub(a => a.ReferenceLine).Return(new ReferenceLine());
var handler = mocks.StrictMock();
handler.Expect(h => h.ConfirmReplace())
.Repeat.Never();
@@ -202,7 +195,7 @@
string path = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, "I_dont_exist");
- var importer = new ReferenceLineImporter(assessmentSection, handler, path);
+ var importer = new ReferenceLineImporter(new ReferenceLine(), handler, path);
// Call
var importSuccessful = true;
@@ -221,8 +214,6 @@
{
// Setup
var mocks = new MockRepository();
- var assessmentSection = mocks.Stub();
- assessmentSection.Stub(a => a.ReferenceLine).Return(ReferenceLineTestFactory.CreateReferenceLineWithGeometry());
var handler = mocks.StrictMock();
handler.Expect(h => h.ConfirmReplace()).Return(false);
handler.Expect(h => h.Replace(null, null))
@@ -232,7 +223,7 @@
string path = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, "traject_10-2.shp");
- var importer = new ReferenceLineImporter(assessmentSection, handler, path);
+ var importer = new ReferenceLineImporter(ReferenceLineTestFactory.CreateReferenceLineWithGeometry(), handler, path);
// Call
bool importSuccessful = importer.Import();
@@ -251,10 +242,8 @@
string path = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, "traject_10-2.shp");
var mocks = new MockRepository();
- var assessmentSection = mocks.Stub();
- assessmentSection.Stub(a => a.ReferenceLine).Return(ReferenceLineTestFactory.CreateReferenceLineWithGeometry());
var handler = mocks.StrictMock();
- var importer = new ReferenceLineImporter(assessmentSection, handler, path);
+ var importer = new ReferenceLineImporter(ReferenceLineTestFactory.CreateReferenceLineWithGeometry(), handler, path);
handler.Expect(h => h.ConfirmReplace())
.WhenCalled(invocation => importer.Cancel())
.Return(acceptRemovalOfReferenceLineDependentData);
@@ -281,14 +270,12 @@
string path = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, Path.Combine("ReferenceLine", "traject_10-2.shp"));
var mocks = new MockRepository();
- var assessmentSection = mocks.Stub();
- assessmentSection.Stub(a => a.ReferenceLine).Return(new ReferenceLine());
var handler = mocks.Stub();
handler.Stub(h => h.ConfirmReplace())
.Return(true);
mocks.ReplayAll();
- var importer = new ReferenceLineImporter(assessmentSection, handler, path);
+ var importer = new ReferenceLineImporter(new ReferenceLine(), handler, path);
importer.SetProgressChanged((description, step, steps) =>
{
if (description.Contains("Inlezen referentielijn."))
@@ -316,7 +303,6 @@
var mocks = new MockRepository();
var assessmentSection = mocks.Stub();
- assessmentSection.Stub(a => a.ReferenceLine).Return(new ReferenceLine());
var handler = mocks.Stub();
handler.Stub(h => h.ConfirmReplace())
.Return(true);
@@ -325,7 +311,7 @@
.Return(Enumerable.Empty());
mocks.ReplayAll();
- var importer = new ReferenceLineImporter(assessmentSection, handler, path);
+ var importer = new ReferenceLineImporter(new ReferenceLine(), handler, path);
importer.SetProgressChanged((description, step, steps) =>
{
if (description.Contains("Geïmporteerde data toevoegen aan het toetsspoor."))
@@ -352,7 +338,6 @@
// Setup
var mocks = new MockRepository();
var assessmentSection = mocks.Stub();
- assessmentSection.Stub(a => a.ReferenceLine).Return(new ReferenceLine());
var handler = mocks.StrictMock();
handler.Expect(h => h.ConfirmReplace())
.Repeat.Never();
@@ -372,7 +357,7 @@
string path = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO,
Path.Combine("ReferenceLine", "traject_10-2.shp"));
- var importer = new ReferenceLineImporter(assessmentSection, handler, path);
+ var importer = new ReferenceLineImporter(new ReferenceLine(), handler, path);
importer.SetProgressChanged((description, step, steps) => importer.Cancel());
// Precondition
@@ -392,12 +377,13 @@
public void DoPostImportUpdates_AssessmentSectionAlreadyHasReferenceLineWithGeometryAndAnswerDialogToContinue_NotifyObserversOfTargetContextAndClearedObjects()
{
// Setup
+ ReferenceLine referenceLine = ReferenceLineTestFactory.CreateReferenceLineWithGeometry();
+
var mocks = new MockRepository();
var contextObserver = mocks.Stub();
contextObserver.Expect(o => o.UpdateObserver());
var assessmentSection = mocks.Stub();
- assessmentSection.Stub(a => a.ReferenceLine).Return(ReferenceLineTestFactory.CreateReferenceLineWithGeometry());
assessmentSection.Expect(section => section.Attach(contextObserver));
assessmentSection.Expect(section => section.NotifyObservers()).Do((Action) (() => contextObserver.UpdateObserver()));
@@ -423,10 +409,10 @@
string path = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO,
Path.Combine("ReferenceLine", "traject_10-2.shp"));
- var referenceLineContext = new ReferenceLineContext(assessmentSection);
+ var referenceLineContext = new ReferenceLineContext(referenceLine, assessmentSection);
referenceLineContext.Attach(contextObserver);
- var importer = new ReferenceLineImporter(assessmentSection, handler, path);
+ var importer = new ReferenceLineImporter(referenceLine, handler, path);
// Precondition
Assert.IsTrue(importer.Import());
@@ -444,14 +430,15 @@
// Setup
string path = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, "traject_10-2.shp");
+ ReferenceLine referenceLine = ReferenceLineTestFactory.CreateReferenceLineWithGeometry();
+
var mocks = new MockRepository();
var contextObserver = mocks.StrictMock();
var assessmentSection = mocks.Stub();
- assessmentSection.Stub(a => a.ReferenceLine).Return(ReferenceLineTestFactory.CreateReferenceLineWithGeometry());
assessmentSection.Expect(section => section.Attach(contextObserver));
var handler = mocks.StrictMock();
- var importer = new ReferenceLineImporter(assessmentSection, handler, path);
+ var importer = new ReferenceLineImporter(referenceLine, handler, path);
handler.Expect(h => h.ConfirmReplace())
.WhenCalled(invocation => importer.Cancel())
.Return(true);
@@ -461,7 +448,7 @@
mocks.ReplayAll();
- var referenceLineContext = new ReferenceLineContext(assessmentSection);
+ var referenceLineContext = new ReferenceLineContext(referenceLine, assessmentSection);
referenceLineContext.Attach(contextObserver);
// Precondition
@@ -485,7 +472,6 @@
contextObserver.Expect(o => o.UpdateObserver());
var assessmentSection = mocks.Stub();
- assessmentSection.Stub(a => a.ReferenceLine).Return(originalReferenceLine);
assessmentSection.Expect(section => section.Attach(contextObserver));
assessmentSection.Expect(section => section.NotifyObservers()).Do((Action) (() => contextObserver.UpdateObserver()));
@@ -512,10 +498,10 @@
string path = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO,
Path.Combine("ReferenceLine", "traject_10-2.shp"));
- var referenceLineContext = new ReferenceLineContext(assessmentSection);
+ var referenceLineContext = new ReferenceLineContext(originalReferenceLine, assessmentSection);
referenceLineContext.Attach(contextObserver);
- var importer = new ReferenceLineImporter(assessmentSection, handler, path);
+ var importer = new ReferenceLineImporter(originalReferenceLine, handler, path);
importer.SetProgressChanged((description, step, steps) => importer.Cancel());
// Precondition