public void CreatingAButtonWithParameterSetsText() { const string TestText = "Test Text"; var button = new ButtonWidget(TestText, null, BuildWidgetParams()); Assert.AreEqual(TestText, button.Text, "Button Text was not set as expected"); }
public void ButtonCommandsExecuteWhenClicked() { var executed = false; var command = Container.Provide<AlfredCommand>(); command.ExecuteAction = () => { executed = true; }; var button = new ButtonWidget(BuildWidgetParams()) { ClickCommand = command }; button.Click(); Assert.IsTrue(executed, "The button was invoked but the executed flag was not set"); }
public void ButtonCommandsDoNotExecuteWhenButtonIsNotClicked() { var executed = false; var command = Container.Provide<AlfredCommand>(); command.ExecuteAction = () => { executed = true; }; var button = new ButtonWidget("Click Me", command, BuildWidgetParams()); Assert.IsNotNull(button.ClickCommand, "Button's ClickCommand was null"); Assert.IsFalse(executed, "The button was invoked but the button was not set"); }
/// <summary> /// Initializes a new instance of the /// <see cref="AlfredPowerModule" /> /// class. /// </summary> /// <exception cref="ArgumentNullException"> /// Thrown when one or more required arguments are null. /// </exception> /// <param name="container"> The container. </param> public AlfredPowerModule([NotNull] IObjectContainer container) : base(container) { if (container == null) { throw new ArgumentNullException(nameof(container)); } AlfredStatusWidget = new TextWidget(Resources.AlfredCoreModule_AlfredNotSet, BuildWidgetParameters(@"lblStatus")); InitializeButton = new ButtonWidget(Resources.InitializeButtonText, CreateCommand(ExecuteInitializeCommand), BuildWidgetParameters(@"btnInitialize")); ShutdownButton = new ButtonWidget(Resources.ShutdownButtonText, CreateCommand(ExecuteShutdownCommand), BuildWidgetParameters(@"btnShutdown")); }
public void NewButtonsDefaultToNullText() { var button = new ButtonWidget(BuildWidgetParams()); Assert.IsNull(button.Text, "Button's text was set to something other than null after instantiation."); }
public void ButtonCommandDefaultsToNull() { var button = new ButtonWidget(BuildWidgetParams()); Assert.IsNull(button.ClickCommand); }