コード例 #1
0
        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");
        }
コード例 #2
0
        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");
        }
コード例 #3
0
        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");
        }
コード例 #4
0
        /// <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"));
        }
コード例 #5
0
        public void NewButtonsDefaultToNullText()
        {
            var button = new ButtonWidget(BuildWidgetParams());

            Assert.IsNull(button.Text, "Button's text was set to something other than null after instantiation.");
        }
コード例 #6
0
        public void ButtonCommandDefaultsToNull()
        {
            var button = new ButtonWidget(BuildWidgetParams());

            Assert.IsNull(button.ClickCommand);
        }