public async Task Should_be_short_and_sweet() { var phone = new PrincessModelTelephone(); await _machine.RaiseEvent(phone, _model.ServiceEstablished, new PhoneServiceEstablished { Digits = "555-1212" }); await _machine.RaiseEvent(phone, _model.CallDialed); await _machine.RaiseEvent(phone, _model.CallConnected); await Task.Delay(50); await _machine.RaiseEvent(phone, _model.HungUp); Assert.AreEqual(_model.OffHook.Name, phone.CurrentState); Assert.GreaterOrEqual(phone.CallTimer.ElapsedMilliseconds, 45); }
public async void Should_end__badly() { var phone = new PrincessModelTelephone(); await _machine.RaiseEvent(phone, _machine.ServiceEstablished, new PhoneServiceEstablished { Digits = "555-1212" }); await _machine.RaiseEvent(phone, x => x.CallDialed); await _machine.RaiseEvent(phone, x => x.CallConnected); await _machine.RaiseEvent(phone, x => x.PlacedOnHold); await Task.Delay(50); await _machine.RaiseEvent(phone, x => x.HungUp); Assert.AreEqual(_machine.OffHook.Name, phone.CurrentState); Assert.GreaterOrEqual(phone.CallTimer.ElapsedMilliseconds, 45); }
void StartCallTimer(PrincessModelTelephone instance) { Console.WriteLine("Started call timer"); instance.CallTimer.Start(); }
void StopCallTimer(PrincessModelTelephone instance) { instance.CallTimer.Stop(); Console.WriteLine("Stopped call timer at {0}ms", instance.CallTimer.ElapsedMilliseconds); }