Example #1
1
            public void ReturnsViewForViewEndingWithViewModel()
            {
                var viewLocator = new ViewLocator();
                var resolvedType = viewLocator.ResolveView(typeof(PersonViewModel));

                Assert.IsNotNull(resolvedType);
                Assert.AreEqual(typeof(PersonView), resolvedType);
            }
            public void OverwritesExistingViewType()
            {
                var viewLocator = new ViewLocator();
                viewLocator.Register(typeof(FollowingNoNamingConventionView), typeof(NoNamingConventionViewModel));
                viewLocator.Register(typeof(FollowingNoNamingConventionView), typeof(NoNamingConventionViewModel2));

                var resolvedView = viewLocator.ResolveView(typeof(FollowingNoNamingConventionView));
                Assert.AreEqual(typeof(NoNamingConventionViewModel2), resolvedView);
            }
Example #3
0
            public void ReturnsViewForNamingConventionWithUp()
            {
                var viewLocator = new ViewLocator();
                viewLocator.NamingConventions.Clear();
                viewLocator.NamingConventions.Add("[UP].Views.[VM]View");

                var resolvedType = viewLocator.ResolveView(typeof(PersonViewModel));

                Assert.IsNotNull(resolvedType);
                Assert.AreEqual(typeof(PersonView), resolvedType);
            }
            public void ReturnsViewForViewModel(Type viewModelType, Type viewType, string convention)
            {
                var viewLocator = new ViewLocator();

                if (!string.IsNullOrEmpty(convention))
                {
                    viewLocator.NamingConventions.Clear();
                    viewLocator.NamingConventions.Add(convention);
                }

                var resolvedType = viewLocator.ResolveView(viewModelType);

                Assert.IsNotNull(resolvedType);
                Assert.AreEqual(viewType, resolvedType);
            }
            public void ResolvesViewFromCache()
            {
                var viewLocator = new ViewLocator();
                var resolvedType = viewLocator.ResolveView(typeof(PersonViewModel));

                Assert.IsNotNull(resolvedType);
                Assert.AreEqual(typeof(PersonView), resolvedType);

                // Clear the naming conventions (so it *must* come from the cache)
                viewLocator.NamingConventions.Clear();

                resolvedType = viewLocator.ResolveView(typeof(PersonViewModel));

                Assert.IsNotNull(resolvedType);
                Assert.AreEqual(typeof(PersonView), resolvedType);
            }
 public void ThrowsArgumentNullExceptionForNullViewType()
 {
     var viewLocator = new ViewLocator();
     ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => viewLocator.ResolveView(null));
 }
 public void ThrowsArgumentNullExceptionForNullResolvedType()
 {
     var viewLocator = new ViewLocator();
     ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => viewLocator.Register(typeof(NoNamingConventionViewModel), null));
 }
 public void ThrowsArgumentNullExceptionForNullTypeToResolve()
 {
     var viewLocator = new ViewLocator();
     ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => viewLocator.Register(null, typeof(FollowingNoNamingConventionView)));
 }
Example #9
0
            public void ThrowsArgumentExceptionForWrongServiceType()
            {
                var serviceLocator = new ServiceLocator();
                var serviceType = typeof(IViewModelLocator);
                var serviceInstance = new ViewLocator();

                ExceptionTester.CallMethodAndExpectException<ArgumentException>(() => serviceLocator.RegisterInstance(serviceType, serviceInstance));
            }