public void ValidationShouldSucceed_Empty() { // arrange var validator = new PreValidator(new List <IPreValidationStep>()); // act var result = validator.Validate(new[] { "" }); // assert Assert.IsTrue(result, "Validation should succeed if no steps are specified"); }
public void ValidationShouldFail_HasMatchingQuotes(string[] lines) { // arrange var validator = new PreValidator(new List <IPreValidationStep> { new HasMatchingQuotes() }); // act var result = validator.Validate(lines); // assert Assert.IsFalse(result, $"Testcase {string.Join(" ", lines)} failed"); }
public void ValidationShouldSucceed_HasMatchingQuotes(string[] lines) { // arrange var validator = new PreValidator(new List <IPreValidationStep> { new HasMatchingQuotes() }); // act var result = validator.Validate(lines); // assert Assert.IsTrue(result); }
public void ValidationShouldFail_HasValidLineEnds(string line) { // arrange var validator = new PreValidator(new List <IPreValidationStep> { new HasValidLineEndsStep() }); // act var result = validator.Validate(new[] { line }); // assert Assert.IsFalse(result); }
public void ValidationShouldFail_PropertiesOk(string prop) { // arrange var validator = new PreValidator(new List <IPreValidationStep> { new PropertiesOk() }); // act var result = validator.Validate(new[] { prop }); // assert Assert.IsFalse(result, $"Testcase {prop} failed"); }
public void ValidationShouldFail_ConstantsOk(string constant) { // arrange var validator = new PreValidator(new List <IPreValidationStep> { new ConstantsOk() }); // act var result = validator.Validate(new[] { constant }); // assert Assert.IsFalse(result, $"Testcase {constant} failed"); }
public void ValidationShouldFail_BlockDeclarationsOk(string block) { // arrange var validator = new PreValidator(new List <IPreValidationStep> { new BlockDeclarationsOk() }); // act var result = validator.Validate(new[] { block }); // assert Assert.IsFalse(result, $"Testcase {block} failed"); }
public void ValidationShouldFail_ContainsStartFunction(string[] lines) { // arrange var validator = new PreValidator(new List <IPreValidationStep> { new ContainsStartFunction() }); // act var result = validator.Validate(lines); // assert Assert.IsFalse(result, $"Testcase {string.Join(" ", lines)} failed"); }
public void ValidationShouldSucceed_ContainsProgramUtility(string[] lines) { // arrange var validator = new PreValidator(new List <IPreValidationStep> { new ContainsProgramUtility() }); // act var result = validator.Validate(lines); // assert Assert.IsTrue(result, $"Testcase {string.Join(" ", lines)} failed"); }
public void ValidationShouldFail_BlockOpeningsOk(string nextLine) { // arrange var validator = new PreValidator(new List <IPreValidationStep> { new BlockOpeningsOk() }); var result = false; // act foreach (var block in PreValidator.Blocks) { result = validator.Validate(new[] { block, nextLine }); } // assert Assert.IsFalse(result, $"Testcase {nextLine} failed"); }
public void ValidationShouldSucceed_BlockOpeningsOk() { // arrange var validator = new PreValidator(new List <IPreValidationStep> { new BlockOpeningsOk() }); var result = false; // act foreach (var block in PreValidator.Blocks) { result = validator.Validate(new[] { block, "{" }); } // assert Assert.IsTrue(result); }
private void _preValidate() { Extensions.WriteColoredLine("Pre-validation: ", ConsoleColor.DarkCyan); var validator = new PreValidator(new List <IPreValidationStep> { new HasValidLineEndsStep(), new HasMatchingQuotes(), new HasMatchingBraces(), new ContainsProgramUtility(), new ContainsStartFunction(), new BlockOpeningsOk(), new BlockDeclarationsOk(), new ConstantsOk(), new PropertiesOk(), new AssignemtnsOk(), }); var preValidationResult = validator.Validate(_lines); if (Verbose) { foreach (var validationStepResult in validator.Results) { Extensions.WriteColoredLine(" - " + validationStepResult.Output, validationStepResult.Valid ? ConsoleColor.DarkGreen : ConsoleColor.Red); } } Console.WriteLine(); Console.WriteLine(preValidationResult ? $"Pre-validation for `{_name}` successful" : $"Pre-validation for {_name} failed!"); Console.WriteLine(); if (preValidationResult == false) { throw new PreValidationException("EInterpreter stopped before execution because of failing Pre-validation"); } }