示例#1
0
        public void When_view_added_to_registry_should_ask_layout_if_it_can_accept_view()
        {
            MockRepository  mocks         = new MockRepository();
            ILayout         stubbedLayout = mocks.Stub <ILayout>();
            ILayoutSelector mockSelector  = mocks.CreateMock <ILayoutSelector>();
            DemoView        view          = new DemoView();

            using (mocks.Record())
            {
                SetupResult.For(stubbedLayout.Name).Return("something");

                Expect.Call(mockSelector.CanAccept(stubbedLayout, view)).Return(false);
            }

            using (mocks.Playback())
            {
                DefaultLayoutRegistry registry = new DefaultLayoutRegistry(null, mockSelector);
                registry.Register(stubbedLayout);
                registry.AddView(view);
            }
        }
示例#2
0
        public void When_layout_says_that_it_can_accept_view_registry_should_add_view_to_layout()
        {
            MockRepository  mocks        = new MockRepository();
            ILayout         mockLayout   = mocks.CreateMock <ILayout>();
            ILayoutSelector mockSelector = mocks.Stub <ILayoutSelector>();
            DemoView        view         = new DemoView();

            using (mocks.Record())
            {
                SetupResult.For(mockLayout.Name).Return("something");

                Expect.Call(mockSelector.CanAccept(mockLayout, view)).Return(true);
                Expect.Call(delegate { mockLayout.AddView(view); });
            }

            using (mocks.Playback())
            {
                DefaultLayoutRegistry registry = new DefaultLayoutRegistry(null, mockSelector);
                registry.Register(mockLayout);
                registry.AddView(view);
            }
        }