diff --git a/SafeExamBrowser.Contracts/Core/OperationModel/Events/ActionRequiredEventArgs.cs b/SafeExamBrowser.Contracts/Core/OperationModel/Events/ActionRequiredEventArgs.cs
index 729d1c41..61bd0f60 100644
--- a/SafeExamBrowser.Contracts/Core/OperationModel/Events/ActionRequiredEventArgs.cs
+++ b/SafeExamBrowser.Contracts/Core/OperationModel/Events/ActionRequiredEventArgs.cs
@@ -11,7 +11,7 @@ namespace SafeExamBrowser.Contracts.Core.OperationModel.Events
///
/// Base class for all event arguments used for .
///
- public class ActionRequiredEventArgs
+ public abstract class ActionRequiredEventArgs
{
}
}
diff --git a/SafeExamBrowser.Core.UnitTests/OperationModel/OperationSequenceTests.cs b/SafeExamBrowser.Core.UnitTests/OperationModel/OperationSequenceTests.cs
index ab2cee5a..7070eab3 100644
--- a/SafeExamBrowser.Core.UnitTests/OperationModel/OperationSequenceTests.cs
+++ b/SafeExamBrowser.Core.UnitTests/OperationModel/OperationSequenceTests.cs
@@ -11,6 +11,8 @@ using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using SafeExamBrowser.Contracts.Core.OperationModel;
+using SafeExamBrowser.Contracts.Core.OperationModel.Events;
+using SafeExamBrowser.Contracts.I18n;
using SafeExamBrowser.Contracts.Logging;
using SafeExamBrowser.Core.OperationModel;
@@ -54,6 +56,47 @@ namespace SafeExamBrowser.Core.UnitTests.OperationModel
operationC.Verify(o => o.Perform(), Times.Once);
}
+ [TestMethod]
+ public void MustCorrectlyPropagateEventSubscription()
+ {
+ var actionRequiredCalled = false;
+ var actionRequiredHandler = new ActionRequiredEventHandler(args => actionRequiredCalled = true);
+ var statusChangedCalled = false;
+ var statusChangedHandler = new StatusChangedEventHandler(t => statusChangedCalled = true);
+ var operationA = new Mock();
+ var operationB = new Mock();
+ var operationC = new Mock();
+ var operations = new Queue();
+
+ operationA.Setup(o => o.Perform()).Returns(OperationResult.Success);
+ operationB.Setup(o => o.Perform()).Returns(OperationResult.Success).Raises(o => o.ActionRequired += null, new Mock().Object);
+ operationC.Setup(o => o.Perform()).Returns(OperationResult.Success).Raises(o => o.StatusChanged += null, default(TextKey));
+
+ operations.Enqueue(operationA.Object);
+ operations.Enqueue(operationB.Object);
+ operations.Enqueue(operationC.Object);
+
+ var sut = new OperationSequence(loggerMock.Object, operations);
+
+ sut.ActionRequired += actionRequiredHandler;
+ sut.StatusChanged += statusChangedHandler;
+
+ sut.TryPerform();
+
+ Assert.IsTrue(actionRequiredCalled);
+ Assert.IsTrue(statusChangedCalled);
+
+ actionRequiredCalled = false;
+ statusChangedCalled = false;
+ sut.ActionRequired -= actionRequiredHandler;
+ sut.StatusChanged -= statusChangedHandler;
+
+ sut.TryPerform();
+
+ Assert.IsFalse(actionRequiredCalled);
+ Assert.IsFalse(statusChangedCalled);
+ }
+
#region Perform Tests
[TestMethod]
diff --git a/SafeExamBrowser.Core.UnitTests/Operations/LazyInitializationOperationTests.cs b/SafeExamBrowser.Core.UnitTests/Operations/LazyInitializationOperationTests.cs
index 18d643e5..ed33a167 100644
--- a/SafeExamBrowser.Core.UnitTests/Operations/LazyInitializationOperationTests.cs
+++ b/SafeExamBrowser.Core.UnitTests/Operations/LazyInitializationOperationTests.cs
@@ -113,7 +113,7 @@ namespace SafeExamBrowser.Core.UnitTests.Operations
sut.Perform();
- operationMock.Raise(o => o.ActionRequired += null, new ActionRequiredEventArgs());
+ operationMock.Raise(o => o.ActionRequired += null, new Mock().Object);
operationMock.Raise(o => o.StatusChanged += null, default(TextKey));
Assert.AreEqual(1, actionRequired);
@@ -122,7 +122,7 @@ namespace SafeExamBrowser.Core.UnitTests.Operations
sut.ActionRequired -= actionRequiredHandler;
sut.StatusChanged -= statusChangedHandler;
- operationMock.Raise(o => o.ActionRequired += null, new ActionRequiredEventArgs());
+ operationMock.Raise(o => o.ActionRequired += null, new Mock().Object);
operationMock.Raise(o => o.StatusChanged += null, default(TextKey));
Assert.AreEqual(1, actionRequired);
@@ -131,7 +131,7 @@ namespace SafeExamBrowser.Core.UnitTests.Operations
sut.ActionRequired += actionRequiredHandler;
sut.StatusChanged += statusChangedHandler;
- operationMock.Raise(o => o.ActionRequired += null, new ActionRequiredEventArgs());
+ operationMock.Raise(o => o.ActionRequired += null, new Mock().Object);
operationMock.Raise(o => o.StatusChanged += null, default(TextKey));
Assert.AreEqual(2, actionRequired);