Exemplo n.º 1
0
            public void GhostTest()
            {
                GhostA          ghostA            = new GhostA();
                IGpiA           gpiA              = ghostA;
                IGhost          ghost             = ghostA;
                PropertyInfo    addSupplyProperty = null;
                PassageCallback addSupplyPassage  = null;

                ghost.AddSupplyNoitfierEvent += (property, passage) =>
                {
                    addSupplyProperty = property;
                    addSupplyPassage  = passage;
                };
                IGpiB gPi = null;

                gpiA.GpiBs.Supply += (gpi) =>
                {
                    gPi = gpi;
                };

                SoulB soulB = new SoulB();

                addSupplyPassage(soulB);


                NUnit.Framework.Assert.AreEqual(soulB, gPi);
            }
Exemplo n.º 2
0
            public void SoulTest()
            {
                IGpiB supplyB   = null;
                IGpiB unsupplyB = null;
                SoulA soulA     = new SoulA();

                SoulProvider.Soul   soul          = new Regulus.Remote.SoulProvider.Soul(1, 1, typeof(IGpiA), soulA);
                PropertyInfo        gpiBsProperty = typeof(IGpiA).GetProperties().FirstOrDefault(p => p.Name == nameof(IGpiA.GpiBs));
                NotifierEventBinder supplyBinder  = NotifierEventBinder.Create(soulA, gpiBsProperty, "Supply", (instance) => supplyB = instance as IGpiB);


                NotifierEventBinder unsupplyBinder = NotifierEventBinder.Create(soulA, gpiBsProperty, "Unsupply", (instance) => unsupplyB = instance as IGpiB);


                soul.AttachSupply(1, supplyBinder);
                soul.AttachUnsupply(1, unsupplyBinder);

                soulA.Add();
                soulA.Remove();

                soul.DetachSupply(1);
                soul.DetachUnsupply(1);

                NUnit.Framework.Assert.AreEqual(soulA.SoulB, supplyB);
                NUnit.Framework.Assert.AreEqual(soulA.SoulB, unsupplyB);
            }