Ejemplo n.º 1
0
        public void DisposeWhenNullTargetPasses()
        {
            var target = new LayoutClass();

            target.Dispose();
            Assert.IsNull(target.Target);
        }
Ejemplo n.º 2
0
        public void OnDisposedWhenThrowExceptionPasses()
        {
            var target = new LayoutClass();

            target.Target = new LayoutTargetObject();
            target.OnDisposed.Add((_self) => {
                throw new System.Exception();
            });

            Assert.DoesNotThrow(() => target.Dispose());

            Assert.IsNull(target.Target);
            Assert.AreEqual(0, target.OnDisposed.RegistedDelegateCount);
        }
Ejemplo n.º 3
0
        public void DisposePasses()
        {
            var target = new LayoutClass();
            var obj    = new LayoutTargetObject();

            Assert.AreEqual(0, obj.OnDisposed.RegistedDelegateCount);

            target.Target = obj;
            Assert.AreEqual(1, obj.OnDisposed.RegistedDelegateCount);

            target.Dispose();
            Assert.IsNull(target.Target);
            Assert.AreEqual(0, obj.OnDisposed.RegistedDelegateCount, $"Remove a callback of LayoutBase from ILayoutTarget#OnDisposed After LayoutBase#Dispose()");
        }
Ejemplo n.º 4
0
        public void OnDisposedPasses()
        {
            var     target        = new LayoutClass();
            var     callCounter   = 0;
            ILayout recievedValue = null;

            target.OnDisposed.Add((_self) => {
                callCounter++;
                recievedValue = _self;
            });
            target.Dispose();

            Assert.AreEqual(1, callCounter);
            Assert.AreSame(target, recievedValue);
            Assert.AreEqual(0, target.OnDisposed.RegistedDelegateCount);
        }