Index: Core/Gui/test/Core.Gui.TestUtil/Core.Gui.TestUtil.csproj
===================================================================
diff -u -r9d314bdfad94ff3fa9695732f06e4b541facb2a7 -r7d5b45bb235209809f53fabb6bd7b05cfff67765
--- Core/Gui/test/Core.Gui.TestUtil/Core.Gui.TestUtil.csproj (.../Core.Gui.TestUtil.csproj) (revision 9d314bdfad94ff3fa9695732f06e4b541facb2a7)
+++ Core/Gui/test/Core.Gui.TestUtil/Core.Gui.TestUtil.csproj (.../Core.Gui.TestUtil.csproj) (revision 7d5b45bb235209809f53fabb6bd7b05cfff67765)
@@ -24,6 +24,9 @@
2.0.2000
+
+ 4.4.0
+
3.8.1
Index: Core/Gui/test/Core.Gui.TestUtil/MainWindowTestHelper.cs
===================================================================
diff -u -r9339a780307cdb21ebe38cbd3aa8811e2c98d980 -r7d5b45bb235209809f53fabb6bd7b05cfff67765
--- Core/Gui/test/Core.Gui.TestUtil/MainWindowTestHelper.cs (.../MainWindowTestHelper.cs) (revision 9339a780307cdb21ebe38cbd3aa8811e2c98d980)
+++ Core/Gui/test/Core.Gui.TestUtil/MainWindowTestHelper.cs (.../MainWindowTestHelper.cs) (revision 7d5b45bb235209809f53fabb6bd7b05cfff67765)
@@ -23,6 +23,7 @@
using System.Drawing;
using Core.Gui.Forms.Main;
using Rhino.Mocks;
+using NSubstitute;
namespace Core.Gui.TestUtil
{
@@ -45,5 +46,19 @@
return mainWindow;
}
+
+ ///
+ /// Creates a new stub.
+ ///
+ /// The stub.
+ public static IMainWindow CreateMainWindowStub()
+ {
+ var mainWindow = Substitute.For();
+
+ mainWindow.ApplicationIcon.Returns(SystemIcons.Application);
+ mainWindow.Handle.Returns(IntPtr.Zero);
+
+ return mainWindow;
+ }
}
}
\ No newline at end of file
Index: Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs
===================================================================
diff -u -r9339a780307cdb21ebe38cbd3aa8811e2c98d980 -r7d5b45bb235209809f53fabb6bd7b05cfff67765
--- Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs (.../WaveImpactAsphaltCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs) (revision 9339a780307cdb21ebe38cbd3aa8811e2c98d980)
+++ Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs (.../WaveImpactAsphaltCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs) (revision 7d5b45bb235209809f53fabb6bd7b05cfff67765)
@@ -37,7 +37,7 @@
using Core.Gui.TestUtil.ContextMenu;
using NUnit.Extensions.Forms;
using NUnit.Framework;
-using Rhino.Mocks;
+using NSubstitute;
using Riskeer.Common.Data;
using Riskeer.Common.Data.AssessmentSection;
using Riskeer.Common.Data.Calculation;
@@ -69,16 +69,14 @@
private static readonly string validHrdFilePath = Path.Combine(testDataPath, "HRD dutch coast south.sqlite");
private static readonly string validHrdFileVersion = "Dutch coast South19-11-2015 12:0013";
- private MockRepository mocks;
private WaveImpactAsphaltCoverPlugin plugin;
private TreeNodeInfo info;
[Test]
public void Initialized_Always_ExpectedPropertiesSet()
{
// Setup
- mocks.ReplayAll();
-
+
// Assert
Assert.IsNotNull(info.Text);
Assert.IsNull(info.ForeColor);
@@ -104,9 +102,8 @@
public void Text_Always_ReturnCalculationName()
{
// Setup
- var assessmentSection = mocks.Stub();
- mocks.ReplayAll();
-
+ var assessmentSection = Substitute.For();
+
const string name = "cool name";
var parent = new CalculationGroup();
var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation
@@ -130,8 +127,7 @@
public void Image_Always_ReturnCalculationIcon()
{
// Setup
- mocks.ReplayAll();
-
+
// Call
Image icon = info.Image(null);
@@ -143,8 +139,7 @@
public void EnsureVisibleOnCreate_Always_ReturnTrue()
{
// Setup
- mocks.ReplayAll();
-
+
// Call
bool shouldBeVisible = info.EnsureVisibleOnCreate(null, null);
@@ -156,8 +151,8 @@
public void ChildNodeObjects_CalculationWithoutOutput_ReturnChildrenWithEmptyOutput()
{
// Setup
- var assessmentSection = mocks.Stub();
- assessmentSection.Stub(a => a.HydraulicBoundaryData).Return(new HydraulicBoundaryData
+ var assessmentSection = Substitute.For();
+ assessmentSection.HydraulicBoundaryData.Returns(new HydraulicBoundaryData
{
HydraulicBoundaryDatabases =
{
@@ -170,8 +165,7 @@
}
}
});
- mocks.ReplayAll();
-
+
var parent = new CalculationGroup();
var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation
{
@@ -215,8 +209,8 @@
public void ChildNodeObjects_CalculationWithOutput_ReturnChildrenWithOutput()
{
// Setup
- var assessmentSection = mocks.Stub();
- assessmentSection.Stub(a => a.HydraulicBoundaryData).Return(new HydraulicBoundaryData
+ var assessmentSection = Substitute.For();
+ assessmentSection.HydraulicBoundaryData.Returns(new HydraulicBoundaryData
{
HydraulicBoundaryDatabases =
{
@@ -229,8 +223,7 @@
}
}
});
- mocks.ReplayAll();
-
+
var parent = new CalculationGroup();
var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation
{
@@ -274,8 +267,7 @@
public void CanRename_Always_ReturnTrue()
{
// Setup
- mocks.ReplayAll();
-
+
// Call
bool canRename = info.CanRename(null, null);
@@ -287,10 +279,8 @@
public void OnNodeRenamed_ChangeNameOfCalculationAndNotifyObservers()
{
// Setup
- var assessmentSection = mocks.Stub();
- var observer = mocks.StrictMock();
- observer.Expect(o => o.UpdateObserver());
- mocks.ReplayAll();
+ var assessmentSection = Substitute.For();
+ var observer = Substitute.For();
var parent = new CalculationGroup();
var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation
@@ -311,14 +301,14 @@
// Assert
Assert.AreEqual(name, calculation.Name);
+ observer.Received().UpdateObserver();
}
[Test]
public void CanRemove_CalculationInParent_ReturnTrue()
{
// Setup
- var assessmentSection = mocks.Stub();
- mocks.ReplayAll();
+ var assessmentSection = Substitute.For();
var parent = new CalculationGroup();
var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation
@@ -348,8 +338,7 @@
public void CanRemove_CalculationNotInParent_ReturnFalse()
{
// Setup
- var assessmentSection = mocks.Stub();
- mocks.ReplayAll();
+ var assessmentSection = Substitute.For();
var parent = new CalculationGroup();
var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation
@@ -378,10 +367,8 @@
public void OnNodeRemoved_CalculationInParent_CalculationRemovedFromParent()
{
// Setup
- var assessmentSection = mocks.Stub();
- var observer = mocks.StrictMock();
- observer.Expect(o => o.UpdateObserver());
- mocks.ReplayAll();
+ var assessmentSection = Substitute.For();
+ var observer = Substitute.For();
var parent = new CalculationGroup();
var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation
@@ -411,9 +398,6 @@
[Test]
public void CanDrag_Always_ReturnTrue()
{
- // Setup
- mocks.ReplayAll();
-
// Call
bool canDrag = info.CanDrag(null, null);
@@ -426,7 +410,7 @@
{
// Setup
var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism();
- IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocks);
+ IAssessmentSection assessmentSection = new AssessmentSectionStub();
var parent = new CalculationGroup();
var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation();
@@ -435,53 +419,57 @@
failureMechanism,
assessmentSection);
- var orderedMocks = new MockRepository();
- var menuBuilder = orderedMocks.StrictMock();
- using (orderedMocks.Ordered())
- {
- menuBuilder.Expect(mb => mb.AddExportItem()).Return(menuBuilder);
- menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
- menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder);
- menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
- menuBuilder.Expect(mb => mb.AddRenameItem()).Return(menuBuilder);
- menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder);
- menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
- menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder);
- menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder);
- menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
- menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder);
- menuBuilder.Expect(mb => mb.AddDeleteItem()).Return(menuBuilder);
- menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
- menuBuilder.Expect(mb => mb.AddCollapseAllItem()).Return(menuBuilder);
- menuBuilder.Expect(mb => mb.AddExpandAllItem()).Return(menuBuilder);
- menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
- menuBuilder.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilder);
- menuBuilder.Expect(mb => mb.Build()).Return(null);
- }
+ var menuBuilder = Substitute.For();
+ menuBuilder.AddExportItem().Returns(menuBuilder);
+ menuBuilder.AddSeparator().Returns(menuBuilder);
+ menuBuilder.AddCustomItem(Arg.Any()).Returns(menuBuilder);
+ menuBuilder.AddRenameItem().Returns(menuBuilder);
+ menuBuilder.AddDeleteItem().Returns(menuBuilder);
+ menuBuilder.AddCollapseAllItem().Returns(menuBuilder);
+ menuBuilder.AddExpandAllItem().Returns(menuBuilder);
+ menuBuilder.AddPropertiesItem().Returns(menuBuilder);
+ menuBuilder.Build().Returns((ContextMenuStrip) null);
using (var treeViewControl = new TreeViewControl())
{
- var gui = mocks.Stub();
- gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilder);
- gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub());
- mocks.ReplayAll();
- orderedMocks.ReplayAll();
+ var gui = Substitute.For();
+ gui.Get(context, treeViewControl).Returns(menuBuilder);
+ gui.MainWindow.Returns(Substitute.For());
plugin.Gui = gui;
// Call
info.ContextMenuStrip(context, null, treeViewControl);
}
- // Assert
- orderedMocks.VerifyAll();
+ Received.InOrder(() =>
+ {
+ menuBuilder.AddExportItem();
+ menuBuilder.AddSeparator();
+ menuBuilder.AddCustomItem(Arg.Any());
+ menuBuilder.AddSeparator();
+ menuBuilder.AddRenameItem();
+ menuBuilder.AddCustomItem(Arg.Any());
+ menuBuilder.AddSeparator();
+ menuBuilder.AddCustomItem(Arg.Any());
+ menuBuilder.AddCustomItem(Arg.Any());
+ menuBuilder.AddSeparator();
+ menuBuilder.AddCustomItem(Arg.Any());
+ menuBuilder.AddDeleteItem();
+ menuBuilder.AddSeparator();
+ menuBuilder.AddCollapseAllItem();
+ menuBuilder.AddExpandAllItem();
+ menuBuilder.AddSeparator();
+ menuBuilder.AddPropertiesItem();
+ menuBuilder.Build();
+ });
}
[Test]
public void ContextMenuStrip_Always_AddCustomItems()
{
// Setup
- var assessmentSection = mocks.Stub();
+ var assessmentSection = Substitute.For();
var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism();
var parent = new CalculationGroup();
var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation();
@@ -493,11 +481,10 @@
using (var treeViewControl = new TreeViewControl())
{
- var gui = mocks.Stub();
- gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(menuBuilder);
- gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub());
- mocks.ReplayAll();
-
+ var gui = Substitute.For();
+ gui.Get(context, treeViewControl).Returns(menuBuilder);
+ gui.MainWindow.Returns(Substitute.For());
+
plugin.Gui = gui;
// Call
@@ -542,7 +529,7 @@
// Given
var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism();
- var assessmentSection = mocks.Stub();
+ var assessmentSection = Substitute.For();
var parent = new CalculationGroup();
var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation
@@ -556,11 +543,11 @@
using (var treeViewControl = new TreeViewControl())
{
- var appFeatureCommandHandler = mocks.Stub();
- var importHandler = mocks.Stub();
- var exportHandler = mocks.Stub();
- var updateHandler = mocks.Stub();
- var viewCommands = mocks.Stub();
+ var appFeatureCommandHandler = Substitute.For();
+ var importHandler = Substitute.For();
+ var exportHandler = Substitute.For();
+ var updateHandler = Substitute.For();
+ var viewCommands = Substitute.For();
var menuBuilder = new ContextMenuBuilder(appFeatureCommandHandler,
importHandler,
exportHandler,
@@ -569,11 +556,10 @@
context,
treeViewControl);
- var gui = mocks.Stub();
- gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilder);
- gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub());
- mocks.ReplayAll();
-
+ var gui = Substitute.For();
+ gui.Get(context, treeViewControl).Returns(menuBuilder);
+ gui.MainWindow.Returns(Substitute.For());
+
plugin.Gui = gui;
using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl))
@@ -592,7 +578,7 @@
public void ContextMenuStrip_CalculationWithoutForeshoreProfile_ContextMenuItemUpdateForeshoreProfileDisabledAndToolTipSet()
{
// Setup
- IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocks);
+ IAssessmentSection assessmentSection = new AssessmentSectionStub();
var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism();
var parent = new CalculationGroup();
var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation();
@@ -604,10 +590,9 @@
using (var treeViewControl = new TreeViewControl())
{
- var gui = mocks.Stub();
- gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
- gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub());
- mocks.ReplayAll();
+ var gui = Substitute.For();
+ gui.Get(nodeData, treeViewControl).Returns(new CustomItemsOnlyContextMenuBuilder());
+ gui.MainWindow.Returns(Substitute.For());
plugin.Gui = gui;
@@ -630,7 +615,7 @@
public void ContextMenuStrip_CalculationWithForeshoreProfileAndInputInSync_ContextMenuItemUpdateForeshoreProfileDisabledAndToolTipSet()
{
// Setup
- IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocks);
+ IAssessmentSection assessmentSection = new AssessmentSectionStub();
var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism();
var parent = new CalculationGroup();
var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation
@@ -648,10 +633,9 @@
using (var treeViewControl = new TreeViewControl())
{
- var gui = mocks.Stub();
- gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
- gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub());
- mocks.ReplayAll();
+ var gui = Substitute.For();
+ gui.Get(nodeData, treeViewControl).Returns(new CustomItemsOnlyContextMenuBuilder());
+ gui.MainWindow.Returns(Substitute.For());
plugin.Gui = gui;
@@ -674,7 +658,7 @@
public void ContextMenuStrip_CalculationWithForeshoreProfileAndInputOutSync_ContextMenuItemUpdateForeshoreProfileEnabledAndToolTipSet()
{
// Setup
- IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocks);
+ IAssessmentSection assessmentSection = new AssessmentSectionStub();
var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism();
var foreshoreProfileInput = new TestForeshoreProfile();
@@ -695,10 +679,9 @@
using (var treeViewControl = new TreeViewControl())
{
- var gui = mocks.Stub();
- gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
- gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub());
- mocks.ReplayAll();
+ var gui = Substitute.For();
+ gui.Get(nodeData, treeViewControl).Returns(new CustomItemsOnlyContextMenuBuilder());
+ gui.MainWindow.Returns(Substitute.For());
plugin.Gui = gui;
@@ -720,11 +703,10 @@
public void GivenCalculationWithoutOutputAndWithInputOutOfSync_WhenUpdateForeshoreProfileClicked_ThenNoInquiryAndCalculationUpdatedAndInputObserverNotified()
{
// Given
- var calculationObserver = mocks.StrictMock();
- var calculationInputObserver = mocks.StrictMock();
- calculationInputObserver.Expect(o => o.UpdateObserver());
+ var calculationObserver = Substitute.For();
+ var calculationInputObserver = Substitute.For();
- IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocks);
+ IAssessmentSection assessmentSection = new AssessmentSectionStub();
var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism();
var foreshoreProfileInput = new TestForeshoreProfile(true);
@@ -746,11 +728,10 @@
using (var treeViewControl = new TreeViewControl())
{
- var gui = mocks.Stub();
- gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
- gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub());
- mocks.ReplayAll();
-
+ var gui = Substitute.For();
+ gui.Get(nodeData, treeViewControl).Returns(new CustomItemsOnlyContextMenuBuilder());
+ gui.MainWindow.Returns(Substitute.For());
+
plugin.Gui = gui;
TestForeshoreProfile.ChangeBreakWaterProperties(foreshoreProfileInput);
@@ -767,6 +748,7 @@
Assert.IsTrue(calculation.InputParameters.IsForeshoreProfileInputSynchronized);
}
}
+ calculationInputObserver.Received().UpdateObserver();
}
[Test]
@@ -775,9 +757,9 @@
public void GivenCalculationWithOutputAndWithInputOutOfSync_WhenPerformClick_ThenInquiryAndExpectedOutputAndNotifications(bool continuation)
{
// Given
- var calculationObserver = mocks.StrictMock();
- var calculationInputObserver = mocks.StrictMock();
- IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocks);
+ var calculationObserver = Substitute.For();
+ var calculationInputObserver = Substitute.For();
+ IAssessmentSection assessmentSection = new AssessmentSectionStub();
var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism();
var foreshoreProfileInput = new TestForeshoreProfile(true);
@@ -799,12 +781,6 @@
calculation.Attach(calculationObserver);
calculation.InputParameters.Attach(calculationInputObserver);
- if (continuation)
- {
- calculationObserver.Expect(o => o.UpdateObserver());
- calculationInputObserver.Expect(o => o.UpdateObserver());
- }
-
var messageBoxText = "";
DialogBoxHandler = (name, wnd) =>
{
@@ -823,11 +799,10 @@
using (var treeViewControl = new TreeViewControl())
{
- var gui = mocks.Stub();
- gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
- gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub());
- mocks.ReplayAll();
-
+ var gui = Substitute.For();
+ gui.Get(nodeData, treeViewControl).Returns(new CustomItemsOnlyContextMenuBuilder());
+ gui.MainWindow.Returns(Substitute.For());
+
plugin.Gui = gui;
TestForeshoreProfile.ChangeBreakWaterProperties(foreshoreProfileInput);
@@ -850,6 +825,12 @@
$"verwijderd.{Environment.NewLine}{Environment.NewLine}Weet u zeker dat u wilt doorgaan?";
Assert.AreEqual(expectedMessageBoxText, messageBoxText);
+
+ if (continuation)
+ {
+ calculationObserver.Received().UpdateObserver();
+ calculationInputObserver.Received().UpdateObserver();
+ }
}
[Test]
@@ -876,11 +857,11 @@
using (var treeViewControl = new TreeViewControl())
{
- var appFeatureCommandHandler = mocks.Stub();
- var importHandler = mocks.Stub();
- var exportHandler = mocks.Stub();
- var updateHandler = mocks.Stub();
- var viewCommands = mocks.Stub();
+ var appFeatureCommandHandler = Substitute.For();
+ var importHandler = Substitute.For();
+ var exportHandler = Substitute.For();
+ var updateHandler = Substitute.For();
+ var viewCommands = Substitute.For();
var menuBuilder = new ContextMenuBuilder(appFeatureCommandHandler,
importHandler,
exportHandler,
@@ -889,10 +870,9 @@
context,
treeViewControl);
- var gui = mocks.Stub();
- gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilder);
- gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub());
- mocks.ReplayAll();
+ var gui = Substitute.For();
+ gui.Get(context, treeViewControl).Returns(menuBuilder);
+ gui.MainWindow.Returns(Substitute.For());
plugin.Gui = gui;
@@ -929,7 +909,7 @@
// Given
var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism();
- var assessmentSection = mocks.Stub();
+ var assessmentSection = Substitute.For();
var parent = new CalculationGroup();
var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation
@@ -943,11 +923,11 @@
using (var treeViewControl = new TreeViewControl())
{
- var appFeatureCommandHandler = mocks.Stub();
- var importHandler = mocks.Stub();
- var exportHandler = mocks.Stub();
- var updateHandler = mocks.Stub();
- var viewCommands = mocks.Stub();
+ var appFeatureCommandHandler = Substitute.For();
+ var importHandler = Substitute.For();
+ var exportHandler = Substitute.For();
+ var updateHandler = Substitute.For();
+ var viewCommands = Substitute.For();
var menuBuilder = new ContextMenuBuilder(appFeatureCommandHandler,
importHandler,
exportHandler,
@@ -956,10 +936,9 @@
context,
treeViewControl);
- var gui = mocks.Stub();
- gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilder);
- gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub());
- mocks.ReplayAll();
+ var gui = Substitute.For();
+ gui.Get(context, treeViewControl).Returns(menuBuilder);
+ gui.MainWindow.Returns(Substitute.For());
plugin.Gui = gui;
@@ -999,45 +978,41 @@
using (var treeViewControl = new TreeViewControl())
{
- var appFeatureCommandHandler = mocks.Stub();
- var importHandler = mocks.Stub();
- var exportHandler = mocks.Stub();
- var updateHandler = mocks.Stub();
- var viewCommands = mocks.Stub();
+ var appFeatureCommandHandler = Substitute.For();
+ var importHandler = Substitute.For();
+ var exportHandler = Substitute.For();
+ var updateHandler = Substitute.For();
+ var viewCommands = Substitute.For();
var menuBuilder = new ContextMenuBuilder(appFeatureCommandHandler,
importHandler,
exportHandler,
updateHandler,
viewCommands,
context,
treeViewControl);
- var observer = mocks.StrictMock();
- observer.Expect(o => o.UpdateObserver());
+ var observer = Substitute.For();
calculation.Attach(observer);
- IMainWindow mainWindow = MainWindowTestHelper.CreateMainWindowStub(mocks);
+ IMainWindow mainWindow = MainWindowTestHelper.CreateMainWindowStub();
- var gui = mocks.Stub();
- gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilder);
- gui.Stub(g => g.MainWindow).Return(mainWindow);
+ var gui = Substitute.For();
+ gui.Get(context, treeViewControl).Returns(menuBuilder);
+ gui.MainWindow.Returns(mainWindow);
RoundedDouble assessmentLevel = WaveConditionsInputHelper.GetAssessmentLevel(calculation.InputParameters, assessmentSection);
IEnumerable waterLevels = calculation.InputParameters.GetWaterLevels(assessmentLevel);
int nrOfCalculators = waterLevels.Count();
- var calculatorFactory = mocks.Stub();
- calculatorFactory.Expect(cf => cf.CreateWaveConditionsCosineCalculator(Arg.Is.NotNull))
- .WhenCalled(invocation =>
+ var calculatorFactory = Substitute.For();
+ calculatorFactory.CreateWaveConditionsCosineCalculator(Arg.Any())
+ .Returns(callInfo =>
{
HydraRingCalculationSettingsTestHelper.AssertHydraRingCalculationSettings(
HydraulicBoundaryCalculationSettingsFactory.CreateSettings(
assessmentSection.HydraulicBoundaryData,
hydraulicBoundaryLocation),
- (HydraRingCalculationSettings) invocation.Arguments[0]);
- })
- .Return(new TestWaveConditionsCosineCalculator())
- .Repeat
- .Times(nrOfCalculators);
- mocks.ReplayAll();
+ (HydraRingCalculationSettings) callInfo[0]);
+ return new TestWaveConditionsCosineCalculator();
+ });
plugin.Gui = gui;
@@ -1058,7 +1033,10 @@
CalculationServiceTestHelper.AssertCalculationEndMessage(messages[13]);
Assert.AreEqual("Golfcondities berekenen voor 'A' is gelukt.", messages[14]);
});
+ calculatorFactory.Received(nrOfCalculators)
+ .CreateWaveConditionsCosineCalculator(Arg.Any());
Assert.AreEqual(3, calculation.Output.Items.Count());
+ observer.Received().UpdateObserver();
}
}
}
@@ -1068,7 +1046,7 @@
{
// Given
var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism();
- IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocks);
+ IAssessmentSection assessmentSection = new AssessmentSectionStub();
var parent = new CalculationGroup();
var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation
@@ -1083,11 +1061,11 @@
using (var treeViewControl = new TreeViewControl())
{
- var appFeatureCommandHandler = mocks.Stub();
- var importHandler = mocks.Stub();
- var exportHandler = mocks.Stub();
- var updateHandler = mocks.Stub();
- var viewCommands = mocks.Stub();
+ var appFeatureCommandHandler = Substitute.For();
+ var importHandler = Substitute.For();
+ var exportHandler = Substitute.For();
+ var updateHandler = Substitute.For();
+ var viewCommands = Substitute.For();
var menuBuilder = new ContextMenuBuilder(appFeatureCommandHandler,
importHandler,
exportHandler,
@@ -1096,11 +1074,10 @@
context,
treeViewControl);
- var gui = mocks.Stub();
- gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilder);
- gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub());
- mocks.ReplayAll();
-
+ var gui = Substitute.For();
+ gui.Get(context, treeViewControl).Returns(menuBuilder);
+ gui.MainWindow.Returns(Substitute.For());
+
plugin.Gui = gui;
using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl))
@@ -1121,7 +1098,7 @@
{
// Given
var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism();
- IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocks);
+ IAssessmentSection assessmentSection = new AssessmentSectionStub();
var parent = new CalculationGroup();
var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation
@@ -1136,11 +1113,11 @@
using (var treeViewControl = new TreeViewControl())
{
- var appFeatureCommandHandler = mocks.Stub();
- var importHandler = mocks.Stub();
- var exportHandler = mocks.Stub();
- var updateHandler = mocks.Stub();
- var viewCommands = mocks.Stub();
+ var appFeatureCommandHandler = Substitute.For();
+ var importHandler = Substitute.For();
+ var exportHandler = Substitute.For();
+ var updateHandler = Substitute.For();
+ var viewCommands = Substitute.For();
var menuBuilder = new ContextMenuBuilder(appFeatureCommandHandler,
importHandler,
exportHandler,
@@ -1149,11 +1126,10 @@
context,
treeViewControl);
- var gui = mocks.Stub();
- gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilder);
- gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub());
- mocks.ReplayAll();
-
+ var gui = Substitute.For();
+ gui.Get(context, treeViewControl).Returns(menuBuilder);
+ gui.MainWindow.Returns(Substitute.For());
+
plugin.Gui = gui;
using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl))
@@ -1173,10 +1149,9 @@
{
// Given
var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism();
- IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocks);
+ IAssessmentSection assessmentSection = new AssessmentSectionStub();
- var observer = mocks.Stub();
- observer.Expect(o => o.UpdateObserver());
+ var observer = Substitute.For();
var parent = new CalculationGroup();
var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation
@@ -1192,11 +1167,11 @@
using (var treeViewControl = new TreeViewControl())
{
- var appFeatureCommandHandler = mocks.Stub();
- var importHandler = mocks.Stub();
- var exportHandler = mocks.Stub();
- var updateHandler = mocks.Stub();
- var viewCommands = mocks.Stub();
+ var appFeatureCommandHandler = Substitute.For();
+ var importHandler = Substitute.For();
+ var exportHandler = Substitute.For();
+ var updateHandler = Substitute.For();
+ var viewCommands = Substitute.For();
var menuBuilder = new ContextMenuBuilder(appFeatureCommandHandler,
importHandler,
exportHandler,
@@ -1205,11 +1180,10 @@
context,
treeViewControl);
- var gui = mocks.Stub();
- gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilder);
- gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub());
- mocks.ReplayAll();
-
+ var gui = Substitute.For();
+ gui.Get(context, treeViewControl).Returns(menuBuilder);
+ gui.MainWindow.Returns(Substitute.For());
+
plugin.Gui = gui;
DialogBoxHandler = (name, wnd) =>
@@ -1226,22 +1200,20 @@
// Then
Assert.IsNull(calculation.Output);
- // Check expectancies in TearDown()
+ observer.Received().UpdateObserver();
}
}
}
public override void Setup()
{
- mocks = new MockRepository();
plugin = new WaveImpactAsphaltCoverPlugin();
info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(WaveImpactAsphaltCoverWaveConditionsCalculationContext));
}
public override void TearDown()
{
plugin.Dispose();
- mocks.VerifyAll();
base.TearDown();
}