Esempio n. 1
0
        public void CanRegisterDelegate()
        {
            try
            {
                var mockRegionContentRegistry = new MockRegionContentRegistry();

                string        regionName      = null;
                Func <object> contentDelegate = null;

                Func <object> expectedDelegate = () => true;
                mockRegionContentRegistry.RegisterContentWithDelegate = (name, usedDelegate) =>
                {
                    regionName      = name;
                    contentDelegate = usedDelegate;
                    return(null);
                };
                ServiceLocator.SetLocatorProvider(
                    () => new MockServiceLocator(
                        () => mockRegionContentRegistry));

                var regionManager = new MockRegionManager();

                regionManager.RegisterViewWithRegion("Region1", expectedDelegate);

                Assert.AreEqual("Region1", regionName);
                Assert.AreEqual(expectedDelegate, contentDelegate);
            }
            finally
            {
                ServiceLocator.SetLocatorProvider(null);
            }
        }
Esempio n. 2
0
        public void CanRegisterViewType()
        {
            try
            {
                var mockRegionContentRegistry = new MockRegionContentRegistry();

                string regionName = null;
                Type   viewType   = null;

                mockRegionContentRegistry.RegisterContentWithViewType = (name, type) =>
                {
                    regionName = name;
                    viewType   = type;
                    return(null);
                };
                ServiceLocator.SetLocatorProvider(
                    () => new MockServiceLocator(
                        () => mockRegionContentRegistry));

                var regionManager = new MockRegionManager();

                regionManager.RegisterViewWithRegion("Region1", typeof(object));

                Assert.AreEqual(regionName, "Region1");
                Assert.AreEqual(viewType, typeof(object));
            }
            finally
            {
                ServiceLocator.SetLocatorProvider(null);
            }
        }
        public void CanRegisterViewType()
        {
            try
            {
                var mockRegionContentRegistry = new MockRegionContentRegistry();

                string regionName = null;
                Type viewType = null;

                mockRegionContentRegistry.RegisterContentWithViewType = (name, type) =>
                                                                            {
                                                                                regionName = name;
                                                                                viewType = type;
                                                                                return null;
                                                                            };
                ServiceLocator.SetLocatorProvider(
                    () => new MockServiceLocator(
                        () => mockRegionContentRegistry));

                var regionManager = new MockRegionManager();

                regionManager.RegisterViewWithRegion("Region1", typeof (object));

                Assert.AreEqual(regionName, "Region1");
                Assert.AreEqual(viewType, typeof(object));
                

            }
            finally
            {
                ServiceLocator.SetLocatorProvider(null);
            }
        }
        public void CanRegisterDelegate()
        {
            try
            {
                var mockRegionContentRegistry = new MockRegionContentRegistry();

                string regionName = null;
                Func<object> contentDelegate = null;

                Func<object> expectedDelegate = () => true;
                mockRegionContentRegistry.RegisterContentWithDelegate = (name, usedDelegate) =>
                {
                    regionName = name;
                    contentDelegate = usedDelegate;
                    return null;
                };
                ServiceLocator.SetLocatorProvider(
                    () => new MockServiceLocator(
                        () => mockRegionContentRegistry));

                var regionManager = new MockRegionManager();

                regionManager.RegisterViewWithRegion("Region1", expectedDelegate);

                Assert.AreEqual("Region1", regionName);
                Assert.AreEqual(expectedDelegate, contentDelegate);


            }
            finally
            {
                ServiceLocator.SetLocatorProvider(null);
            }
        }