Hi,
Am having some trouble getting this going - here's the code. Need the delegate function call triggered in StartLockDown() to be able to set the lockDownStartedCount in the code below. Not sure if this is possible. Thought to reach out.
[Test]
public void LockDownMethods_RaisingTheEvents()
{
int lockDownStartedCount = 0, lockDownEndedCount = 0;
_lockDownManager.LockDownEnded += (sender, args) => lockDownEndedCount++;
_lockDownManager.LockDownStarted += (sender, args) => lockDownStartedCount++;
Assert.AreEqual(0, lockDownStartedCount);
Assert.AreEqual(0, lockDownEndedCount);
_lockDownManager.StartLockDown();
Assert.AreEqual(1, lockDownStartedCount);
Assert.AreEqual(0, lockDownEndedCount);
_lockDownManager.StartLockDown();
Assert.AreEqual(1, lockDownStartedCount);
Assert.AreEqual(0, lockDownEndedCount);
_lockDownManager.EndLockDown();
Assert.AreEqual(1, lockDownStartedCount);
Assert.AreEqual(1, lockDownEndedCount);
_lockDownManager.EndLockDown();
Assert.AreEqual(1, lockDownStartedCount);
Assert.AreEqual(1, lockDownEndedCount);
_lockDownManager.StartLockDown();
Assert.AreEqual(2, lockDownStartedCount);
Assert.AreEqual(1, lockDownEndedCount);
}
Currently - I have the StartLockDown method in lockdownmanager method as
public void StartLockDown()
{
LockDownStarted = setCounter();
LockDownStarted.Invoke(this, EventArgs.Empty); // think something needs to change here - like pass the main counter value to setCounter - I tried deriving from EventArgs and adding an int field, that didn't work either
}
public virtual void setCounter(object sender, EventArgs e)
//{
// this method is incorrect, something needs to happen here...
// Console.Write(" in setAccountLockdown----start####");
// //if (e.counter == 0)
// // e.counter = 1;
//}