static void Main(string[] args) { ConnectionManager man = new ConnectionManager(); Console.WriteLine("Start state: " + man.State.ToString()); man.StateChanged += new ConnectionManager.StateChangedEventHandler(man_OnStateChanged); man.State = ConnectionStates.Connecting; man.State = ConnectionStates.Connected; man.State = ConnectionStates.Disconnected; Console.ReadLine(); }
public void ConnectionManager_Raise_StateChanged_Event() { ConnectionManager man = new ConnectionManager(); Assert.AreEqual(ConnectionStates.Disconnected, man.State); bool eventRaised = false; man.StateChanged += delegate(object sender, StateChangedEventArgs args) { eventRaised = true; }; man.State = ConnectionStates.Connecting; Assert.IsTrue(eventRaised); }