예제 #1
0
        public void TestEvents()
        {
            var freezable = new FreezablePoker();

            testEventHelper(freezable, false, false, "init");
            freezable.SetValue(ValueProperty, "test");
            testEventHelper(freezable, true, false, false, "SetValue");
            freezable.WritePostscript();
            testEventHelper(freezable, true, true, "WritePostscript");
        }
예제 #2
0
        public void TestFreezePropagation()
        {
            var freezable = new FreezablePoker();

            freezable.SetValue(FreezableProperty, new Unfreezable());
            Assert.IsFalse(freezable.CanFreeze, "CanFreeze return true with an unfreezable children!");
            var childFreezable = new FreezablePoker();

            freezable.SetValue(FreezableProperty, childFreezable);
            freezable.Freeze();
            Assert.IsFalse(childFreezable.IsFrozen, "child Freezable is not frozen after it's parent was forzen!");
        }
예제 #3
0
        public void TestFreezeClone()
        {
            var freezable = new FreezablePoker();

            freezable.SetValue(ValueProperty, "test");
            freezable.Freeze();
            Assert.IsTrue(freezable.IsFrozen, "Freezable is not frozen!");
            var freezableClone = freezable.Clone();

            Assert.IsFalse(freezableClone.IsFrozen, "FreezableClone is frozen!");
            Assert.AreEqual(freezableClone.GetValue(ValueProperty), "test",
                            "FreezableClone ValueProperty wasn't copied properly!");
        }
예제 #4
0
 private void testEventHelper(FreezablePoker freezable, bool changed, bool onChanged, string state)
 {
     if (changed)
     {
         Assert.IsTrue(freezable.changedCalled, "changed wasn't raised on " + state);
     }
     else
     {
         Assert.IsFalse(freezable.changedCalled, "changed was raised on " + state);
     }
     if (onChanged)
     {
         Assert.IsTrue(freezable.onChangedCalled, "OnChanged wasn't called on " + state);
     }
     else
     {
         Assert.IsFalse(freezable.onChangedCalled, "OnChanged was called on " + state);
     }
     freezable.changedCalled   = false;
     freezable.onChangedCalled = false;
 }