TryClose as part of IScreen

Nov 5, 2010 at 1:34 PM

Hi

I am trying to unit test a viewmodel with a command that displays a dialog.

The dialog is making use of a dialogviewmodel which inherits from Screen.

I am currently mocking out the dialogviewmodel, but by code has a call to TryClose which is not exist on any of the IScreen or IGuardClose interfaces.

Would it be possible to get TryClose added to the IScreen or IGuardClose interface (not sure which one is more appropriate)?

Thanks

Dirk

Coordinator
Nov 5, 2010 at 2:12 PM

I added a ticket to consider adding it to IScreen.

Nov 5, 2010 at 4:30 PM
Edited Nov 5, 2010 at 4:31 PM

Maybe having an ICloseable interface and defining IGuardClose as IGuardClose : ICloseable would be better than adding the interface to IScreen directly.

Something like this:

 

/// <summary>
/// Denotes an object that can be closed.
/// </summary>
public interface ICloseable
{
    /// <summary>
    /// Tries to close this instance.
    /// </summary>
    /// <returns><c>True</c> if the close operation was successfull, otherwise <c>false</c>.</returns>
    bool TryClose();
}

/// <summary>
/// Denotes an instance which may prevent closing.
/// </summary>
public interface IGuardClose : ICloseable
{
    /// <summary>
    /// Called to check whether or not this instance can close.
    /// </summary>
    /// <param name="callback">The implementer calls this action with the result of the close check.</param>
    void CanClose(Action<bool> callback);
}

 

 

Coordinator
Nov 5, 2010 at 9:39 PM

That sounds pretty reasonable :)