Index: Ringtoets/Integration/src/Ringtoets.Integration.Service/Merge/AssessmentSectionProviderActivity.cs
===================================================================
diff -u -rc7a1a30a7fafe8671a06b10bf2a3d56cf9f510a4 -reb36d0a34bdea2d82aabec9f649516dac00a648a
--- Ringtoets/Integration/src/Ringtoets.Integration.Service/Merge/AssessmentSectionProviderActivity.cs (.../AssessmentSectionProviderActivity.cs) (revision c7a1a30a7fafe8671a06b10bf2a3d56cf9f510a4)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Service/Merge/AssessmentSectionProviderActivity.cs (.../AssessmentSectionProviderActivity.cs) (revision eb36d0a34bdea2d82aabec9f649516dac00a648a)
@@ -1,8 +1,14 @@
-using Core.Common.Base.Service;
+using System;
+using Core.Common.Base.Service;
+using Ringtoets.Integration.Data;
using Ringtoets.Integration.Data.Merge;
namespace Ringtoets.Integration.Service.Merge
{
+ ///
+ /// Activity to retrieve a collection of
+ /// from a file.
+ ///
public class AssessmentSectionProviderActivity : Activity
{
private readonly AssessmentSectionsOwner owner;
@@ -11,10 +17,35 @@
private bool canceled;
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The owner to set the retrieved collection
+ /// of on.
+ /// The provider defining how to
+ /// retrieve the collection of from a file.
+ /// The file path to retrieve the collection of
+ /// from.
+ /// Thrown when any of the arguments is null.
public AssessmentSectionProviderActivity(AssessmentSectionsOwner owner,
IAssessmentSectionProvider assessmentSectionProvider,
string filePath)
{
+ if (owner == null)
+ {
+ throw new ArgumentNullException(nameof(owner));
+ }
+
+ if (assessmentSectionProvider == null)
+ {
+ throw new ArgumentNullException(nameof(assessmentSectionProvider));
+ }
+
+ if (filePath == null)
+ {
+ throw new ArgumentNullException(nameof(filePath));
+ }
+
this.owner = owner;
this.assessmentSectionProvider = assessmentSectionProvider;
this.filePath = filePath;
Index: Ringtoets/Integration/test/Ringtoets.Integration.Service.Test/Merge/AssessmentSectionProviderActivityTest.cs
===================================================================
diff -u -rc7a1a30a7fafe8671a06b10bf2a3d56cf9f510a4 -reb36d0a34bdea2d82aabec9f649516dac00a648a
--- Ringtoets/Integration/test/Ringtoets.Integration.Service.Test/Merge/AssessmentSectionProviderActivityTest.cs (.../AssessmentSectionProviderActivityTest.cs) (revision c7a1a30a7fafe8671a06b10bf2a3d56cf9f510a4)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Service.Test/Merge/AssessmentSectionProviderActivityTest.cs (.../AssessmentSectionProviderActivityTest.cs) (revision eb36d0a34bdea2d82aabec9f649516dac00a648a)
@@ -1,4 +1,5 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
using System.Linq;
using Core.Common.Base.Service;
using NUnit.Framework;
@@ -14,6 +15,53 @@
public class AssessmentSectionProviderActivityTest
{
[Test]
+ public void Constructor_OwnerNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var provider = mocks.Stub();
+ mocks.ReplayAll();
+
+ // Call
+ TestDelegate call = () => new AssessmentSectionProviderActivity(null, provider, string.Empty);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("owner", exception.ParamName);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Constructor_ProviderNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => new AssessmentSectionProviderActivity(new AssessmentSectionsOwner(), null, string.Empty);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("assessmentSectionProvider", exception.ParamName);
+ }
+
+ [Test]
+ public void Constructor_FilePathNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var provider = mocks.Stub();
+ mocks.ReplayAll();
+
+ // Call
+ TestDelegate call = () => new AssessmentSectionProviderActivity(new AssessmentSectionsOwner(),
+ provider,
+ null);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("filePath", exception.ParamName);
+ mocks.VerifyAll();
+ }
+
+ [Test]
public void Constructor_ExpectedValues()
{
// Setup
@@ -29,18 +77,18 @@
// Assert
Assert.IsInstanceOf(activity);
Assert.AreEqual(ActivityState.None, activity.State);
+ mocks.VerifyAll();
}
[Test]
- public void Run_ProviderReturnsAssessmentSections_SetsActivityStateToExecutedAndSetsAssessmentSections()
+ public void Run_Always_SendsFilePathToGetsAssessmentSections()
{
// Setup
const string filePath = "Path to file";
- IEnumerable assessmentSections = Enumerable.Empty();
var mocks = new MockRepository();
var provider = mocks.Stub();
- provider.Expect(p => p.GetAssessmentSections(filePath)).Return(assessmentSections);
+ provider.Expect(p => p.GetAssessmentSections(filePath)).Return(Enumerable.Empty());
mocks.ReplayAll();
var owner = new AssessmentSectionsOwner();
@@ -50,46 +98,72 @@
activity.Run();
// Assert
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Run_ProviderReturnsAssessmentSections_SetsActivityStateToExecutedAndSetsAssessmentSections()
+ {
+ // Setup
+ IEnumerable assessmentSections = Enumerable.Empty();
+
+ var mocks = new MockRepository();
+ var provider = mocks.Stub();
+ provider.Expect(p => p.GetAssessmentSections(null))
+ .IgnoreArguments()
+ .Return(assessmentSections);
+ mocks.ReplayAll();
+
+ var owner = new AssessmentSectionsOwner();
+ var activity = new AssessmentSectionProviderActivity(owner, provider, string.Empty);
+
+ // Call
+ activity.Run();
+
+ // Assert
Assert.AreEqual(ActivityState.Executed, activity.State);
Assert.AreSame(assessmentSections, owner.AssessmentSections);
+ mocks.VerifyAll();
}
[Test]
public void Run_ProviderThrowsException_SetsActivityStateToFailedAndDoesNotSetAssessmentSections()
{
// Setup
- const string filePath = "Path to file";
-
var mocks = new MockRepository();
var provider = mocks.Stub();
- provider.Expect(p => p.GetAssessmentSections(filePath)).Throw(new AssessmentSectionProviderException());
+ provider.Expect(p => p.GetAssessmentSections(null))
+ .IgnoreArguments()
+ .Throw(new AssessmentSectionProviderException());
mocks.ReplayAll();
var owner = new AssessmentSectionsOwner();
- var activity = new AssessmentSectionProviderActivity(owner, provider, filePath);
+ var activity = new AssessmentSectionProviderActivity(owner, provider, string.Empty);
// Call
activity.Run();
// Assert
Assert.AreEqual(ActivityState.Failed, activity.State);
Assert.IsNull(owner.AssessmentSections);
+ mocks.VerifyAll();
}
[Test]
public void GivenCancelledActivity_WhenFinishingActivity_ThenActivityStateSetToCancelledAndDoesNotSetAssessmentSections()
{
// Given
- const string filePath = "Path to file";
IEnumerable assessmentSections = Enumerable.Empty();
var mocks = new MockRepository();
var provider = mocks.Stub();
- provider.Expect(p => p.GetAssessmentSections(filePath)).Return(assessmentSections);
+ provider.Expect(p => p.GetAssessmentSections(null))
+ .IgnoreArguments()
+ .Return(assessmentSections);
mocks.ReplayAll();
var owner = new AssessmentSectionsOwner();
- var activity = new AssessmentSectionProviderActivity(owner, provider, filePath);
+ var activity = new AssessmentSectionProviderActivity(owner, provider, string.Empty);
activity.Run();
activity.Cancel();
@@ -100,6 +174,7 @@
// Assert
Assert.AreEqual(ActivityState.Canceled, activity.State);
Assert.IsNull(owner.AssessmentSections);
+ mocks.VerifyAll();
}
}
}
\ No newline at end of file