public void ResetTest() { var dummyBasicFlow = new Flow(); var dummyGlobalFlows = new List <Flow>(); var dummySpecificFlows = new List <Flow>(); var dummyBoundedFlows = new List <Flow>(); var dummy1 = new DummyRule(0); var dummy2 = new DummyRule(1); var dummy3 = new DummyRule(2); // Test validation with 3 rules and 3 errors var ruleList = new List <IRule> { dummy1, dummy2, dummy3 }; var rucmRuleValidator = new RucmRuleValidator(ruleList); var result = rucmRuleValidator.Validate(dummyBasicFlow, dummyGlobalFlows, dummySpecificFlows, dummyBoundedFlows); Assert.IsFalse(result); Assert.IsTrue(rucmRuleValidator.GetErrorReport().GetErrorList.Count == 3); // Test the reset rucmRuleValidator.Reset(); Assert.IsTrue(rucmRuleValidator.GetErrorReport().GetErrorList.Count == 0); // And validate again result = rucmRuleValidator.Validate(dummyBasicFlow, dummyGlobalFlows, dummySpecificFlows, dummyBoundedFlows); Assert.IsFalse(result); Assert.IsTrue(rucmRuleValidator.GetErrorReport().GetErrorList.Count == 3); }
public void GetErrorTest() { // Arrange IRucmRuleValidator testrucmRuleValidator = new RucmRuleValidator(RucmRuleRepository.Rules); XmlStructureParser testxmlStructureParser = new XmlStructureParser(testrucmRuleValidator); string result = string.Empty; // Act result = testxmlStructureParser.GetError(); // Assert Assert.IsEmpty(result); }
public void LoadXmlFileTestWithBrokenXmlSampleFile() { // Arrange IRucmRuleValidator testrucmRuleValidator = new RucmRuleValidator(RucmRuleRepository.Rules); XmlStructureParser testxmlStructureParser = new XmlStructureParser(testrucmRuleValidator); string filePath = "UseCaseTest\\XmlParser\\Testdateien\\UseCaseBeispiel - XML-Struktur defekt.docx"; bool result = false; // Act result = testxmlStructureParser.LoadXmlFile(filePath); // Assert Assert.IsFalse(result); }
public void ParseXmlFileTestWithRucmValidationRule19_23_24_25_26FailedSampleFile() { // Arrange IRucmRuleValidator testrucmRuleValidator = new RucmRuleValidator(RucmRuleRepository.Rules); XmlStructureParser testxmlStructureParser = new XmlStructureParser(testrucmRuleValidator); string filePath = "UseCaseTest\\XmlParser\\Testdateien\\UseCaseBeispiel - Regel 19, 23, 24, 25 und 26 verletzt.docx"; UseCase testUseCase = new UseCase(); bool resultLoadXmlFile = false; bool resultParseXmlFile = false; // Act resultLoadXmlFile = testxmlStructureParser.LoadXmlFile(filePath); resultParseXmlFile = testxmlStructureParser.ParseXmlFile(out testUseCase); // Assert Assert.IsTrue(resultLoadXmlFile); Assert.IsFalse(resultParseXmlFile); Assert.IsNull(testUseCase); }
public void ParseXmlFileTestWithWorstCaseSampleFile() { // Arrange IRucmRuleValidator testrucmRuleValidator = new RucmRuleValidator(RucmRuleRepository.Rules); XmlStructureParser testxmlStructureParser = new XmlStructureParser(testrucmRuleValidator); string filePath = "UseCaseTest\\XmlParser\\Testdateien\\UseCaseBeispiel - Worst-Case Szenario.docx"; UseCase testUseCase = new UseCase(); bool resultLoadXmlFile = false; bool resultParseXmlFile = false; // Act resultLoadXmlFile = testxmlStructureParser.LoadXmlFile(filePath); resultParseXmlFile = testxmlStructureParser.ParseXmlFile(out testUseCase); // Assert Assert.IsTrue(resultLoadXmlFile); Assert.IsTrue(resultParseXmlFile); Assert.IsNotNull(testUseCase); }
public void ParseXmlFileTestWithOneRfsBoundedAlternativeFlowSampleFile() { // Arrange IRucmRuleValidator testrucmRuleValidator = new RucmRuleValidator(RucmRuleRepository.Rules); XmlStructureParser testxmlStructureParser = new XmlStructureParser(testrucmRuleValidator); string filePath = "UseCaseTest\\XmlParser\\Testdateien\\UseCaseBeispiel - BoundedAlternativeFlow mit einem RFS.docx"; UseCase testUseCase = new UseCase(); bool resultLoadXmlFile = false; bool resultParseXmlFile = false; // Act resultLoadXmlFile = testxmlStructureParser.LoadXmlFile(filePath); resultParseXmlFile = testxmlStructureParser.ParseXmlFile(out testUseCase); // Assert Assert.IsTrue(resultLoadXmlFile); Assert.IsTrue(resultParseXmlFile); Assert.IsNotNull(testUseCase); }
public void ParseXmlFileTestWithCorrectXmlSampleFileButWithFormattingChanges() { // Arrange IRucmRuleValidator testrucmRuleValidator = new RucmRuleValidator(RucmRuleRepository.Rules); XmlStructureParser testxmlStructureParser = new XmlStructureParser(testrucmRuleValidator); string filePath = "UseCaseTest\\XmlParser\\Testdateien\\UseCaseBeispiel - Keine Fehler aber mit Formatierungsänderungen.docx"; UseCase testUseCase = new UseCase(); bool resultLoadXmlFile = false; bool resultParseXmlFile = false; // Act resultLoadXmlFile = testxmlStructureParser.LoadXmlFile(filePath); resultParseXmlFile = testxmlStructureParser.ParseXmlFile(out testUseCase); // Assert Assert.IsTrue(resultLoadXmlFile); Assert.IsTrue(resultParseXmlFile); Assert.IsNotNull(testUseCase); }
public void ExportTest() { // Erfolgreicher Export ohne Mängel var tempPath = this.GetTempFile(); var ruleList = new List <IRule>(); var rucmRuleValidator = new RucmRuleValidator(ruleList); var exportResult = rucmRuleValidator.Export(tempPath); try { Assert.IsTrue(exportResult); Assert.IsTrue(File.Exists(tempPath)); Assert.IsTrue(File.ReadAllText(tempPath) == ErrorReport.ExportHeader + ErrorReport.EmptyErrorExportMessage); } finally { File.Delete(tempPath); } // Erfolgreicher Export mit externen Mängeln tempPath = this.GetTempFile(); var fehlermeldung = "Das ist ein Fehler"; rucmRuleValidator.AddExternalError(fehlermeldung); exportResult = rucmRuleValidator.Export(tempPath); try { Assert.IsTrue(exportResult); Assert.IsTrue(File.Exists(tempPath)); Assert.IsTrue(File.ReadAllText(tempPath) == ErrorReport.ExportHeader + ErrorReport.GeneralErrorHeader + fehlermeldung + "\r\n"); } finally { File.Delete(tempPath); } // Erfolgreicher Export mit Validierungsmängel tempPath = this.GetTempFile(); var dummy = new DummyRule(2, 2, 2); var dummyBasicFlow = new Flow(); var dummyGlobalFlows = new List <Flow>(); var dummySpecificFlows = new List <Flow>(); var dummyBoundedFlows = new List <Flow>(); ruleList = new List <IRule> { dummy }; rucmRuleValidator = new RucmRuleValidator(ruleList); rucmRuleValidator.Validate(dummyBasicFlow, dummyGlobalFlows, dummySpecificFlows, dummyBoundedFlows); exportResult = rucmRuleValidator.Export(tempPath); try { Assert.IsTrue(exportResult); Assert.IsTrue(File.Exists(tempPath)); var expectedText = ErrorReport.ExportHeader + ErrorReport.GeneralErrorHeader + "Error #1\r\nError #2\r\n" + ErrorReport.FlowErrorHeader + "Fehler in Flow 1: Error #0\tLösung zu: 0\r\n" + "Fehler in Flow 2: Error #1\tLösung zu: 1\r\n" + ErrorReport.StepErrorHeader + "Fehler in Step 1: Error #1\tLösung zu: 1\r\n" + "Fehler in Step 2: Error #2\tLösung zu: 2\r\n"; Assert.IsTrue(File.ReadAllText(tempPath) == expectedText); } finally { File.Delete(tempPath); } // Erfolgreicher Export mit Dateiersetzung tempPath = this.GetTempFile(); dummy = new DummyRule(2); ruleList = new List <IRule> { dummy }; rucmRuleValidator = new RucmRuleValidator(ruleList); rucmRuleValidator.Validate(dummyBasicFlow, dummyGlobalFlows, dummySpecificFlows, dummyBoundedFlows); File.WriteAllText(tempPath, "Test"); exportResult = rucmRuleValidator.Export(tempPath); try { Assert.IsTrue(exportResult); Assert.IsTrue(File.Exists(tempPath)); Assert.IsTrue(File.ReadAllText(tempPath) == ErrorReport.ExportHeader + ErrorReport.GeneralErrorHeader + "Error #1\r\nError #2\r\n"); } finally { File.Delete(tempPath); } // Fehlerhafter Export var invalidPath = "ABC:\\Invalid\\test.txt"; exportResult = rucmRuleValidator.Export(invalidPath); Assert.IsFalse(exportResult); }