public void CloseAll_ShouldCall_OnlyDialogsWithNoStayOnTop_TryClose() { var builder = new ContainerBuilder(); for (var i = 0; i < 3; i++) { builder.Register(c => Substitute.For <IModal>()).As <IModal>().SingleInstance(); } for (var i = 0; i < 3; i++) { var modal = Substitute.For <IModal>(); modal.StayOnTop.Returns(true); builder.Register(c => modal).As <IModal>().SingleInstance(); } _container = builder.Build(); var modals = new ProtonVPN.Modals.Modals(_scheduler, _container, _windowManager, _modalWindows); modals.CloseAll(); foreach (var modal in _container.Resolve <IEnumerable <IModal> >()) { modal.Received(modal.StayOnTop ? 0 : 1).TryClose(false); } }
public void Close_ShouldCall_Dialog_TryClose(bool?dialogResult) { var modals = new ProtonVPN.Modals.Modals(_scheduler, _container, _windowManager, _modalWindows); modals.Close <WrappedModal>(dialogResult); _modal.Received(1).TryClose(dialogResult); }
public void Show_ShouldCall_Modal_BeforeOpenModal() { var modals = new ProtonVPN.Modals.Modals(_scheduler, _container, _windowManager, _modalWindows); dynamic options = new ExpandoObject(); modals.Show <WrappedModal>(options); _modal.Received(1).BeforeOpenModal(options); }
public void Show_ShouldCall_WindowManager_ShowDialog() { var wrappedModal = _container.Resolve <WrappedModal>(); var modals = new ProtonVPN.Modals.Modals(_scheduler, _container, _windowManager, _modalWindows); modals.Show <WrappedModal>(); _windowManager.Received(1).ShowDialog( wrappedModal, Arg.Is <object>(o => o == null), Arg.Any <IDictionary <string, object> >()); }
public void Show_ShouldCall_WindowManager_ShowDialog_WithDefaultSettings() { var modals = new ProtonVPN.Modals.Modals(_scheduler, _container, _windowManager, _modalWindows); modals.Show <WrappedModal>(); _windowManager.Received(1).ShowDialog( Arg.Any <object>(), Arg.Any <object>(), Arg.Is <IDictionary <string, object> >(d => (WindowStartupLocation)d["WindowStartupLocation"] == WindowStartupLocation.CenterOwner && (ResizeMode)d["ResizeMode"] == ResizeMode.NoResize)); }
public void Show_ShouldReturnFalse_IfAlreadyOpened() { // Arrange var modalViewModel = new WrappedModal(_modal); _modalWindows.List().Returns(new[] { new BaseModalWindow { DataContext = modalViewModel } }); var modals = new ProtonVPN.Modals.Modals(_scheduler, _container, _windowManager, _modalWindows); // Assert modals.Show <WrappedModal>().Should().BeFalse("Modal already opened"); }