public async Task OneByOneClosingStrategyClosesClosableItemsWhenCanCloseIsFalse() { // OneByOneClosingStrategy expected behavior: // - Close all items that can be closed, starting with the last item and moving back. // - Break on the first item that can't be closed and activate it (makes user aware). var conductor = new Conductor <IScreen> .Collection.AllActive { CloseStrategy = new OneByOneCloseStrategy <IScreen>() }; var notClosable = new StateScreen { IsClosable = false }; var closable = new StateScreen { IsClosable = true }; // Last item is closable, the one before that is not, so only last item will be closed. conductor.Items.Add(notClosable); conductor.Items.Add(closable); await((IActivate)conductor).ActivateAsync(CancellationToken.None); var canClose = await conductor.CanCloseAsync(CancellationToken.None); Assert.False(canClose); Assert.True(closable.IsClosed); Assert.False(closable.IsActive); Assert.False(notClosable.IsClosed); Assert.True(notClosable.IsActive); }
public async Task AllOrNoneClosingStrategyDoesNotCloseClosableItemsWhenCanCloseIsFalse() { // AllOrNoneCloseStrategy expected behavior: // - Close all items if all can be closed and none otherwise. // - ActiveItem is not changed when canClose is false. var conductor = new Conductor <IScreen> .Collection.AllActive { CloseStrategy = new AllOrNoneCloseStrategy <IScreen>() }; var notClosable = new StateScreen { IsClosable = false }; var closable = new StateScreen { IsClosable = true }; // Last item is closable, the one before that is not, so no items will be closed. conductor.Items.Add(notClosable); conductor.Items.Add(closable); await((IActivate)conductor).ActivateAsync(CancellationToken.None); var canClose = await conductor.CanCloseAsync(CancellationToken.None); Assert.False(canClose); Assert.False(closable.IsClosed); Assert.True(closable.IsActive); Assert.False(notClosable.IsClosed); Assert.True(notClosable.IsActive); }
public async Task CanCloseIsFalseWhenSomeItemsAreNotClosable() { var conductor = new Conductor <IScreen> .Collection.OneActive { CloseStrategy = new OneByOneCloseStrategy <IScreen>() }; var conducted = new StateScreen { IsClosable = false }; conductor.Items.Add(conducted); await((IActivate)conductor).ActivateAsync(CancellationToken.None); var canClose = await conductor.CanCloseAsync(CancellationToken.None); Assert.False(canClose); }
public async Task CanCloseIsTrueWhenItemsAreClosable() { var conductor = new Conductor <IScreen> .Collection.OneActive(); var conducted = new StateScreen { IsClosable = true }; conductor.Items.Add(conducted); await((IActivate)conductor).ActivateAsync(CancellationToken.None); var canClose = await conductor.CanCloseAsync(CancellationToken.None); Assert.True(canClose); Assert.False(conducted.IsClosed); }
public async Task CanCloseIsTrueWhenItemsAreNotClosableAndCloseStrategyCloses() { var conductor = new Conductor <IScreen> .Collection.OneActive { CloseStrategy = new DefaultCloseStrategy <IScreen>(true) }; var conducted = new StateScreen { IsClosable = true }; conductor.Items.Add(conducted); await((IActivate)conductor).ActivateAsync(CancellationToken.None); var canClose = await conductor.CanCloseAsync(CancellationToken.None); Assert.True(canClose); Assert.True(conducted.IsClosed); }