Validate() public method

public Validate ( ) : void
return void
        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);
        }
        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);
        }
        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);
        }
        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);
        }