Beispiel #1
0
            public void ReturnsViewForViewEndingWithViewModel(Type viewModelType, string expectedValue)
            {
                var urlLocator = new UrlLocator();
                var resolvedType = urlLocator.ResolveUrl(viewModelType, false);

                Assert.IsNotNull(resolvedType);
                Assert.AreEqual(expectedValue, resolvedType);
            }
Beispiel #2
0
            public void ReturnsViewForViewEndingWithViewModel()
            {
                var urlLocator = new UrlLocator();
                var resolvedType = urlLocator.ResolveUrl(typeof(PersonViewModel), false);

                Assert.IsNotNull(resolvedType);
                Assert.AreEqual("/Views/Person.xaml", resolvedType);
            }
Beispiel #3
0
            public void OverwritesExistingViewType()
            {
                var urlLocator = new UrlLocator();
                urlLocator.Register(typeof(NoNamingConventionViewModel2), "/Views/NoNaming1.xaml");
                urlLocator.Register(typeof(NoNamingConventionViewModel2), "/App.xaml");

                var resolvedUri = urlLocator.ResolveUrl(typeof(NoNamingConventionViewModel2), false);
                Assert.AreEqual("/App.xaml", resolvedUri);
            }
Beispiel #4
0
            public void RegistersNonExistingViewType()
            {
                var urlLocator = new UrlLocator();

                Assert.IsNull(urlLocator.ResolveUrl(typeof(FollowingNoNamingConventionView)));

                urlLocator.Register(typeof(NoNamingConventionViewModel), "/App.xaml");

                var resolvedUri = urlLocator.ResolveUrl(typeof(NoNamingConventionViewModel));
                Assert.AreEqual("/App.xaml", resolvedUri);
            }
Beispiel #5
0
            public void ResolvesViewFromCache()
            {
                var urlLocator = new UrlLocator();
                var resolvedType = urlLocator.ResolveUrl(typeof(PersonViewModel), false);

                Assert.IsNotNull(resolvedType);
                Assert.AreEqual("/Views/Person.xaml", resolvedType);

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

                resolvedType = urlLocator.ResolveUrl(typeof(PersonViewModel), false);

                Assert.IsNotNull(resolvedType);
                Assert.AreEqual("/Views/Person.xaml", resolvedType);
            }
Beispiel #6
0
 public void ThrowsArgumentNullExceptionForNullViewType()
 {
     var urlLocator = new UrlLocator();
     ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => urlLocator.ResolveUrl(null));
 }
Beispiel #7
0
 public void ThrowsArgumentNullExceptionForNullResolvedType()
 {
     var urlLocator = new UrlLocator();
     ExceptionTester.CallMethodAndExpectException<ArgumentException>(() => urlLocator.Register(typeof(NoNamingConventionViewModel), null));
     ExceptionTester.CallMethodAndExpectException<ArgumentException>(() => urlLocator.Register(typeof(NoNamingConventionViewModel), string.Empty));
 }
Beispiel #8
0
 public void ThrowsArgumentNullExceptionForNullTypeToResolve()
 {
     var urlLocator = new UrlLocator();
     ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => urlLocator.Register(null, "/Views/PersonView.xaml"));
 }
Beispiel #9
0
            public void ClearsTheCache()
            {
                var urlLocator = new UrlLocator();
                var resolvedUrl = urlLocator.ResolveUrl(typeof(PersonViewModel), false);

                Assert.IsNotNull(resolvedUrl);
                Assert.AreEqual("/Views/Person.xaml", resolvedUrl);

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

                resolvedUrl = urlLocator.ResolveUrl(typeof(PersonViewModel), false);

                Assert.IsNotNull(resolvedUrl);
                Assert.AreEqual("/Views/Person.xaml", resolvedUrl);

                // Clear the cache, now it should break
                urlLocator.ClearCache();

                resolvedUrl = urlLocator.ResolveUrl(typeof(PersonViewModel), false);

                Assert.IsNull(resolvedUrl);
            }