public void SetModelOnBaseInterfaceView() { DerivedScreen screen = new DerivedScreen(); BaseScreenView view = new BaseScreenView(); ContentControl cc = new ContentControl { Content = view }; View.SetModel(cc, screen); Assert.AreEqual(screen, view.Model); }
public void SetModelOnMultipleViewInterfaces() { DerivedScreen screen = new DerivedScreen(); MultiScreenView view = new MultiScreenView(); ContentControl cc = new ContentControl { Content = view }; View.SetModel(cc, screen); Assert.AreEqual(screen, view.DerivedScreenModel); Assert.IsNull(view.SimpleScreenModel); Assert.IsNull(view.BaseScreenModel); Assert.IsNull(view.ObjectModel); }
public void SetModelOnContentPresenter() { BaseScreenView view = new BaseScreenView(); var locator = new Mock <IServiceLocator>(MockBehavior.Strict); locator.Setup(x => x.TryGetInstance(typeof(IView <DerivedScreen>))).Returns(null); locator.Setup(x => x.TryGetInstance(typeof(IView <BaseScreen>))).Returns(view); ServiceLocator.SetServiceLocator(locator.Object); DerivedScreen screen = new DerivedScreen(); ContentPresenter cp = new ContentPresenter(); View.SetModel(cp, screen); Assert.AreEqual(view, cp.Content); Assert.AreEqual(screen, view.Model); locator.Verify(x => x.TryGetInstance(typeof(IView <DerivedScreen>)), Times.Once()); locator.Verify(x => x.TryGetInstance(typeof(IView <BaseScreen>)), Times.Once()); }