public void Bounds_Should_Be_Set_After_Layout_Pass() { using (Locator.CurrentMutable.WithResolver()) { this.RegisterServices(); Locator.CurrentMutable.RegisterConstant(new LayoutManager(), typeof(ILayoutManager)); var impl = new Mock<ITopLevelImpl>(); impl.SetupProperty(x => x.ClientSize); impl.SetupProperty(x => x.Resized); var target = new TestTopLevel(impl.Object) { Template = new ControlTemplate<TestTopLevel>(x => new ContentPresenter { [~ContentPresenter.ContentProperty] = x[~TestTopLevel.ContentProperty], }), Content = new TextBlock { Width = 321, Height = 432, } }; target.LayoutManager.ExecuteLayoutPass(); Assert.Equal(new Rect(0, 0, 321, 432), target.Bounds); } }
public void Height_Should_Not_Be_Set_On_Construction() { using (UnitTestApplication.Start(TestServices.StyledWindow)) { var impl = new Mock<ITopLevelImpl>(); impl.Setup(x => x.ClientSize).Returns(new Size(123, 456)); var target = new TestTopLevel(impl.Object); Assert.Equal(double.NaN, target.Height); } }
public void Activate_Should_Call_Impl_Activate() { using (Locator.CurrentMutable.WithResolver()) { this.RegisterServices(); var impl = new Mock<ITopLevelImpl>(); var target = new TestTopLevel(impl.Object); target.Activate(); impl.Verify(x => x.Activate()); } }
public void Width_Should_Not_Be_Set_On_Construction() { using (Locator.CurrentMutable.WithResolver()) { RegisterServices(); var impl = new Mock<ITopLevelImpl>(); impl.Setup(x => x.ClientSize).Returns(new Size(123, 456)); var target = new TestTopLevel(impl.Object); Assert.Equal(double.NaN, target.Width); } }
public void Width_Should_Not_Be_Set_On_Construction() { using (Locator.CurrentMutable.WithResolver()) { RegisterServices(); var impl = new Mock <ITopLevelImpl>(); impl.Setup(x => x.ClientSize).Returns(new Size(123, 456)); var target = new TestTopLevel(impl.Object); Assert.Equal(double.NaN, target.Width); } }
public void Layout_Pass_Should_Not_Be_Automatically_Scheduled() { var services = TestServices.StyledWindow.With(layoutManager: Mock.Of<ILayoutManager>()); using (UnitTestApplication.Start(services)) { var impl = new Mock<ITopLevelImpl>(); var target = new TestTopLevel(impl.Object); // The layout pass should be scheduled by the derived class. var layoutManagerMock = Mock.Get(LayoutManager.Instance); layoutManagerMock.Verify(x => x.ExecuteLayoutPass(), Times.Never); } }
public void Activate_Should_Call_Impl_Activate() { using (Locator.CurrentMutable.WithResolver()) { RegisterServices(); var impl = new Mock <ITopLevelImpl>(); var target = new TestTopLevel(impl.Object); target.Activate(); impl.Verify(x => x.Activate()); } }
public void Height_Should_Not_Be_Set_On_Construction() { using (PerspexLocator.EnterScope()) { RegisterServices(); var impl = new Mock<ITopLevelImpl>(); impl.Setup(x => x.ClientSize).Returns(new Size(123, 456)); var target = new TestTopLevel(impl.Object); Assert.Equal(double.NaN, target.Height); } }
public void Layout_Pass_Should_Not_Be_Automatically_Scheduled() { using (PerspexLocator.EnterScope()) { RegisterServices(); var impl = new Mock<ITopLevelImpl>(); var target = new TestTopLevel(impl.Object); // The layout pass should be scheduled by the derived class. var layoutManagerMock = Mock.Get(target.LayoutManager); layoutManagerMock.Verify(x => x.ExecuteLayoutPass(), Times.Never); } }
public void Width_And_Height_Should_Not_Be_Set_After_Layout_Pass() { using (UnitTestApplication.Start(TestServices.StyledWindow)) { var impl = new Mock <ITopLevelImpl>(); impl.Setup(x => x.ClientSize).Returns(new Size(123, 456)); var target = new TestTopLevel(impl.Object); target.LayoutManager.ExecuteLayoutPass(); Assert.Equal(double.NaN, target.Width); Assert.Equal(double.NaN, target.Height); } }
public void Activate_Should_Call_Impl_Activate() { using (PerspexLocator.EnterScope()) { RegisterServices(); var impl = new Mock<ITopLevelImpl>(); var target = new TestTopLevel(impl.Object); target.Activate(); impl.Verify(x => x.Activate()); } }
public void Layout_Pass_Should_Not_Be_Automatically_Scheduled() { var services = TestServices.StyledWindow.With(layoutManager: Mock.Of <ILayoutManager>()); using (UnitTestApplication.Start(services)) { var impl = new Mock <ITopLevelImpl>(); var target = new TestTopLevel(impl.Object); // The layout pass should be scheduled by the derived class. var layoutManagerMock = Mock.Get(LayoutManager.Instance); layoutManagerMock.Verify(x => x.ExecuteLayoutPass(), Times.Never); } }
public void Layout_Pass_Should_Not_Be_Automatically_Scheduled() { using (PerspexLocator.EnterScope()) { RegisterServices(); var impl = new Mock <ITopLevelImpl>(); var target = new TestTopLevel(impl.Object); // The layout pass should be scheduled by the derived class. var layoutManagerMock = Mock.Get(target.LayoutManager); layoutManagerMock.Verify(x => x.ExecuteLayoutPass(), Times.Never); } }
public void Height_Should_Not_Be_Set_On_Construction() { using (PerspexLocator.EnterScope()) { RegisterServices(); var impl = new Mock <ITopLevelImpl>(); impl.Setup(x => x.ClientSize).Returns(new Size(123, 456)); var target = new TestTopLevel(impl.Object); Assert.Equal(double.NaN, target.Height); } }
public void Activate_Should_Call_Impl_Activate() { using (PerspexLocator.EnterScope()) { RegisterServices(); var impl = new Mock <ITopLevelImpl>(); var target = new TestTopLevel(impl.Object); target.Activate(); impl.Verify(x => x.Activate()); } }
public void Close_Should_Dispose_LayoutManager() { using (UnitTestApplication.Start(TestServices.StyledWindow)) { var impl = new Mock <ITopLevelImpl>(); impl.SetupAllProperties(); var layoutManager = new Mock <ILayoutManager>(); var target = new TestTopLevel(impl.Object, layoutManager.Object); impl.Object.Closed(); layoutManager.Verify(x => x.Dispose()); } }
public void Adding_Top_Level_As_Child_Should_Throw_Exception() { using (UnitTestApplication.Start(TestServices.StyledWindow)) { var impl = new Mock <ITopLevelImpl>(); impl.SetupAllProperties(); var target = new TestTopLevel(impl.Object); var child = new TestTopLevel(impl.Object); target.Template = CreateTemplate(); target.Content = child; Assert.Throws <InvalidOperationException>(() => target.ApplyTemplate()); } }
public void Adding_Resource_To_Application_Should_Raise_ResourcesChanged() { using (UnitTestApplication.Start(TestServices.StyledWindow)) { var impl = new Mock <ITopLevelImpl>(); impl.SetupAllProperties(); var target = new TestTopLevel(impl.Object); var raised = false; target.ResourcesChanged += (_, __) => raised = true; Application.Current.Resources.Add("foo", "bar"); Assert.True(raised); } }
public void Width_And_Height_Should_Not_Be_Set_After_Layout_Pass() { using (PerspexLocator.EnterScope()) { RegisterServices(); var impl = new Mock <ITopLevelImpl>(); impl.Setup(x => x.ClientSize).Returns(new Size(123, 456)); var target = new TestTopLevel(impl.Object); target.LayoutManager.ExecuteLayoutPass(); Assert.Equal(double.NaN, target.Width); Assert.Equal(double.NaN, target.Height); } }
public void Close_Should_Notify_MouseDevice() { using (UnitTestApplication.Start(TestServices.StyledWindow)) { var impl = new Mock <ITopLevelImpl>(); var mouseDevice = new Mock <IMouseDevice>(); impl.SetupAllProperties(); impl.Setup(x => x.MouseDevice).Returns(mouseDevice.Object); var target = new TestTopLevel(impl.Object); impl.Object.Closed(); mouseDevice.Verify(x => x.TopLevelClosed(target)); } }
public void Width_And_Height_Should_Be_Set_After_Window_Resize_Notification() { using (UnitTestApplication.Start(TestServices.StyledWindow)) { var impl = new Mock <ITopLevelImpl>(); impl.SetupAllProperties(); impl.Setup(x => x.ClientSize).Returns(new Size(123, 456)); // The user has resized the window, so we can no longer auto-size. var target = new TestTopLevel(impl.Object); impl.Object.Resized(new Size(100, 200)); Assert.Equal(100, target.Width); Assert.Equal(200, target.Height); } }
public void Impl_Close_Should_Call_Raise_Closed_Event() { using (UnitTestApplication.Start(TestServices.StyledWindow)) { var impl = new Mock <ITopLevelImpl>(); impl.SetupAllProperties(); bool raised = false; var target = new TestTopLevel(impl.Object); target.Closed += (s, e) => raised = true; impl.Object.Closed(); Assert.True(raised); } }
public void Adding_Top_Level_As_Child_Should_Throw_Exception() { using (PerspexLocator.EnterScope()) { RegisterServices(); var impl = new Mock <ITopLevelImpl>(); impl.SetupAllProperties(); var target = new TestTopLevel(impl.Object); var child = new TestTopLevel(impl.Object); target.Template = CreateTemplate(); target.Content = child; Assert.Throws <InvalidOperationException>(() => target.ApplyTemplate()); } }
public void Adding_Top_Level_As_Child_Should_Throw_Exception() { using (PerspexLocator.EnterScope()) { RegisterServices(); var impl = new Mock<ITopLevelImpl>(); impl.SetupAllProperties(); var target = new TestTopLevel(impl.Object); var child = new TestTopLevel(impl.Object); target.Template = CreateTemplate(); target.Content = child; Assert.Throws<InvalidOperationException>(() => target.ApplyTemplate()); } }
public void Impl_Close_Should_Call_Raise_Closed_Event() { using (Locator.CurrentMutable.WithResolver()) { RegisterServices(); var impl = new Mock <ITopLevelImpl>(); impl.SetupAllProperties(); bool raised = false; var target = new TestTopLevel(impl.Object); target.Closed += (s, e) => raised = true; impl.Object.Closed(); Assert.True(raised); } }
public void Impl_Deactivate_Should_Call_Raise_Activated_Event() { using (PerspexLocator.EnterScope()) { RegisterServices(); var impl = new Mock <ITopLevelImpl>(); impl.SetupAllProperties(); bool raised = false; var target = new TestTopLevel(impl.Object); target.Deactivated += (s, e) => raised = true; impl.Object.Deactivated(); Assert.True(raised); } }
public void Width_And_Height_Should_Be_Set_After_Window_Resize_Notification() { using (Locator.CurrentMutable.WithResolver()) { RegisterServices(); var impl = new Mock <ITopLevelImpl>(); impl.SetupAllProperties(); impl.Setup(x => x.ClientSize).Returns(new Size(123, 456)); // The user has resized the window, so we can no longer auto-size. var target = new TestTopLevel(impl.Object); impl.Object.Resized(new Size(100, 200)); Assert.Equal(100, target.Width); Assert.Equal(200, target.Height); } }
public void Render_Should_Be_Scheduled_After_Layout_Pass() { using (PerspexLocator.EnterScope()) { RegisterServices(); var completed = new Subject <Unit>(); var layoutManagerMock = Mock.Get(PerspexLocator.Current.GetService <ILayoutManager>()); layoutManagerMock.Setup(x => x.LayoutCompleted).Returns(completed); var impl = new Mock <ITopLevelImpl>(); impl.Setup(x => x.ClientSize).Returns(new Size(123, 456)); var target = new TestTopLevel(impl.Object); completed.OnNext(Unit.Default); var renderManagerMock = Mock.Get(PerspexLocator.Current.GetService <IRenderQueueManager>()); renderManagerMock.Verify(x => x.InvalidateRender(target)); } }
public void Impl_Input_Should_Pass_Input_To_InputManager() { using (PerspexLocator.EnterScope()) { RegisterServices(); var impl = new Mock <ITopLevelImpl>(); impl.SetupAllProperties(); var target = new TestTopLevel(impl.Object); var input = new RawKeyEventArgs( new Mock <IKeyboardDevice>().Object, 0, RawKeyEventType.KeyDown, Key.A, InputModifiers.None); impl.Object.Input(input); var inputManagerMock = Mock.Get(InputManager.Instance); inputManagerMock.Verify(x => x.Process(input)); } }
public void Impl_ClientSize_Should_Be_Set_After_Layout_Pass() { using (UnitTestApplication.Start(TestServices.StyledWindow)) { var impl = Mock.Of <ITopLevelImpl>(x => x.Scaling == 1); var target = new TestTopLevel(impl) { Template = CreateTemplate(), Content = new TextBlock { Width = 321, Height = 432, } }; LayoutManager.Instance.ExecuteInitialLayoutPass(target); Mock.Get(impl).VerifySet(x => x.ClientSize = new Size(321, 432)); } }
public void Impl_Input_Should_Pass_Input_To_InputManager() { var inputManagerMock = new Mock <IInputManager>(); var services = TestServices.StyledWindow.With(inputManager: inputManagerMock.Object); using (UnitTestApplication.Start(services)) { var impl = new Mock <ITopLevelImpl>(); impl.SetupAllProperties(); var target = new TestTopLevel(impl.Object); var input = new RawKeyEventArgs( new Mock <IKeyboardDevice>().Object, 0, RawKeyEventType.KeyDown, Key.A, InputModifiers.None); impl.Object.Input(input); inputManagerMock.Verify(x => x.ProcessInput(input)); } }
public void Reacts_To_Changes_In_Global_Styles() { using (UnitTestApplication.Start(TestServices.StyledWindow)) { var impl = new Mock <ITopLevelImpl>(); impl.SetupGet(x => x.Scaling).Returns(1); var child = new Border { Classes = { "foo" } }; var target = new TestTopLevel(impl.Object) { Template = CreateTemplate(), Content = child, }; target.LayoutManager.ExecuteInitialLayoutPass(target); Assert.Equal(new Thickness(0), child.BorderThickness); var style = new Style(x => x.OfType <Border>().Class("foo")) { Setters = { new Setter(Border.BorderThicknessProperty, new Thickness(2)) } }; Application.Current.Styles.Add(style); target.LayoutManager.ExecuteInitialLayoutPass(target); Assert.Equal(new Thickness(2), child.BorderThickness); Application.Current.Styles.Remove(style); Assert.Equal(new Thickness(0), child.BorderThickness); } }
public void Bounds_Should_Be_Set_After_Layout_Pass() { using (UnitTestApplication.Start(TestServices.StyledWindow)) { var impl = new Mock <ITopLevelImpl>(); impl.SetupProperty(x => x.Resized); impl.SetupGet(x => x.Scaling).Returns(1); var target = new TestTopLevel(impl.Object) { Template = CreateTemplate(), Content = new TextBlock { Width = 321, Height = 432, } }; LayoutManager.Instance.ExecuteInitialLayoutPass(target); Assert.Equal(new Rect(0, 0, 321, 432), target.Bounds); } }
public void Impl_Close_Should_Raise_DetachedFromLogicalTree_Event() { using (UnitTestApplication.Start(TestServices.StyledWindow)) { var impl = new Mock <ITopLevelImpl>(); impl.SetupAllProperties(); var target = new TestTopLevel(impl.Object); var raised = 0; target.DetachedFromLogicalTree += (s, e) => { Assert.Same(target, e.Root); Assert.Same(target, e.Source); Assert.Null(e.Parent); ++raised; }; impl.Object.Closed(); Assert.Equal(1, raised); } }
public void Impl_ClientSize_Should_Be_Set_After_Layout_Pass() { using (PerspexLocator.EnterScope()) { RegisterServices(); PerspexLocator.CurrentMutable.Bind <ILayoutManager>().ToConstant(new LayoutManager()); var impl = new Mock <ITopLevelImpl>(); var target = new TestTopLevel(impl.Object) { Template = CreateTemplate(), Content = new TextBlock { Width = 321, Height = 432, } }; target.LayoutManager.ExecuteLayoutPass(); impl.VerifySet(x => x.ClientSize = new Size(321, 432)); } }
public void Render_Should_Be_Scheduled_After_Layout_Pass() { using (Locator.CurrentMutable.WithResolver()) { this.RegisterServices(); var completed = new Subject<Unit>(); var layoutManagerMock = Mock.Get(Locator.Current.GetService<ILayoutManager>()); layoutManagerMock.Setup(x => x.LayoutCompleted).Returns(completed); var impl = new Mock<ITopLevelImpl>(); impl.Setup(x => x.ClientSize).Returns(new Size(123, 456)); var target = new TestTopLevel(impl.Object); completed.OnNext(Unit.Default); var renderManagerMock = Mock.Get(Locator.Current.GetService<IRenderManager>()); renderManagerMock.Verify(x => x.InvalidateRender(target)); } }
public void Impl_Deactivate_Should_Call_Raise_Activated_Event() { using (Locator.CurrentMutable.WithResolver()) { this.RegisterServices(); var impl = new Mock<ITopLevelImpl>(); impl.SetupAllProperties(); bool raised = false; var target = new TestTopLevel(impl.Object); target.Deactivated += (s, e) => raised = true; impl.Object.Deactivated(); Assert.True(raised); } }
public void Impl_Input_Should_Pass_Input_To_InputManager() { using (Locator.CurrentMutable.WithResolver()) { this.RegisterServices(); var impl = new Mock<ITopLevelImpl>(); impl.SetupAllProperties(); var target = new TestTopLevel(impl.Object); var input = new RawKeyEventArgs( new Mock<IKeyboardDevice>().Object, 0, RawKeyEventType.KeyDown, Key.A, "A"); impl.Object.Input(input); var inputManagerMock = Mock.Get(InputManager.Instance); inputManagerMock.Verify(x => x.Process(input)); } }
public void Bounds_Should_Be_Set_After_Layout_Pass() { using (PerspexLocator.EnterScope()) { RegisterServices(); PerspexLocator.CurrentMutable.Bind<ILayoutManager>().ToConstant(new LayoutManager()); var impl = new Mock<ITopLevelImpl>(); impl.SetupProperty(x => x.ClientSize); impl.SetupProperty(x => x.Resized); var target = new TestTopLevel(impl.Object) { Template = CreateTemplate(), Content = new TextBlock { Width = 321, Height = 432, } }; target.LayoutManager.ExecuteLayoutPass(); Assert.Equal(new Rect(0, 0, 321, 432), target.Bounds); } }
public void Bounds_Should_Be_Set_After_Layout_Pass() { using (UnitTestApplication.Start(TestServices.StyledWindow)) { var impl = new Mock<ITopLevelImpl>(); impl.SetupProperty(x => x.ClientSize); impl.SetupProperty(x => x.Resized); impl.SetupGet(x => x.Scaling).Returns(1); var target = new TestTopLevel(impl.Object) { Template = CreateTemplate(), Content = new TextBlock { Width = 321, Height = 432, } }; LayoutManager.Instance.ExecuteInitialLayoutPass(target); Assert.Equal(new Rect(0, 0, 321, 432), target.Bounds); } }
public void Impl_ClientSize_Should_Be_Set_After_Layout_Pass() { using (PerspexLocator.EnterScope()) { RegisterServices(); PerspexLocator.CurrentMutable.Bind<ILayoutManager>().ToConstant(new LayoutManager()); var impl = new Mock<ITopLevelImpl>(); var target = new TestTopLevel(impl.Object) { Template = CreateTemplate(), Content = new TextBlock { Width = 321, Height = 432, } }; target.LayoutManager.ExecuteLayoutPass(); impl.VerifySet(x => x.ClientSize = new Size(321, 432)); } }
public void Impl_ClientSize_Should_Be_Set_After_Layout_Pass() { using (Locator.CurrentMutable.WithResolver()) { this.RegisterServices(); Locator.CurrentMutable.RegisterConstant(new LayoutManager(), typeof(ILayoutManager)); var impl = new Mock<ITopLevelImpl>(); var target = new TestTopLevel(impl.Object) { Template = ControlTemplate.Create<TestTopLevel>(x => new ContentPresenter { [~ContentPresenter.ContentProperty] = x[~TestTopLevel.ContentProperty], }), Content = new TextBlock { Width = 321, Height = 432, } }; target.LayoutManager.ExecuteLayoutPass(); impl.VerifySet(x => x.ClientSize = new Size(321, 432)); } }
public void Impl_Input_Should_Pass_Input_To_InputManager() { using (PerspexLocator.EnterScope()) { RegisterServices(); var impl = new Mock<ITopLevelImpl>(); impl.SetupAllProperties(); var target = new TestTopLevel(impl.Object); var input = new RawKeyEventArgs( new Mock<IKeyboardDevice>().Object, 0, RawKeyEventType.KeyDown, Key.A, InputModifiers.None); impl.Object.Input(input); var inputManagerMock = Mock.Get(InputManager.Instance); inputManagerMock.Verify(x => x.Process(input)); } }
public void Adding_Top_Level_As_Child_Should_Throw_Exception() { using (UnitTestApplication.Start(TestServices.StyledWindow)) { var impl = new Mock<ITopLevelImpl>(); impl.SetupAllProperties(); var target = new TestTopLevel(impl.Object); var child = new TestTopLevel(impl.Object); target.Template = CreateTemplate(); target.Content = child; Assert.Throws<InvalidOperationException>(() => target.ApplyTemplate()); } }
public void Activate_Should_Call_Impl_Activate() { using (UnitTestApplication.Start(TestServices.StyledWindow)) { var impl = new Mock<ITopLevelImpl>(); var target = new TestTopLevel(impl.Object); target.Activate(); impl.Verify(x => x.Activate()); } }
public void Width_And_Height_Should_Not_Be_Set_After_Layout_Pass() { using (PerspexLocator.EnterScope()) { RegisterServices(); var impl = new Mock<ITopLevelImpl>(); impl.Setup(x => x.ClientSize).Returns(new Size(123, 456)); var target = new TestTopLevel(impl.Object); LayoutManager.Instance.ExecuteLayoutPass(); Assert.Equal(double.NaN, target.Width); Assert.Equal(double.NaN, target.Height); } }
public void Width_And_Height_Should_Be_Set_After_Window_Resize_Notification() { using (UnitTestApplication.Start(TestServices.StyledWindow)) { var impl = new Mock<ITopLevelImpl>(); impl.SetupAllProperties(); impl.Setup(x => x.ClientSize).Returns(new Size(123, 456)); // The user has resized the window, so we can no longer auto-size. var target = new TestTopLevel(impl.Object); impl.Object.Resized(new Size(100, 200)); Assert.Equal(100, target.Width); Assert.Equal(200, target.Height); } }
public void Width_And_Height_Should_Not_Be_Set_After_Layout_Pass() { using (UnitTestApplication.Start(TestServices.StyledWindow)) { var impl = new Mock<ITopLevelImpl>(); impl.Setup(x => x.ClientSize).Returns(new Size(123, 456)); var target = new TestTopLevel(impl.Object); LayoutManager.Instance.ExecuteLayoutPass(); Assert.Equal(double.NaN, target.Width); Assert.Equal(double.NaN, target.Height); } }
public void Impl_ClientSize_Should_Be_Set_After_Layout_Pass() { using (UnitTestApplication.Start(TestServices.StyledWindow)) { var impl = Mock.Of<ITopLevelImpl>(x => x.Scaling == 1); var target = new TestTopLevel(impl) { Template = CreateTemplate(), Content = new TextBlock { Width = 321, Height = 432, } }; LayoutManager.Instance.ExecuteInitialLayoutPass(target); Mock.Get(impl).VerifySet(x => x.ClientSize = new Size(321, 432)); } }
public void Width_And_Height_Should_Be_Set_After_Window_Resize_Notification() { using (Locator.CurrentMutable.WithResolver()) { this.RegisterServices(); var impl = new Mock<ITopLevelImpl>(); impl.SetupAllProperties(); impl.Setup(x => x.ClientSize).Returns(new Size(123, 456)); // The user has resized the window, so we can no longer auto-size. var target = new TestTopLevel(impl.Object); impl.Object.Resized(new Size(100, 200)); Assert.Equal(100, target.Width); Assert.Equal(200, target.Height); } }
public void Exiting_Application_Notifies_Top_Level() { using (UnitTestApplication.Start(TestServices.StyledWindow)) { var impl = new Mock<ITopLevelImpl>(); impl.SetupAllProperties(); var target = new TestTopLevel(impl.Object); UnitTestApplication.Current.Exit(); Assert.True(target.IsClosed); } }
public void Width_And_Height_Should_Not_Be_Set_After_Layout_Pass() { using (Locator.CurrentMutable.WithResolver()) { this.RegisterServices(); var impl = new Mock<ITopLevelImpl>(); impl.Setup(x => x.ClientSize).Returns(new Size(123, 456)); var target = new TestTopLevel(impl.Object); target.LayoutManager.ExecuteLayoutPass(); Assert.Equal(double.NaN, target.Width); Assert.Equal(double.NaN, target.Height); } }
public void Impl_Deactivate_Should_Call_Raise_Activated_Event() { using (PerspexLocator.EnterScope()) { RegisterServices(); var impl = new Mock<ITopLevelImpl>(); impl.SetupAllProperties(); bool raised = false; var target = new TestTopLevel(impl.Object); target.Deactivated += (s, e) => raised = true; impl.Object.Deactivated(); Assert.True(raised); } }
public void Impl_Deactivate_Should_Call_Raise_Activated_Event() { using (UnitTestApplication.Start(TestServices.StyledWindow)) { var impl = new Mock<ITopLevelImpl>(); impl.SetupAllProperties(); bool raised = false; var target = new TestTopLevel(impl.Object); target.Deactivated += (s, e) => raised = true; impl.Object.Deactivated(); Assert.True(raised); } }
public void Impl_Input_Should_Pass_Input_To_InputManager() { var inputManagerMock = new Mock<IInputManager>(); var services = TestServices.StyledWindow.With(inputManager: inputManagerMock.Object); using (UnitTestApplication.Start(services)) { var impl = new Mock<ITopLevelImpl>(); impl.SetupAllProperties(); var target = new TestTopLevel(impl.Object); var input = new RawKeyEventArgs( new Mock<IKeyboardDevice>().Object, 0, RawKeyEventType.KeyDown, Key.A, InputModifiers.None); impl.Object.Input(input); inputManagerMock.Verify(x => x.ProcessInput(input)); } }