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

                Assert.IsNotNull(resolvedType);
                Assert.AreEqual(typeof(PersonView), resolvedType);
            }
Esempio n. 2
0
            public void RegistersNonExistingViewType()
            {
                var viewLocator = new ViewLocator();

                Assert.IsNull(viewLocator.ResolveView(typeof(FollowingNoNamingConventionView)));

                viewLocator.Register(typeof(FollowingNoNamingConventionView), typeof(NoNamingConventionViewModel));

                var resolvedView = viewLocator.ResolveView(typeof (FollowingNoNamingConventionView));
                Assert.AreEqual(typeof(NoNamingConventionViewModel), resolvedView);
            }
Esempio n. 3
0
            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);
            }
Esempio n. 4
0
            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);
            }
Esempio n. 5
0
 public void ThrowsArgumentNullExceptionForNullViewType()
 {
     var viewLocator = new ViewLocator();
     ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => viewLocator.ResolveView(null));
 }
Esempio n. 6
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);
            }