public void Register(FrameworkElement frameworkElement) { ILayout layout = layoutDeocratorResolver.GetLayoutDecoratorFor(frameworkElement); if (layout == null) { return; } Register(layout); }
public void When_registering_using_framework_element_will_add_layout_decorator_for_that_element() { var panel = new DockPanel { Name = "Demo" }; MockRepository mocks = new MockRepository(); ILayoutDecoratorResolver mockLayoutDecoratorResolver = mocks.CreateMock <ILayoutDecoratorResolver>(); using (mocks.Record()) { SetupResult.For(mockLayoutDecoratorResolver.GetLayoutDecoratorFor(panel)) .Return(new DemoLayout()); } using (mocks.Playback()) { DefaultLayoutRegistry registry = new DefaultLayoutRegistry(mockLayoutDecoratorResolver, null); registry.Register(panel); Assert.IsNotNull(registry.GetLayout("Demo")); } }
public void When_trying_to_register_framework_element_that_has_no_configured_layout_will_ignore_the_registration() { var panel = new DockPanel { Name = "Demo" }; MockRepository mocks = new MockRepository(); ILayoutDecoratorResolver mockLayoutDecoratorResolver = mocks.CreateMock <ILayoutDecoratorResolver>(); using (mocks.Record()) { SetupResult.For(mockLayoutDecoratorResolver.GetLayoutDecoratorFor(panel)) .Return(null); } using (mocks.Playback()) { DefaultLayoutRegistry registry = new DefaultLayoutRegistry(mockLayoutDecoratorResolver, null); registry.Register(panel); registry.GetLayout("Demo"); } }