public void AddHandler(object sender, EventArgs args) { DataDictionary.Tests.TestCase testCase = (DataDictionary.Tests.TestCase)DataDictionary.Generated.acceptor.getFactory().createTestCase(); testCase.Enclosing = Item; testCase.Name = "Test case" + (Item.TestCases.Count + 1); createTestCase(testCase); }
public override void visit(Generated.SubSequence obj, bool visitSubNodes) { Tests.SubSequence subSequence = (Tests.SubSequence)obj; if (subSequence != null) { if (subSequence.TestCases.Count == 0) { subSequence.AddWarning("Sub sequences should hold at least one test case"); } else { Tests.TestCase testCase = (Tests.TestCase)subSequence.TestCases[0]; if (testCase.Steps.Count == 0) { testCase.AddWarning("First test case of a subsequence should hold at least one step"); } else { Tests.Step step = (Tests.Step)testCase.Steps[0]; if (step.Name.IndexOf("Setup") < 0 && step.Name.IndexOf("Initialize") < 0) { step.AddWarning("First step of the first test case of a subsequence should be used to setup the system, and should hold 'Setup' or 'Initialize' in its name"); } } } } base.visit(obj, visitSubNodes); }
public override TestCase createTestCase() { TestCase retVal = new Tests.TestCase(); _defaultValueSetter.SetDefaultValue(retVal); return(retVal); }
public override void visit(TestCase obj, bool visitSubNodes) { Tests.TestCase testCase = (Tests.TestCase)obj; if (!testCase.getImplemented()) { testCase.AddInfo("Unimplemented test case"); } base.visit(obj, visitSubNodes); }
public override void visit(Generated.TestCase obj, bool visitSubNodes) { DataDictionary.Tests.TestCase testCase = (DataDictionary.Tests.TestCase)obj; if (!testCase.getImplemented()) { testCase.AddInfo("Unimplemented test case"); } base.visit(obj, visitSubNodes); }
/// <summary> /// Creates a new test case (e.g. feature + test case) /// </summary> /// <param name="testCase"></param> /// <returns></returns> public TestCaseTreeNode createTestCase(DataDictionary.Tests.TestCase testCase) { TestCaseTreeNode retVal = new TestCaseTreeNode(testCase); Item.appendTestCases(testCase); Nodes.Add(retVal); return(retVal); }
/// <summary> /// Remove obsolete fields from XML file /// </summary> /// <param name="obj"></param> /// <param name="visitSubNodes"></param> public override void visit(TestCase obj, bool visitSubNodes) { Tests.TestCase testCase = (Tests.TestCase)obj; if (testCase.getObsoleteComment() == "") { testCase.setObsoleteComment(null); } base.visit(obj, visitSubNodes); }
/// <summary> /// Creates a section for a given test case /// </summary> /// <param name="runner">The runner to be used to execute the tests</param> /// <param name="aTestCase">Test case to be displayed</param> /// <param name="aReportConfig">The report configuration containing display details</param> /// <param name="activatedRuleConditions">The list that will contain the rules activated by this test case</param> /// <param name="createPdf">Indicates if the information about this sub-sequence has to be added to the pdf</param> public void CreateTestCaseSection(Runner runner, TestCase aTestCase, TestsCoverageReportHandler aReportConfig, HashSet<RuleCondition> activatedRuleConditions, bool createPdf) { string title = "Test case " + aTestCase.Name; if (createPdf) { AddSubParagraph(title); if (aTestCase.Requirements.Count > 0) { AddSubParagraph(title + ": verified requirements:"); foreach (ReqRef reqRef in aTestCase.Requirements) { string text = "Requirement " + reqRef.Name; if (!Util.isEmpty(reqRef.Comment)) { text = text + " : " + reqRef.Comment; } AddListItem(text); } CloseSubParagraph(); } } runner.RunUntilStep(null); activatedRuleConditions.UnionWith(runner.EventTimeLine.GetActivatedRules()); if (createPdf) { if (aReportConfig.AddSteps) { foreach (Step step in aTestCase.Steps) { if (step.SubSteps.Count > 0) { SubStep firstSubStep = step.SubSteps[0] as SubStep; SubStep lastSubStep = step.SubSteps[step.SubSteps.Count - 1] as SubStep; double start = runner.EventTimeLine.GetSubStepActivationTime(firstSubStep); double end = runner.EventTimeLine.GetNextSubStepActivationTime(lastSubStep); List<RuleCondition> activatedRules = runner.EventTimeLine.GetActivatedRulesInRange(start, end); CreateStepSection(step, activatedRules, aReportConfig); } } } CreateActivatedRulesSection(title, runner.EventTimeLine.GetActivatedRules(), aReportConfig.Dictionary.ImplementedRules, aReportConfig.AddActivatedRulesInTestCases); CloseSubParagraph(); } }
/// <summary> /// Consctructor: creates a report for a selected test case /// </summary> /// <param name="aTestCase"></param> public TestReport(TestCase aTestCase) { InitializeComponent(); EFSSystem = aTestCase.EFSSystem; reportHandler = new TestsCoverageReportHandler(aTestCase.Dictionary); reportHandler.TestCase = aTestCase; InitializeCheckBoxes(3); TxtB_Path.Text = reportHandler.FileName; }
/// <summary> /// Fills the actual test case with steps of another test case /// </summary> /// <param name="oldTestCase"></param> public void Merge(TestCase aTestCase) { if (Steps.Count != aTestCase.Steps.Count) { throw new Exception("The number of steps of " + Name + " changed"); } else { int cnt = 0; foreach (Step step in Steps) { Step oldStep = aTestCase.Steps[cnt] as Step; if (aTestCase != null) { if (step.getTCS_Order() == oldStep.getTCS_Order()) { step.Merge(oldStep); } else { throw new Exception("The new version of the test case " + Name + " contains the step " + step.Name + " instead of " + oldStep.Name); } } cnt++; } } }
/// <summary> /// Creates a section for a given test case /// </summary> /// <param name="runner">The runner to be used to execute the tests</param> /// <param name="aFrame">Frame to be displayed</param> /// <param name="aReportConfig">The report configuration containing display details</param> /// <param name="activatedRuleConditions">The list that will contain the rules activated by this test case</param> /// <returns></returns> public void CreateTestCaseSection(DataDictionary.Tests.Runner.Runner runner, TestCase aTestCase, TestsCoverageReportHandler aReportConfig, HashSet<RuleCondition> activatedRuleConditions, bool createPdf) { AddSubParagraph("Test case " + aTestCase.Name); if (aTestCase.Requirements.Count > 0) { AddParagraph("This test case verifies the following requirements"); foreach (DataDictionary.ReqRef reqRef in aTestCase.Requirements) { string text = "Requirement " + reqRef.Name; if (!Utils.Utils.isEmpty(reqRef.Comment)) { text = text + " : " + reqRef.Comment; } AddListItem(text); } } runner.RunUntilStep(null); activatedRuleConditions.UnionWith(runner.EventTimeLine.GetActivatedRules()); string title = "Test case " + aTestCase.Name; CreateTable(title, runner.EventTimeLine.GetActivatedRules(), aReportConfig.Dictionary.ImplementedRules, aReportConfig.AddActivatedRulesInTestCases, aReportConfig.AddNonCoveredRulesInTestCases); if (createPdf && aReportConfig.AddSteps) { foreach (Step step in aTestCase.Steps) { if (step.SubSteps.Count > 0) { AddSubParagraph(String.Format("Step {0}", step.Name)); DataDictionary.Tests.SubStep firstSubStep = step.SubSteps[0] as DataDictionary.Tests.SubStep; DataDictionary.Tests.SubStep lastSubStep = step.SubSteps[step.SubSteps.Count - 1] as DataDictionary.Tests.SubStep; double start = runner.EventTimeLine.GetSubStepActivationTime(firstSubStep); double end = runner.EventTimeLine.GetNextSubStepActivationTime(lastSubStep); List<RuleCondition> activatedRules = runner.EventTimeLine.GetActivatedRulesInRange(start, end); CreateStepTable(runner, step, aTestCase.Dictionary.ImplementedRules.Count, activatedRules, aReportConfig); if (aReportConfig.AddLog) { List<DataDictionary.Tests.Runner.Events.ModelEvent> events = runner.EventTimeLine.GetEventsInRange((uint)start, (uint)end); foreach (ModelEvent ev in events) { AddCode(ev.ToString()); } } CloseSubParagraph(); } } } CloseSubParagraph(); }
public override TestCase createTestCase() { TestCase retVal = new Tests.TestCase(); _defaultValueSetter.SetDefaultValue(retVal); return retVal; }
private void initializeInputForLambda(TestCase aTestCase, Workbook workbook) { Step aStep = new Step(); aStep.Name = "Step1 - Initialize input"; aTestCase.AddModelElement(aStep); /*********************************** TRAIN DATA ***********************************/ SubStep aSubStep = new SubStep(); aSubStep.Name = "SubStep1 - Train data"; aSubStep.setSkipEngine(true); aStep.AddModelElement(aSubStep); /* This is a lambda train => no brake models defined in the train data */ addAction(aSubStep, String.Format("Kernel.TrainData.TrainData.Value.EBModels <- EMPTY")); addAction(aSubStep, String.Format("Kernel.TrainData.TrainData.Value.SBModels <- EMPTY")); addAction(aSubStep, String.Format("Kernel.TrainData.TrainData.Value.NormalServiceBrakeModels <- EMPTY")); addAction(aSubStep, String.Format("Kernel.TrainData.TrainData.Value.T_brake_emergency <- EMPTY")); addAction(aSubStep, String.Format("Kernel.TrainData.TrainData.Value.T_brake_service <- EMPTY")); /* Initializing the maximum train speed */ /* This value must be in the range {0km/h; 200km/h}, otherwise the conversion model will not be applicable */ addAction(aSubStep, String.Format(CultureInfo.InvariantCulture, "Kernel.TrainData.TrainData.Value.MaximumSpeed <- {0:0.0}", 180.0)); Worksheet aWorksheet = workbook.Sheets[1] as Worksheet; bool isPassengerTrain; importCommonTrainDataInformation(aSubStep, aWorksheet, out isPassengerTrain); /*********************************** TRACK DATA ***********************************/ aSubStep = new SubStep(); aSubStep.Name = "SubStep2 - Track data"; aSubStep.setSkipEngine(true); aStep.AddModelElement(aSubStep); /* This is a lambda train => track condition brake inhibition profile is not applicable */ addAction(aSubStep, String.Format("Kernel.TrackDescription.TrackConditions.TCProfile <- EMPTY")); aWorksheet = workbook.Sheets[2] as Worksheet; importCommonTrackDataInformation(aSubStep, aWorksheet); /*********************************** NATIONAL VALUES ***********************************/ aSubStep = new SubStep(); aSubStep.Name = "SubStep3 - National values"; aSubStep.setSkipEngine(true); aStep.AddModelElement(aSubStep); aWorksheet = workbook.Sheets[3] as Worksheet; importCommonNationalValuesInformation(aSubStep, aWorksheet); /*********************************** FIXED VALUES ***********************************/ aSubStep = new SubStep(); aSubStep.Name = "SubStep4 - Fixed values"; aSubStep.setSkipEngine(true); aStep.AddModelElement(aSubStep); aWorksheet = workbook.Sheets[4] as Worksheet; importCommonFixedValuesInformation(aSubStep, aWorksheet); /****************************** BRAKE PARAMETERS (lambda) ******************************/ aSubStep = new SubStep(); aSubStep.Name = "SubStep5 - Brake parameters"; aSubStep.setSkipEngine(true); aStep.AddModelElement(aSubStep); aWorksheet = workbook.Sheets[5] as Worksheet; Range aRange = aWorksheet.UsedRange; addAction(aSubStep, String.Format(CultureInfo.InvariantCulture, "Kernel.TrainData.TrainData.Value.BrakePercentage <- {0:0.0#}", (double)(aRange.Cells[3, 6] as Range).Value2)); /*************************** INTERGRATED CORRECTION FACTORS ***************************/ aSubStep = new SubStep(); aSubStep.Name = "SubStep6 - Integrated correction factors"; aSubStep.setSkipEngine(true); aStep.AddModelElement(aSubStep); aWorksheet = workbook.Sheets[8] as Worksheet; aRange = aWorksheet.UsedRange; /* Initializing Kr_int */ int index = 0; double doubleValue = -1; double temp; for (int i = 0; i < 9; i++) { temp = (double)(aRange.Cells[i + 32, 2] as Range).Value2; if (doubleValue != temp) { double location = (double)(aRange.Cells[i + 32, 1] as Range).Value2; doubleValue = temp; addAction(aSubStep, String.Format(CultureInfo.InvariantCulture, "Kernel.NationalValues.ApplicableNationalValues.Value.IntegratedCorrectionFactorKrInt.Val{0} <- Kernel.NationalValues.KrIntValue\n{{\n LengthStep => {1:0.0},\n Value => {2:0.0####}\n}}", index, location, doubleValue)); index++; } } addAction(aSubStep, String.Format(CultureInfo.InvariantCulture, "Kernel.NationalValues.ApplicableNationalValues.Value.IntegratedCorrectionFactorKrInt.Val{0} <- Kernel.NationalValues.KrIntValue\n{{\n LengthStep => Default.BaseTypes.Length.Infinity,\n Value => {1:0.0####}\n}}", index, doubleValue)); /* Case of a passenger train */ if (isPassengerTrain) { /* Initializing Kv_int */ double a = -1; double b = -1; double tempA, tempB; index = 0; for (int i = 0; i <= 9; i++) { tempA = (double)(aRange.Cells[i + 5, 5] as Range).Value2; tempB = (double)(aRange.Cells[i + 31, 5] as Range).Value2; if (a != tempA || b != tempB) { double speed = (double)(aRange.Cells[i + 5, 4] as Range).Value2; a = tempA; b = tempB; addAction(aSubStep, String.Format(CultureInfo.InvariantCulture, "Kernel.NationalValues.ApplicableNationalValues.Value.IntegratedCorrectionFactorKvInt_PassengerTrain.Val{0} <- Kernel.NationalValues.KvIntValue_PassengerTrain\n{{\n SpeedStep => {1:0.0},\n ValueA => {2:0.0#},\n ValueB => {3:0.0#}\n}}", index, speed, a, b)); index++; } } addAction(aSubStep, String.Format(CultureInfo.InvariantCulture, "Kernel.NationalValues.ApplicableNationalValues.Value.IntegratedCorrectionFactorKvInt_PassengerTrain.Val{0} <- Kernel.NationalValues.KvIntValue_PassengerTrain\n{{\n SpeedStep => Default.BaseTypes.Speed.Infinity,\n ValueA => {1:0.0#},\n ValueB => {2:0.0#}\n}}", index, a, b)); } else /* Case of freight trains */ { /* Initializing Kv_int */ doubleValue = -1; index = 0; for (int i = 0; i <= 9; i++) { temp = (double)(aRange.Cells[i + 5, 2] as Range).Value2; if (doubleValue != temp) { double speed = (double)(aRange.Cells[i + 5, 1] as Range).Value2; doubleValue = temp; addAction(aSubStep, String.Format(CultureInfo.InvariantCulture, "Kernel.NationalValues.ApplicableNationalValues.Value.IntegratedCorrectionFactorKvInt_FreightTrain.Val{0} <- Kernel.NationalValues.KvIntValue_FreightTrain\n{{\n SpeedStep => {1:0.0},\n Value => {2:0.0#}\n}}", index, speed, doubleValue)); index++; } } addAction(aSubStep, String.Format(CultureInfo.InvariantCulture, "Kernel.NationalValues.ApplicableNationalValues.Value.IntegratedCorrectionFactorKvInt_FreightTrain.Val{0} <- Kernel.NationalValues.KvIntValue_FreightTrain\n{{\n SpeedStep => Default.BaseTypes.Speed.Infinity,\n Value => {1:0.0#}\n}}", index, doubleValue)); } /* Initializing A_NVP12 */ addAction(aSubStep, String.Format(CultureInfo.InvariantCulture, "Kernel.NationalValues.ApplicableNationalValues.Value.IntegratedCorrectionFactorKvInt_PassengerTrain.A_NVP12 <- {0:0.0}", (double)(aRange.Cells[44, 4] as Range).Value2)); /* Initializing A_NVP23 */ addAction(aSubStep, String.Format(CultureInfo.InvariantCulture, "Kernel.NationalValues.ApplicableNationalValues.Value.IntegratedCorrectionFactorKvInt_PassengerTrain.A_NVP23 <- {0:0.0}", (double)(aRange.Cells[44, 6] as Range).Value2)); /* Initializing Kt_int */ addAction(aSubStep, String.Format(CultureInfo.InvariantCulture, "Kernel.NationalValues.ApplicableNationalValues.Value.IntegratedCorrectionFactorForBrakeBuildUpTime <- {0:0.0}", (double)(aRange.Cells[47, 4] as Range).Value2)); }
private void initializeInputForGamma(TestCase aTestCase, Workbook workbook) { Step aStep = new Step(); aStep.Name = "Step1 - Initialize input"; aTestCase.AddModelElement(aStep); /*********************************** TRAIN DATA ***********************************/ SubStep aSubStep = new SubStep(); aSubStep.Name = "SubStep1 - Train data"; aSubStep.setSkipEngine(true); aStep.AddModelElement(aSubStep); /* This is a gamma train => we have to initialize brake models in the train data */ addAction(aSubStep, String.Format("Kernel.TrainData.TrainData.Value.EBModels <- Kernel.TrainData.BrakingParameters.EBModelSet\n{{\n ModelSet => Kernel.TrainData.BrakingParameters.BrakingModelSet{{}},\n Kdry_rstValuesSet => Kernel.TrainData.BrakingParameters.Kdry_rstValuesSet{{}},\n Kwet_rstValuesSet => Kernel.TrainData.BrakingParameters.Kwet_rstValuesSet{{}}\n}}")); addAction(aSubStep, String.Format("Kernel.TrainData.TrainData.Value.SBModels <- Kernel.TrainData.BrakingParameters.SBModelSet{{}}")); /* Initializing the maximum train speed */ /* I didn't find this value in ERA sheets, but I observed than their P function can exceed 160 km/h => the maximum speed should be greater than 160 km/h */ addAction(aSubStep, String.Format(CultureInfo.InvariantCulture, "Kernel.TrainData.TrainData.Value.MaximumSpeed <- {0:0.0}", 180.0)); Worksheet aWorksheet = workbook.Sheets[1] as Worksheet; bool isPassengerTrain; importCommonTrainDataInformation(aSubStep, aWorksheet, out isPassengerTrain); /*********************************** TRACK DATA ***********************************/ aSubStep = new SubStep(); aSubStep.Name = "SubStep2 - Track data"; aSubStep.setSkipEngine(true); aStep.AddModelElement(aSubStep); aWorksheet = workbook.Sheets[2] as Worksheet; importCommonTrackDataInformation(aSubStep, aWorksheet); /*********************************** NATIONAL VALUES ***********************************/ aSubStep = new SubStep(); aSubStep.Name = "SubStep3 - National values"; aSubStep.setSkipEngine(true); aStep.AddModelElement(aSubStep); aWorksheet = workbook.Sheets[3] as Worksheet; importCommonNationalValuesInformation(aSubStep, aWorksheet); /*********************************** FIXED VALUES ***********************************/ aSubStep = new SubStep(); aSubStep.Name = "SubStep4 - Fixed values"; aSubStep.setSkipEngine(true); aStep.AddModelElement(aSubStep); aWorksheet = workbook.Sheets[4] as Worksheet; importCommonFixedValuesInformation(aSubStep, aWorksheet); /****************************** BRAKE PARAMETERS (gamma) ******************************/ aSubStep = new SubStep(); aSubStep.Name = "SubStep5 - Brake parameters"; aSubStep.setSkipEngine(true); aStep.AddModelElement(aSubStep); aWorksheet = workbook.Sheets[6] as Worksheet; importGammaBrakeParameters(aSubStep, aWorksheet, 2, 8, true); // first combination importGammaBrakeParameters(aSubStep, aWorksheet, 3, 20, false); // second combination /*************************** CORRECTION FACTOR KDRY_RST ***************************/ aSubStep = new SubStep(); aSubStep.Name = "SubStep6 - Correction factor kdry_rst"; aSubStep.setSkipEngine(true); aStep.AddModelElement(aSubStep); aWorksheet = workbook.Sheets[7] as Worksheet; }
/// <summary> /// Consctructor: creates a report for a selected test case /// </summary> /// <param name="aTestCase"></param> public TestReport(TestCase aTestCase) { InitializeComponent(); _reportHandler = new TestsCoverageReportHandler(aTestCase.Dictionary) {TestCase = aTestCase}; InitializeCheckBoxes(3); TxtB_Path.Text = _reportHandler.FileName; }
private void intializeEFS(TestCase aTestCase, Workbook workbook) { Step aStep = new Step(); aStep.Name = "Step1 - Setup"; aTestCase.AddModelElement(aStep); SubStep aSubStep = new SubStep(); aSubStep.Name = "SubStep1 - Setup"; aSubStep.setSkipEngine(true); aStep.AddModelElement(aSubStep); TestAction levelInitialization = new TestAction(); levelInitialization.Expression = "Kernel.Level <- Kernel.LevelData\n{\n Value => Level.L1,\n DataState => DataState.Valid\n}"; aSubStep.AddModelElement(levelInitialization); TestAction odometryInitialization = new TestAction(); odometryInitialization.Expression = "Odometry.NominalDistance <- 0.0"; aSubStep.AddModelElement(odometryInitialization); }
// The sheets of the workbook are: \\ // \\ // Sheet number 1, name: Train (main) \\ // Sheet number 2, name: Track \\ // Sheet number 3, name: National values \\ // Sheet number 4, name: Fixed values \\ // Sheet number 5, name: Brake parameters (lambda) \\ L // Sheet number 6, name: Brake parameters (gamma) \\ G // Sheet number 7, name: Correction factor Kdry_rst \\ G // Sheet number 8, name: Integrated correction factors \\ L // Sheet number 9, name: Lambda train deceleration \\ L // Sheet number 10, name: Gamma train deceleration \\ G // Sheet number 11, name: Curves Gamma train \\ G // Sheet number 12, name: Calc Gamma \\ G (hidden) // Sheet number 13, name: Curves Lambda train \\ L // Sheet number 14, name: Calc Lambda \\ L (hidden) /// <summary> /// Launches import of the excel file in the background task /// </summary> /// <param name="arg"></param> public override void ExecuteWork() { if (TheDictionary != null) { Microsoft.Office.Interop.Excel.Application application = new Microsoft.Office.Interop.Excel.Application(); if (application != null) { Workbook workbook = application.Workbooks.Open(FileName); Worksheet trainData = workbook.Sheets[1] as Worksheet; Range aRange = trainData.UsedRange; string trainTypeName = (string)(aRange.Cells[14, 4] as Range).Value2; bool trainIsGamma = false; if (trainTypeName.Equals("Gamma")) { trainIsGamma = true; } else if (!trainTypeName.Equals("Lambda")) { new Exception("Unknown train type"); } Frame newFrame = new Frame(); newFrame.Name = FrameName; newFrame.setCycleDuration("Kernel.CycleDuration"); TheDictionary.AddModelElement(newFrame); SubSequence newSubSequence = new SubSequence(); newSubSequence.Name = FrameName; newFrame.AddModelElement(newSubSequence); TestCase aTestCase = new TestCase(); aTestCase.Name = "Setup"; aTestCase.NeedsRequirement = false; newSubSequence.AddModelElement(aTestCase); intializeEFS(aTestCase, workbook); aTestCase = new TestCase(); aTestCase.Name = "Initialize input"; aTestCase.NeedsRequirement = false; newSubSequence.AddModelElement(aTestCase); if (trainIsGamma) { initializeInputForGamma(aTestCase, workbook); } else { initializeInputForLambda(aTestCase, workbook); } aTestCase = new TestCase(); aTestCase.Name = "Verify input"; aTestCase.NeedsRequirement = false; newSubSequence.AddModelElement(aTestCase); if (trainIsGamma) { verifyInputForGamma(aTestCase, workbook); } else { verifyInputForLambda(aTestCase, workbook); } aTestCase = new TestCase(); aTestCase.Name = "Verify output"; aTestCase.NeedsRequirement = false; newSubSequence.AddModelElement(aTestCase); verifyOutputForTrains(trainIsGamma, aTestCase, workbook); } else { Log.ErrorFormat("Error while opening the excel file"); } application.Quit(); } else { if (TheStep != null) { //importExpectations(workbook); } else { Log.ErrorFormat("The import config is not properly initialized"); } } }
private void fillBrakingParametersExpectations(TestCase aTestCase, int stepNumber, string name, string expression, List<double> distanceValues, List<double> speedValues, List<double> values) { Step aStep = new Step(); aStep.Name = String.Format("Step{0} - {1}", stepNumber, name); aTestCase.AddModelElement(aStep); SubStep aSubStep = new SubStep(); aSubStep.Name = String.Format("SubStep1 - Verify {0} values", name); aStep.AddModelElement(aSubStep); for (int i = 0; i < values.Count; i++) { if (values[i] != -1) { Expectation expectation = new Expectation(); expectation.Expression = String.Format(CultureInfo.InvariantCulture, expression, Math.Round(distanceValues[i], 2), Math.Round(speedValues[i], 2), Math.Round(values[i], 4)); aSubStep.AddModelElement(expectation); } } }
private void verifyInputForGamma(TestCase aTestCase, Workbook workbook) { Step aStep = new Step(); aStep.Name = "Step1 - Verify input"; aTestCase.AddModelElement(aStep); /*********************************** TRAIN DATA ***********************************/ SubStep aSubStep = new SubStep(); aSubStep.Name = "SubStep1 - Train data"; aStep.AddModelElement(aSubStep); addAction(aSubStep, "Kernel.SpeedAndDistanceMonitoring.ReleaseSpeedSupervision.UpdateReleaseSpeed()"); addExpectation(aSubStep, "Kernel.TrainData.BrakingParameters.ConversionModel.ConversionModelIsUsed() == False"); }
private void verifyOutputForTrains(bool trainIsGamma, TestCase aTestCase, Workbook aWorkbook) { int sheet_number; if (trainIsGamma) { sheet_number = 11; } else { sheet_number = 13; } if (aWorkbook.Sheets.Count >= sheet_number && sheet_number != -1) { Worksheet worksheet = aWorkbook.Sheets[sheet_number] as Worksheet; List<double> speedValues = new List<double>(); List<double> aSafeValues = new List<double>(); List<double> aExpectedValues = new List<double>(); List<double> ebdValues = new List<double>(); List<double> sbdValues = new List<double>(); List<double> ebiValues = new List<double>(); List<double> sbi1Values = new List<double>(); List<double> sbi2Values = new List<double>(); List<double> floiValues = new List<double>(); List<double> warningValues = new List<double>(); List<double> permittedValues = new List<double>(); List<double> indicationValues = new List<double>(); Range testRange = worksheet.UsedRange; double val; object obj; double lastAddedSpeedValue = double.MinValue; for (int i = 2; i <= testRange.Rows.Count; i++) { val = (double)(testRange.Cells[i, 14] as Range).Value2; if (val - lastAddedSpeedValue >= SpeedInterval) { lastAddedSpeedValue = val; speedValues.Add(val); if (trainIsGamma) // then we import the values of A_Safe and A_Expected { obj = (testRange.Cells[i, 16] as Range).Value2; val = obj == null ? -1 : (double)obj; aSafeValues.Add(val); obj = (testRange.Cells[i, 17] as Range).Value2; val = obj == null ? -1 : (double)obj; aExpectedValues.Add(val); } if (FillEBD) { obj = (testRange.Cells[i, 18] as Range).Value2; val = obj == null ? -1 : (double)obj; ebdValues.Add(val); } if (FillSBD) { obj = (testRange.Cells[i, 19] as Range).Value2; val = obj == null ? -1 : (double)obj; sbdValues.Add(val); } if (FillEBI) { obj = (testRange.Cells[i, 20] as Range).Value2; val = obj == null ? -1 : (double)obj; ebiValues.Add(val); } if (FillSBI1) { obj = (testRange.Cells[i, 21] as Range).Value2; val = obj == null ? -1 : (double)obj; sbi1Values.Add(val); } if (FillSBI2) { obj = (testRange.Cells[i, 22] as Range).Value2; val = obj == null ? -1 : (double)obj; sbi2Values.Add(val); } if (FillFLOI) { obj = (testRange.Cells[i, 23] as Range).Value2; val = obj == null ? -1 : (double)obj; floiValues.Add(val); } if (FillWarning) { obj = (testRange.Cells[i, 24] as Range).Value2; val = obj == null ? -1 : (double)obj; warningValues.Add(val); } if (FillPermitted) { obj = (testRange.Cells[i, 25] as Range).Value2; val = obj == null ? -1 : (double)obj; permittedValues.Add(val); } if (FillIndication) { obj = (testRange.Cells[i, 26] as Range).Value2; val = obj == null ? -1 : (double)obj; indicationValues.Add(val); } } } int stepNumber = 1; if (trainIsGamma) // then we create steps for A_Safe and A_Expected { fillBrakingParametersExpectations(aTestCase, stepNumber++, "A_Safe", "ERA_BrakingCurvesVerification.CompareAcceleration\n(\n Val1 => Kernel.TrainData.BrakingParameters.A_safe ( d => ERA_BrakingCurvesVerification.ConvertTargetDistance({0:0.0}) , V => {1:0.0}),\n Val2 => {2:0.0####}\n)", ebdValues, speedValues, aSafeValues); fillBrakingParametersExpectations(aTestCase, stepNumber++, "A_Safe", "ERA_BrakingCurvesVerification.CompareAcceleration\n(\n Val1 => Kernel.TrainData.BrakingParameters.A_expected ( d => ERA_BrakingCurvesVerification.ConvertTargetDistance({0:0.0}) , V => {1:0.0}),\n Val2 => {2:0.0####}\n)", sbdValues, speedValues, aExpectedValues); } if (FillEBD) { fillBrakingCurvesExpectations(aTestCase, stepNumber++, "EBD", "ERA_BrakingCurvesVerification.Compare\n(\n Val1 => DistanceForSpeed (\n Function =>\n FUNCTION d : Default.BaseTypes.Distance => Kernel.SpeedAndDistanceMonitoring.TargetSupervision.EBD_Target ( Distance => d, aTarget => Kernel.MA.EndOfMovementAuthority() ),\n Speed => {0:0.0} ),\n Val2 => ERA_BrakingCurvesVerification.ConvertTargetDistance ( {1:0.0#} )\n)", speedValues, ebdValues); /*fillBrakingCurvesExpectations(aTestCase, => first "EBD", "ERA_BrakingCurvesVerification.Compare\n(\n Val1 => Kernel.SpeedAndDistanceMonitoring.TargetSupervision.EBD\n (\n Distance => ERA_BrakingCurvesVerification.ConvertTargetDistance ( {1:0.0#} )\n ),\n Val2 => {0:0.0#}\n)", speedValues, ebdValues); fillBrakingCurvesExpectations(aTestCase, => second "EBD", "ERA_BrakingCurvesVerification.Compare\n(\n Val1 => Kernel.SpeedAndDistanceMonitoring.TargetSupervision.EBD_Target\n (\n Distance => ERA_BrakingCurvesVerification.ConvertTargetDistance ( {1:0.0#} ),\n aTarget => Kernel.MA.EndOfMovementAuthority()\n ),\n Val2 => {0:0.0#}\n)", speedValues, ebdValues);*/ } if (FillSBD) { fillBrakingCurvesExpectations(aTestCase, stepNumber++, "SBD", "ERA_BrakingCurvesVerification.Compare\n(\n Val1 => Kernel.SpeedAndDistanceMonitoring.TargetSupervision.SBD\n (\n Distance => ERA_BrakingCurvesVerification.ConvertTargetDistance ( {1:0.0#} )\n ),\n Val2 => {0:0.0#}\n)", speedValues, sbdValues); } if (FillEBI) { fillBrakingCurvesExpectations(aTestCase, stepNumber++, "EBI", "ERA_BrakingCurvesVerification.Compare\n(\n Val1 => Kernel.SpeedAndDistanceMonitoring.TargetSupervision.d_EBI\n (\n Vest => {0:0.0#},\n aTarget => Kernel.MA.EndOfMovementAuthority()\n ),\n Val2 => ERA_BrakingCurvesVerification.ConvertTargetDistance ( {1:0.0#} )\n)", speedValues, ebiValues); } if (FillSBI1) { fillBrakingCurvesExpectations(aTestCase, stepNumber++, "SBI1", "ERA_BrakingCurvesVerification.Compare\n(\n Val1 => Kernel.SpeedAndDistanceMonitoring.TargetSupervision.d_SBI1\n (\n Vest => {0:0.0#}\n ),\n Val2 => ERA_BrakingCurvesVerification.ConvertTargetDistance ( {1:0.0#} )\n)", speedValues, sbi1Values); } if (FillSBI2) { fillBrakingCurvesExpectations(aTestCase, stepNumber++, "SBI2", "ERA_BrakingCurvesVerification.Compare\n(\n Val1 => Kernel.SpeedAndDistanceMonitoring.TargetSupervision.d_SBI2\n (\n Vest => {0:0.0#},\n aTarget => Kernel.MA.EndOfMovementAuthority()\n ),\n Val2 => ERA_BrakingCurvesVerification.ConvertTargetDistance ( {1:0.0#} )\n)", speedValues, sbi2Values); } if (FillFLOI) { fillBrakingCurvesExpectations(aTestCase, stepNumber++, "FLOI", "ERA_BrakingCurvesVerification.Compare\n(\n Val1 => Kernel.SpeedAndDistanceMonitoring.TargetSupervision.d_FLOI\n (\n Vest => {0:0.0#}\n ),\n Val2 => ERA_BrakingCurvesVerification.ConvertTargetDistance ( {1:0.0#} )\n)", speedValues, floiValues); } if (FillWarning) { fillBrakingCurvesExpectations(aTestCase, stepNumber++, "Warning", "ERA_BrakingCurvesVerification.Compare\n(\n Val1 => Kernel.SpeedAndDistanceMonitoring.TargetSupervision.d_W\n (\n Vest => {0:0.0#}\n ),\n Val2 => ERA_BrakingCurvesVerification.ConvertTargetDistance ( {1:0.0#} )\n)", speedValues, warningValues); } if (FillPermitted) { fillBrakingCurvesExpectations(aTestCase, stepNumber++, "Permitted", "ERA_BrakingCurvesVerification.Compare\n(\n Val1 => Kernel.SpeedAndDistanceMonitoring.TargetSupervision.d_P\n (\n Vest => {0:0.0#}\n ),\n Val2 => ERA_BrakingCurvesVerification.ConvertTargetDistance ( {1:0.0#} )\n)", speedValues, permittedValues); } if (FillIndication) { fillBrakingCurvesExpectations(aTestCase, stepNumber++, "Indication", "ERA_BrakingCurvesVerification.Compare\n(\n Val1 => Kernel.SpeedAndDistanceMonitoring.TargetSupervision.d_I\n (\n Vest => {0:0.0#}\n ),\n Val2 => ERA_BrakingCurvesVerification.ConvertTargetDistance ( {1:0.0#} )\n)", speedValues, indicationValues); } } else { if (sheet_number == -1) { Log.ErrorFormat("Incorrect train type selected!!"); } else { Log.ErrorFormat("Incorrect number of sheets in the excel document!!"); } } }
private void verifyInputForLambda(TestCase aTestCase, Workbook workbook) { Step aStep = new Step(); aStep.Name = "Step1 - Verify input"; aTestCase.AddModelElement(aStep); /*********************************** TRAIN DATA ***********************************/ SubStep aSubStep = new SubStep(); aSubStep.Name = "SubStep1 - Train data"; aStep.AddModelElement(aSubStep); addAction(aSubStep, "Kernel.TrainData.BrakingParameters.ConversionModel.Initialize()"); addAction(aSubStep, "Kernel.SpeedAndDistanceMonitoring.ReleaseSpeedSupervision.UpdateReleaseSpeed()"); addExpectation(aSubStep, "Kernel.TrainData.BrakingParameters.ConversionModel.ConversionModelIsUsed() == True"); /********************************* BRAKE PARAMETERS *********************************/ aSubStep = new SubStep(); aSubStep.Name = "SubStep2 - Brake parameters"; aStep.AddModelElement(aSubStep); Worksheet aWorksheet = workbook.Sheets[5] as Worksheet; Range aRange = aWorksheet.UsedRange; addAction(aSubStep, "Kernel.SpeedAndDistanceMonitoring.TargetSupervision.InitializeTimeIntervals()"); /* Verifying kto */ addExpectation(aSubStep, String.Format(CultureInfo.InvariantCulture, "Kernel.TrainData.BrakingParameters.ConversionModel.kto() == {0:0.0#}", (double)(aRange.Cells[7, 6] as Range).Value2)); if (TargetSpeed == 0) /* In this case, the values of T_brake_emergency_cmt and T_brake_service_cmt do not make sense (3.13.3.4.4.1) */ { /* Verifying T_brake_emergency_cm0 */ addExpectation(aSubStep, String.Format(CultureInfo.InvariantCulture, "Kernel.TrainData.BrakingParameters.ConversionModel.T_brake_emergency_cm0 == {0:0.0#}", (double)(aRange.Cells[8, 6] as Range).Value2)); /* Verifying T_brake_service_cm0 */ addExpectation(aSubStep, String.Format(CultureInfo.InvariantCulture, "Kernel.TrainData.BrakingParameters.ConversionModel.T_brake_service_cm0 == {0:0.0#}", (double)(aRange.Cells[10, 6] as Range).Value2)); } else /* In this case, the values of T_brake_emergency_cm0 and T_brake_service_cm0 do not make sense (3.13.3.4.4.1) */ { /* Verifying T_brake_emergency_cmt */ addExpectation(aSubStep, String.Format(CultureInfo.InvariantCulture, "Kernel.TrainData.BrakingParameters.ConversionModel.T_brake_emergency_cmt == {0:0.0#}", (double)(aRange.Cells[9, 6] as Range).Value2)); /* Verifying T_brake_service_cmt */ addExpectation(aSubStep, String.Format(CultureInfo.InvariantCulture, "Kernel.TrainData.BrakingParameters.ConversionModel.T_brake_service_cmt == {0:0.0#}", (double)(aRange.Cells[11, 6] as Range).Value2)); } /* Verifying T_be */ addExpectation(aSubStep, String.Format(CultureInfo.InvariantCulture, "Kernel.TrainData.BrakingParameters.T_be() == {0:0.0#}", (double)(aRange.Cells[12, 6] as Range).Value2)); /* Verifying T_bs */ addExpectation(aSubStep, String.Format(CultureInfo.InvariantCulture, "Kernel.TrainData.BrakingParameters.T_bs() == {0:0.0#}", (double)(aRange.Cells[13, 6] as Range).Value2)); /********************* BRAKE PARAMETERS (A_brake_emergency) *********************/ aSubStep = new SubStep(); aSubStep.Name = "SubStep3 - Brake parameters (A_brake_emergency)"; aStep.AddModelElement(aSubStep); /* Verifying A_brake_emergency */ double doubleValue = -1; double temp; for (int i = 16; i <= 27; i++) { temp = (double)(aRange.Cells[i, 10] as Range).Value2; if (doubleValue != temp) { if (doubleValue != -1) { addExpectation(aSubStep, String.Format(CultureInfo.InvariantCulture, "ERA_BrakingCurvesVerification.Compare\n(\n Val1 => Kernel.TrainData.BrakingParameters.ConversionModel.A_brake_emergency(V => {0:0.0########}),\n Val2 => {1:0.0########}\n)", (double)(aRange.Cells[i, 9] as Range).Value2 - 0.000000001, doubleValue)); } doubleValue = temp; double speedValue = (double)(aRange.Cells[i, 9] as Range).Value2; if (Math.Abs(speedValue - Math.Round(speedValue, 8)) > 0) { speedValue += 0.000000001; } addExpectation(aSubStep, String.Format(CultureInfo.InvariantCulture, "ERA_BrakingCurvesVerification.Compare\n(\n Val1 => Kernel.TrainData.BrakingParameters.ConversionModel.A_brake_emergency(V => {0:0.0########}),\n Val2 => {1:0.0########}\n)", speedValue, doubleValue)); } } /* Verifying V_lim EBI */ addExpectation(aSubStep, String.Format(CultureInfo.InvariantCulture, "ERA_BrakingCurvesVerification.Compare\n(\n Val1 => Kernel.TrainData.BrakingParameters.ConversionModel.A_brake_emergency.Val1.SpeedStep,\n Val2 => {0:0.0########}\n)", (double)(aRange.Cells[17, 9] as Range).Value2)); /*********************** BRAKE PARAMETERS (A_brake_service) ***********************/ aSubStep = new SubStep(); aSubStep.Name = "SubStep4 - Brake parameters (A_brake_service)"; aStep.AddModelElement(aSubStep); /* Verifying A_brake_service */ doubleValue = -1; for (int i = 16; i <= 27; i++) { temp = (double)(aRange.Cells[i, 14] as Range).Value2; if (doubleValue != temp) { if (doubleValue != -1) { addExpectation(aSubStep, String.Format(CultureInfo.InvariantCulture, "ERA_BrakingCurvesVerification.Compare\n(\n Val1 => Kernel.TrainData.BrakingParameters.ConversionModel.A_brake_service(V => {0:0.0########}),\n Val2 => {1:0.0########}\n)", (double)(aRange.Cells[i, 13] as Range).Value2 - 0.000000001, doubleValue)); } doubleValue = temp; double speedValue = (double)(aRange.Cells[i, 13] as Range).Value2; if (Math.Abs(speedValue - Math.Round(speedValue, 8)) > 0) { speedValue += 0.000000001; } addExpectation(aSubStep, String.Format(CultureInfo.InvariantCulture, "ERA_BrakingCurvesVerification.Compare\n(\n Val1 => Kernel.TrainData.BrakingParameters.ConversionModel.A_brake_service(V => {0:0.0########}),\n Val2 => {1:0.0########}\n)", speedValue, doubleValue)); } } /* Verifying V_lim BS */ addExpectation(aSubStep, String.Format(CultureInfo.InvariantCulture, "ERA_BrakingCurvesVerification.Compare\n(\n Val1 => Kernel.TrainData.BrakingParameters.ConversionModel.A_brake_service.Val1.SpeedStep,\n Val2 => {0:0.0########}\n)", (double)(aRange.Cells[17, 13] as Range).Value2)); }