public void GetActualServiceTest1() { var b = new ConfirmationBehavior(); var service = CreateMessageService(); b.MessageBoxService = service; Assert.AreEqual(service, b.GetActualService()); }
public void GetActualServiceTest2() { UserControl root = new UserControl(); var service = CreateMessageService(); Interaction.GetBehaviors(root).Add(service); var viewModel = new TestViewModelBase(); root.DataContext = viewModel; Button button = new Button(); var b = new ConfirmationBehavior(); Interaction.GetBehaviors(button).Add(b); root.Content = button; Assert.AreEqual(service, viewModel.MessageBoxService); Assert.AreEqual(service, b.GetActualService()); }
public void GetActualServiceTest4() { UserControl root = new UserControl(); var service = CreateMessageService(); Interaction.GetBehaviors(root).Add(service); Button button = new Button(); var b = new ConfirmationBehavior(); Interaction.GetBehaviors(button).Add(b); root.DataContext = new object(); root.Content = button; var viewModel = new TestViewModelBase(); button.DataContext = viewModel; var service2 = b.GetActualService(); var service3 = b.GetActualService(); Assert.IsNotNull(viewModel.MessageBoxService); Assert.AreNotEqual(service, service2); Assert.AreEqual(service2, service3); b.MessageBoxService = service; Assert.AreEqual(service, b.GetActualService()); }
public void GetActualServiceTest3() { UserControl root = new UserControl(); var viewModel = new TestViewModelBase(); root.DataContext = viewModel; Button button = new Button(); var b = new ConfirmationBehavior(); Interaction.GetBehaviors(button).Add(b); root.Content = button; var service = b.GetActualService(); var service2 = b.GetActualService(); var service3 = Interaction.GetBehaviors(button).First(x => x is IMessageBoxService); Assert.AreEqual(service, service2); Assert.AreEqual(service, service3); }