Пример #1
0
        public void WireViewModel_AssemblyQualifiedName_UsesSpecifiedName()
        {
            //Don't test the ioc
            var mockIoc = new Mock <IIoc>();

            mockIoc.Setup(m => m.Resolve(typeof(TestAssembly.SpecificViewModel))).Returns(new TestAssembly.SpecificViewModel());
            ViewModelLocator.Ioc = mockIoc.Object;

            var view = new EmptyPage();

            //Act
            ViewModelLocator.WireViewModel(view, typeof(TestAssembly.SpecificViewModel).AssemblyQualifiedName);

            Assert.IsType <TestAssembly.SpecificViewModel>(view.BindingContext);
            Assert.Contains(", ZenMvvm.TestAssembly", view.BindingContext.GetType().AssemblyQualifiedName);
            Assert.Contains(".Views", view.GetType().FullName);

            ViewModelLocator.Ioc = null;
        }
Пример #2
0
        public void WireViewModel_Name_UsesNameSpaceNamingConventionOnly()
        {
            //Don't test the ioc
            var mockIoc = new Mock <IIoc>();

            mockIoc.Setup(m => m.Resolve(typeof(ImplementsBaseViewModel))).Returns(new ImplementsBaseViewModel());
            ViewModelLocator.Ioc = mockIoc.Object;

            var view = new EmptyPage();

            //Act
            ViewModelLocator.WireViewModel(view, nameof(ImplementsBaseViewModel));

            Assert.IsType <ImplementsBaseViewModel>(view.BindingContext);
            Assert.Contains(".ViewModels", view.BindingContext.GetType().FullName);
            Assert.Contains(".Views", view.GetType().FullName);

            ViewModelLocator.Ioc = null;
        }