public void TriggerInvokesCallbacksAfterProcessingReceivedNotifications() { string notificationReceived = "Foo"; var callbackInvoked = 0; var callbackCallsWhenNotificationIsHandled = 0; var page = new PhoneApplicationPage(); var myNotificationAwareObject = new MyNotificationAwareClass(); var binding = new Binding("InteractionRequest") { Source = myNotificationAwareObject, Mode = BindingMode.OneWay }; var trigger = new MyTriggerClass { RequestBinding = binding, NotifyAction = c => { notificationReceived = c.Title; callbackCallsWhenNotificationIsHandled = callbackInvoked; } }; Interaction.GetBehaviors(page).Add(trigger); var initialState = notificationReceived; myNotificationAwareObject.InteractionRequest.Raise(new Notification { Title = "Bar" }, n => callbackInvoked++); var barState = notificationReceived; myNotificationAwareObject.InteractionRequest.Raise(new Notification { Title = "Finish" }, n => callbackInvoked++); var finalState = notificationReceived; Assert.AreEqual("Foo", initialState); Assert.AreEqual("Bar", barState); Assert.AreEqual("Finish", finalState); Assert.AreEqual(2, callbackInvoked); Assert.AreEqual(1, callbackCallsWhenNotificationIsHandled); }
public void TriggerReceivesNotificationsFromBindedInteractionRequest() { string notificationReceived = "Foo"; var page = new PhoneApplicationPage(); var myNotificationAwareObject = new MyNotificationAwareClass(); var binding = new Binding("InteractionRequest") { Source = myNotificationAwareObject, Mode = BindingMode.OneWay }; var trigger = new MyTriggerClass { RequestBinding = binding, NotifyAction = c => notificationReceived = c.Title, }; Interaction.GetBehaviors(page).Add(trigger); var initialState = notificationReceived; myNotificationAwareObject.InteractionRequest.Raise(new Notification { Title = "Bar" }); var barState = notificationReceived; myNotificationAwareObject.InteractionRequest.Raise(new Notification { Title = "Finish" }); var finalState = notificationReceived; Assert.AreEqual("Foo", initialState); Assert.AreEqual("Bar", barState); Assert.AreEqual("Finish", finalState); }