Inheritance: IRegionViewRegistry
        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
                {
                    GetInstance = t => mockRegionContentRegistry
                });

                var regionManager = new MockRegionManager();

                regionManager.RegisterViewWithRegion("Region1", expectedDelegate);

                Assert.AreEqual("Region1", regionName);
                Assert.AreEqual(expectedDelegate, contentDelegate);
            }
            finally
            {
                ServiceLocator.SetLocatorProvider(null);
            }
        }
Ejemplo 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
                    {
                        GetInstance = t => 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
                {
                    GetInstance = t => mockRegionContentRegistry
                });

                var regionManager = new MockRegionManager();

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

                Assert.AreEqual(regionName, "Region1");
                Assert.AreEqual(viewType, typeof(object));
            }
            finally
            {
                ServiceLocator.SetLocatorProvider(null);
            }
        }
Ejemplo n.º 4
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
                        {
                            GetInstance = t => mockRegionContentRegistry
                        });

                var regionManager = new MockRegionManager();

                regionManager.RegisterViewWithRegion("Region1", expectedDelegate);

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


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