Exemple #1
0
        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);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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());
        }