Beispiel #1
0
        public void SubClassEventSubscriberCanNotRecieveSuperClassEvent()
        {
            int testData = 1;
            var obj      = new SuperClass {
                SuperData = testData
            };

            EventHub.Instance.Post(obj);
            Task.Delay(100).Wait();
            Assert.That(d.MethodHit, Is.EqualTo(true), $"'{obj.GetType().FullName}' subscriber wasn't hit in '{d.GetType().FullName}'");
            Assert.That(d.obj, Is.EqualTo(obj), $"Data wasn't changed in '{d.GetType().FullName}'");

            Assert.That(a.SubMethodHit, Is.Not.EqualTo(true), $"'{obj.GetType().FullName}' subscriber was hit in '{a.GetType().FullName}'");
            Assert.That(a.obj, Is.Not.EqualTo(obj), $"Data was changed in '{a.GetType().FullName}'");
        }
Beispiel #2
0
        public void SubscriberInheritenceTest()
        {
            B   v        = new V();
            int testData = 1;
            var obj      = new ObjectClass {
                SubData = testData
            };
            var supObj = new SuperClass {
                SuperData = testData
            };

            EventHub.Instance.Deregister(a);
            EventHub.Instance.Deregister(b);
            EventHub.Instance.Register(v);
            EventHub.Instance.Post(obj);
            EventHub.Instance.Post(supObj);
            Task.Delay(100).Wait();
            Assert.That(((V)v).NewMethodHit, Is.EqualTo(true), $"'{obj.GetType().FullName}' subscriber wasn't hit in '{v.GetType().FullName}'");
            Assert.That(((V)v).VirtualMethodHit, Is.EqualTo(true), $"'{supObj.GetType().FullName}' subscriber wasn't hit in '{v.GetType().FullName}'");

            Assert.That(((V)v).SupMethodHit, Is.Not.EqualTo(true), $"'{obj.GetType().FullName}' subscriber was hit in '{typeof(B).FullName}'");
            Assert.That(((V)v).UlMethodHit, Is.Not.EqualTo(true), $"'{supObj.GetType().FullName}' subscriber was hit in '{typeof(B).FullName}'");
            EventHub.Instance.Deregister(v);
        }
Beispiel #3
0
 public override void Subscriber(SuperClass objectClass)
 {
     objVirtual       = objectClass;
     VirtualMethodHit = true;
 }
Beispiel #4
0
 public void Subscriber(SuperClass objectClass)
 {
     obj       = objectClass;
     MethodHit = true;
 }
Beispiel #5
0
 public virtual void Subscriber(SuperClass objectClass)
 {
     ulObj       = objectClass;
     UlMethodHit = true;
 }