Example #1
0
        public void CommandLineDesignerViewModel_Validate_CommandFileNameIsNull_HasErrors()
        {
            //------------Setup for test--------------------------
            const string CommandFileName = null;
            // ReSharper disable RedundantArgumentDefaultValue
            var viewModel = new CommandLineDesignerViewModel(CreateModelItem(CommandFileName));

            // ReSharper restore RedundantArgumentDefaultValue

            //------------Execute Test---------------------------
            viewModel.Validate();

            //------------Assert Results-------------------------
            Assert.IsNotNull(viewModel.Errors);
            Assert.AreEqual(1, viewModel.Errors.Count);

            var error = viewModel.Errors[0];

            Assert.AreEqual("Command must have a value", error.Message);
            Assert.AreEqual(ErrorType.Critical, error.ErrorType);

            Assert.IsFalse(viewModel.IsCommandFileNameFocused);
            error.Do();
            Assert.IsTrue(viewModel.IsCommandFileNameFocused);
        }
Example #2
0
        public void CommandLineDesignerViewModel_Validate_ClearsErrorsFirst()
        {
            //------------Setup for test--------------------------
            const string CommandFileName = "h]]";
            var          viewModel       = new CommandLineDesignerViewModel(CreateModelItem(CommandFileName))
            {
                Errors = new List <IActionableErrorInfo>
                {
                    new ActionableErrorInfo {
                        Message = "Previous Error", ErrorType = ErrorType.Warning
                    }
                }
            };

            //------------Execute Test---------------------------
            viewModel.Validate();

            //------------Assert Results-------------------------
            Assert.IsNotNull(viewModel.Errors);
            Assert.AreEqual(1, viewModel.Errors.Count);

            var error = viewModel.Errors[0];

            Assert.AreEqual("Invalid expression: opening and closing brackets don't match.", error.Message);
            Assert.AreEqual(ErrorType.Critical, error.ErrorType);
        }
Example #3
0
        public void CommandLineDesignerViewModel_Validate_CommandFileNameHasValidExpression_HasNoErrors()
        {
            //------------Setup for test--------------------------
            const string CommandFileName = "[[h]]";
            var          viewModel       = new CommandLineDesignerViewModel(CreateModelItem(CommandFileName));

            //------------Execute Test---------------------------
            viewModel.Validate();

            //------------Assert Results-------------------------
            Assert.IsNotNull(viewModel.Errors);
            Assert.AreEqual(0, viewModel.Errors.Count);
        }
Example #4
0
        public void CommandLineDesignerViewModel_Constructor_Properties_Initialized()
        {
            //------------Setup for test--------------------------

            //------------Execute Test---------------------------
            var viewModel = new CommandLineDesignerViewModel(CreateModelItem());

            //------------Assert Results-------------------------
            Assert.IsNotNull(viewModel.CommandPriorities);

            // Ensure order is correct
            Assert.AreEqual(ProcessPriorityClass.BelowNormal, viewModel.CommandPriorities[0].Key);
            Assert.AreEqual(ProcessPriorityClass.Normal, viewModel.CommandPriorities[1].Key);
            Assert.AreEqual(ProcessPriorityClass.AboveNormal, viewModel.CommandPriorities[2].Key);
            Assert.AreEqual(ProcessPriorityClass.Idle, viewModel.CommandPriorities[3].Key);
            Assert.AreEqual(ProcessPriorityClass.High, viewModel.CommandPriorities[4].Key);
            Assert.AreEqual(ProcessPriorityClass.RealTime, viewModel.CommandPriorities[5].Key);
        }
Example #5
0
        public void CommandLineDesignerViewModel_UpdateHelp_ShouldCallToHelpViewMode()
        {
            //------------Setup for test--------------------------
            var mockMainViewModel = new Mock <IShellViewModel>();
            var mockHelpViewModel = new Mock <IHelpWindowViewModel>();

            mockHelpViewModel.Setup(model => model.UpdateHelpText(It.IsAny <string>())).Verifiable();
            mockMainViewModel.Setup(model => model.HelpViewModel).Returns(mockHelpViewModel.Object);
            CustomContainer.Register(mockMainViewModel.Object);

            const string CommandFileName = "[[h]]";
            var          viewModel       = new CommandLineDesignerViewModel(CreateModelItem(CommandFileName));

            //------------Execute Test---------------------------
            viewModel.UpdateHelpDescriptor("help");
            //------------Assert Results-------------------------
            mockHelpViewModel.Verify(model => model.UpdateHelpText(It.IsAny <string>()), Times.Once());
        }
Example #6
0
        public void CommandLineDesignerViewModel_Validate_CommandFileNameHasInvalidExpression_HasErrors()
        {
            //------------Setup for test--------------------------
            const string CommandFileName = "h]]";
            var          viewModel       = new CommandLineDesignerViewModel(CreateModelItem(CommandFileName));

            //------------Execute Test---------------------------
            viewModel.Validate();

            //------------Assert Results-------------------------
            Assert.IsNotNull(viewModel.Errors);
            Assert.AreEqual(1, viewModel.Errors.Count);

            var error = viewModel.Errors[0];

            Assert.AreEqual("Invalid expression: opening and closing brackets don't match.", error.Message);
            Assert.AreEqual(ErrorType.Critical, error.ErrorType);

            Assert.IsFalse(viewModel.IsCommandFileNameFocused);
            error.Do();
            Assert.IsTrue(viewModel.IsCommandFileNameFocused);
        }