コード例 #1
0
ファイル: ObserverTest.cs プロジェクト: guidgets/XamlGrid
        public void ObserverAccessors()
        {
            // Create observer with null args, then
               			// use accessors to set notification method and context
            IObserver observer = new Observer(null, null);
            observer.NotifyContext = this;
               			observer.NotifyMethod = this.observerTestMethod;

               			// create a test event, setting a payload value and notify
               			// the observer with it. since the observer is this class
               			// and the notification method is observerTestMethod,
               			// successful notification will result in our local
               			// observerTestVar being set to the value we pass in
               			// on the note body.
               			INotification note = new Notification(1, 10);
            observer.NotifyObserver(note);

            // test assertions
               			Assert.IsTrue(observerTestVar == 10, "Expecting observerTestVar = 10");
        }
コード例 #2
0
ファイル: ObserverTest.cs プロジェクト: guidgets/XamlGrid
        public void ObserverConstructor()
        {
            // Create observer passing in notification method and context
            IObserver observer = new Observer(this.observerTestMethod, this);

               			// create a test note, setting a body value and notify
               			// the observer with it. since the observer is this class
               			// and the notification method is observerTestMethod,
               			// successful notification will result in our local
               			// observerTestVar being set to the value we pass in
               			// on the note body.
               			INotification note = new Notification(1, 5);
            observer.NotifyObserver(note);

            // test assertions
               			Assert.IsTrue(observerTestVar == 5, "Expecting observerTestVar = 5");
        }