コード例 #1
0
ファイル: InkPresenterTest.cs プロジェクト: ynkbt/moon
        public void SetStrokesToNull()
        {
            InkPresenter ink = new InkPresenter();
            object       strokes;

            // check that ReadLocalValue returns a collection after setting it to null via the property accessor
            ink.Strokes = null;
            strokes     = ink.ReadLocalValue(InkPresenter.StrokesProperty);
            Assert.IsTrue(strokes is StrokeCollection, "ReadLocalValue after setting to null returns a collection");

            // check that ReadLocalValue returns a collection after SetValue to null
            ink.SetValue(InkPresenter.StrokesProperty, null);
            strokes = ink.ReadLocalValue(InkPresenter.StrokesProperty);
            Assert.IsTrue(strokes is StrokeCollection, "ReadLocalValue after SetValue(null) returns a collection");
        }
コード例 #2
0
ファイル: InkPresenterTest.cs プロジェクト: ynkbt/moon
        public void ClearValueTest()
        {
            object       strokes, new_strokes, rlv_strokes;
            InkPresenter ink = new InkPresenter();

            // check initial value
            strokes = ink.ReadLocalValue(InkPresenter.StrokesProperty);
            Assert.AreEqual(DependencyProperty.UnsetValue, strokes, "initial strokes is not set");

            // now try ClearValue
            ink.ClearValue(InkPresenter.StrokesProperty);

            // check that ReadLocalValue returns unset
            rlv_strokes = ink.ReadLocalValue(InkPresenter.StrokesProperty);
            Assert.AreEqual(DependencyProperty.UnsetValue, rlv_strokes, "ReadLocalValue after ClearValue is unset");

            // check that GetValue returns a StrokeCollection
            new_strokes = ink.GetValue(InkPresenter.StrokesProperty);
            Assert.AreNotEqual(DependencyProperty.UnsetValue, new_strokes, "GetValue after a ClearValue is set");
            Assert.IsNotNull(new_strokes as StrokeCollection, "GetValue after a ClearValue does not return null");

            // check that ReadLocalValue still returns unset
            rlv_strokes = ink.ReadLocalValue(InkPresenter.StrokesProperty);
            Assert.AreEqual(DependencyProperty.UnsetValue, rlv_strokes, "ReadLocalValue after a GetValue still returns unset");

            // add a stroke
            strokes = new_strokes;
            ((StrokeCollection)strokes).Add(new Stroke());

            // check that ReadLocalValue still returns unset
            rlv_strokes = ink.ReadLocalValue(InkPresenter.StrokesProperty);
            Assert.AreEqual(DependencyProperty.UnsetValue, rlv_strokes, "ReadLocalValue after adding a stroke still returns unset");

            // check that GetValue still returns the same StrokeCollection
            new_strokes = ink.GetValue(InkPresenter.StrokesProperty);
            Assert.AreEqual(strokes, new_strokes, "strokes are the same");

            // set the strokes to something
            strokes = ink.Strokes = new StrokeCollection();

            // check that ReadLocalValue doesn't return unset anymore
            rlv_strokes = ink.ReadLocalValue(InkPresenter.StrokesProperty);
            Assert.AreEqual(strokes, rlv_strokes, "ReadLocalValue returned the strokes we just set on it");
        }