public void ValidateState() { var target = new Target(); Assert.True(InitializeUtility.ValidateState(false, false, null, false)); Assert.False(InitializeUtility.ValidateState(true, false, null, false)); Assert.DoesNotThrow(() => InitializeUtility.ValidateState(true, false, null, false)); Assert.Throws <InitializeStateException>(() => InitializeUtility.ValidateState(true, false)); target.Initialize(); Assert.False(InitializeUtility.ValidateState(false, true, null, false)); Assert.True(InitializeUtility.ValidateState(true, true, null, false)); }
/// <summary> /// Validates current state. /// </summary> /// <param name="expected">The expected initialize state.</param> /// <param name="throws">The value that determines whether to throw exception on invalid validate result.</param> public bool ValidateState(bool expected, bool throws = true) { return(InitializeUtility.ValidateState(expected, Value, null, throws)); }
/// <summary> /// Validates state of the specified handler. /// </summary> /// <param name="handler">The initialize state handler to validate.</param> /// <param name="expected">The expected initialize state.</param> /// <param name="throws">The value that determines whether to throw exception on invalid validate result.</param> public static bool ValidateState(this IInitialize handler, bool expected, bool throws = true) { return(InitializeUtility.ValidateState(expected, handler, throws)); }