protected virtual void EmpOnShift(Employee emp, int index4Shift) { //Phase II if employee is already on the shift //***Check if subscriber (listener) will handle this event //Invoke the delegate. The handler will know which employee and which shift it is. OnShift?.Invoke(emp, index4Shift); }
protected virtual void EmpOnShift(Employee emp, int index4Shift) { if (OnShift != null) { //Invokes the delegates. // if the test succeeds call the event handler method with the ”emp” object as parameter OnShift?.Invoke(emp, index4Shift); } }
public void TestRegisterShift() { DbConnector dbC = new DbConnector(); string resp = dbC.connect(); Assert.AreEqual("Done", resp); OnShift oShift = new OnShift(); oShift.StaffId = "D2"; oShift.DateOnShift = "04/12/2019"; oShift.TimeOnShift = "11:00 - 11:59"; oShift.DateAndTimeRegistered = "13/4/2019 5:29:15 PM"; oShift.DateAndTimeDeregistered = ""; OnShiftHandler UnitTest1 = new OnShiftHandler(); UnitTest1.registerShift(dbC.getConn(), oShift); }