Exemplo n.º 1
0
        public void CreateCorrectViewType()
        {
            var conn = new TConnector();
            var vm   = new TestViewModel();
            var view = conn.CreateItem(vm);

            Assert.IsNotNull(view);
            Assert.AreEqual(typeof(TestView), view.GetType());
        }
Exemplo n.º 2
0
        public void WarnIfViewDoesNotImplementCorrectInterface()
        {
            var debug = new Mock <IDebug>();

            debug.Setup(d => d.WriteLine("IView<ATZ.MVVM.ViewModels.Utility.Tests.TestViewModel> was successfully resolved, "
                                         + "but it has no interface of IView<IViewModel<ATZ.MVVM.ViewModels.Utility.Tests.TestModel>>!"));
            Assert.IsNotNull(debug.Object);

            DependencyResolver.Initialize(new NinjectStandardKernel());
            DependencyInjection.System.Bindings.Initialize();

            DependencyResolver.Instance.Unbind <IDebug>();
            DependencyResolver.Instance.Bind <IDebug>().ToConstant(debug.Object);

            DependencyResolver.Instance.Bind <IView <TestViewModel> >().To <TestViewWithoutInterface>();

            var conn = new TConnector();
            var vm   = new TestViewModel();
            var view = conn.CreateItem(vm);

            Assert.IsNull(view);
            debug.VerifyAll();
        }