Ejemplo n.º 1
0
		public void UnknownEventArgs()
		{
			var events = new EventHandlers<String>(this);

			Boolean firstAdded = events.Add<AEventArgs>("v", AEventHandler);
			Assert.IsTrue(firstAdded);
			firstAdded = events.Add<AEventArgs>("v", AEventHandler);
			Assert.IsFalse(firstAdded);

			EventArgs e = new AEventArgs();
			events.Raise("v", e);
			Assert.IsTrue(((AEventArgs)e).Handled);

			e = new BEventArgs();
			events.Raise("v", e);
			Assert.IsTrue(((BEventArgs)e).Handled);
		}
Ejemplo n.º 2
0
		public void Contravariance()
		{
			var events = new EventHandlers<String>(this);

			Boolean firstAdded = events.Add<AEventArgs>("v", AEventHandler);
			Assert.IsTrue(firstAdded);
			firstAdded = events.Add<AEventArgs>("v", AEventHandler);
			Assert.IsFalse(firstAdded);

			var e = new BEventArgs();
			events.Raise("v", e);
			Assert.IsTrue(e.Handled);
		}