Exemplo n.º 1
0
        public void CreateViewForModelDoesNotComplainIfNoInitializeComponentMethod()
        {
            var view        = new UIElement();
            var viewManager = new LocatingViewManager(type => view, new List <Assembly>());

            viewManager.LocatedViewType = typeof(UIElement);

            var returnedView = viewManager.CreateAndBindViewForModelIfNecessary(new object());

            Assert.AreEqual(view, returnedView);
        }
Exemplo n.º 2
0
        public void CreateAndBindViewForModelIfNecessaryCallsFetchesViewAndCallsInitializeComponent()
        {
            var view        = new TestView();
            var viewManager = new LocatingViewManager(type => view, new List <Assembly>());

            viewManager.LocatedViewType = typeof(TestView);

            var returnedView = viewManager.CreateAndBindViewForModelIfNecessary(new object());

            Assert.True(view.InitializeComponentCalled);
            Assert.AreEqual(view, returnedView);
        }
Exemplo n.º 3
0
        public void CreateViewForModelIfNecessaryThrowsIfViewIsNotConcreteUIElement()
        {
            var viewManager = new LocatingViewManager(this.config);

            viewManager.LocatedViewType = typeof(I1);
            Assert.Throws <StyletViewLocationException>(() => viewManager.CreateAndBindViewForModelIfNecessary(new object()));

            viewManager.LocatedViewType = typeof(AC1);
            Assert.Throws <StyletViewLocationException>(() => viewManager.CreateAndBindViewForModelIfNecessary(new object()));

            viewManager.LocatedViewType = typeof(C1);
            Assert.Throws <StyletViewLocationException>(() => viewManager.CreateAndBindViewForModelIfNecessary(new object()));
        }
Exemplo n.º 4
0
        public void CreateViewForModelDoesNotComplainIfNoInitializeComponentMethod()
        {
            var view = new UIElement();
            var viewManager = new LocatingViewManager(type => view, new List<Assembly>());
            viewManager.LocatedViewType = typeof(UIElement);

            var returnedView = viewManager.CreateAndBindViewForModelIfNecessary(new object());

            Assert.AreEqual(view, returnedView);
        }
Exemplo n.º 5
0
        public void CreateAndBindViewForModelIfNecessaryCallsFetchesViewAndCallsInitializeComponent()
        {
            var view = new TestView();
            var viewManager = new LocatingViewManager(type => view, new List<Assembly>());
            viewManager.LocatedViewType = typeof(TestView);

            var returnedView = viewManager.CreateAndBindViewForModelIfNecessary(new object());

            Assert.True(view.InitializeComponentCalled);
            Assert.AreEqual(view, returnedView);
        }
Exemplo n.º 6
0
        public void CreateViewForModelIfNecessaryThrowsIfViewIsNotConcreteUIElement()
        {
            var viewManager = new LocatingViewManager(type => null, new List<Assembly>());

            viewManager.LocatedViewType = typeof(I1);
            Assert.Throws<StyletViewLocationException>(() => viewManager.CreateAndBindViewForModelIfNecessary(new object()));

            viewManager.LocatedViewType = typeof(AC1);
            Assert.Throws<StyletViewLocationException>(() => viewManager.CreateAndBindViewForModelIfNecessary(new object()));

            viewManager.LocatedViewType = typeof(C1);
            Assert.Throws<StyletViewLocationException>(() => viewManager.CreateAndBindViewForModelIfNecessary(new object()));
        }