コード例 #1
0
        public void NestDoubleAddError()
        {
            var egg  = new TestEgg();
            var nest = new Nest();

            nest.Add(egg);
            Assert.Throws <ContainNestException>(() => nest.Add(egg));
        }
コード例 #2
0
        public void EggEvent()
        {
            var egg  = new TestEgg();
            var flag = false;

            egg.Knock += args => flag = true;
            egg.InvokeTest();
            Assert.True(flag);
        }
コード例 #3
0
        public void EggAddEvent()
        {
            var nest = new Nest();
            var egg  = new TestEgg();
            var flag = false;

            egg.Knock += args => flag = args.Type == NestEggEventType.Added;
            nest.Add(egg);
            Assert.True(flag);
        }
コード例 #4
0
        public void EggBubleEvent()
        {
            var nest = new Nest();
            var egg  = new TestEgg();
            var flag = false;

            nest.Knock += args => flag = args.Type == NestEggEventType.Custom && args.Self == egg;
            nest.Add(egg);
            egg.InvokeTest();
            Assert.True(flag);
        }
コード例 #5
0
        public void EggMoveEvent()
        {
            var nest  = new Nest();
            var nest2 = new Nest();
            var egg   = new TestEgg();
            var flag  = false;

            egg.Knock += args => flag = args.Type == NestEggEventType.Moved && args.From == nest && args.To == nest2;
            nest.Add(egg);
            nest.MoveTo(egg, nest2);
            Assert.True(flag);
            Assert.IsNotNull(nest2.GetNested <TestEgg>());
        }