예제 #1
0
        public void Constructor_ValidateDialogTitleText()
        {
            var buttons = new string[1] {
                "b1"
            };
            var vm = new MultiChoiceMsgBoxViewModel("title", "errorText", buttons);

            Assert.Matches("title", vm.DialogTitle);
        }
        /// <summary>
        /// Creates the dialog where the number of buttons specified indicates how many "choices"
        /// are available. The button chosen by the user is returned in Result. The values
        /// are from the MultiChoiceMsgBoxResult enum. Note that 1 to 4 buttons are supported where
        /// button[0] is the right most button and is the default button.
        /// </summary>
        public MultiChoiceMsgBox(string dialogTitle, string errorText, string[] buttons)
        {
            var viewModel = new MultiChoiceMsgBoxViewModel(dialogTitle, errorText, buttons);

            InitializeComponent();

            // Make sure the datacontext points to the view model
            DataContext = viewModel;

            viewModel.CloseDialog += ViewModel_CloseDialog;
        }
예제 #3
0
        public void ButtonClickCommand_Validate()
        {
            var buttons = new string[4] {
                "b1", "b2", "b3", "b4"
            };
            var vm = new MultiChoiceMsgBoxViewModel("title", "errorText", buttons);

            MultiChoiceMsgBoxResult result = MultiChoiceMsgBoxResult.Cancel;

            vm.CloseDialog += (s, e) => { result = e; };
            Assert.True(vm.ButtonClickCommand.CanExecute(null));

            vm.ButtonClickCommand.Execute(MultiChoiceMsgBoxResult.Button3);

            Assert.True(MultiChoiceMsgBoxResult.Button3 == result);
        }
예제 #4
0
        public void Constructor_ValidateButtonText()
        {
            var buttons = new string[4] {
                "b1", "b2", "b3", "b4"
            };
            var vm = new MultiChoiceMsgBoxViewModel("title", "errorText", buttons);

            Assert.Matches(buttons[0], vm.Button1Text);
            Assert.Matches(buttons[1], vm.Button2Text);
            Assert.Matches(buttons[2], vm.Button3Text);
            Assert.Matches(buttons[3], vm.Button4Text);

            buttons = new string[2] {
                "b1", "b2"
            };
            vm = new MultiChoiceMsgBoxViewModel("title", "errorText", buttons);
            Assert.Matches(buttons[0], vm.Button1Text);
            Assert.Matches(buttons[1], vm.Button2Text);
            Assert.Null(vm.Button3Text);
            Assert.Null(vm.Button4Text);
        }