I have following cases and conditions:
I need to loop through some testCases (passed/failed)check and certify one key. Basicaly i am checking some testcases and key validation
Case 1- All test cases execute and pass, certificate key found and certified
Result-test cases found. All test cases passed.Data certified.
Case 2- Some or all test cases failed, certificate key found and certified
Result-
WARNING: test cases found. The following test test cases failed:
Test case ID '1'
Test case ID '123'
Test case ID '4223'
Test case ID '321'
Data certified.
Case 3- Some/all test cases failed, certificate key NOT found
Result -
WARNING: test cases found. The following test test cases failed:
Test case ID '1'
Test case ID '123'
Test case ID '4223'
Test case ID '321'
WARNING: No data certificate key found, data not certified'
Case 4 – All test cases execute and pass, certificate key found and NOT certified
Result -
test cases found. All test cases passed.
WARNING: data certificate key found, Certification key not valid, data not certified'
1.KEY CAN BE NULL
2.KEY CAN BE THERE BUT NOT THE EXACT KEY
3.KEY IS THERE,EXACT ONE-CERTIFIED
4.TEST RESULT WILL BE PASSED OR FAILED
How can i loop through all these conditions and assign values and error messages based on this loop?
WHAT I HAVE TRIED AND STUCK:
public Task GetTestResults(string infoset){
//getting "resultDataSet" from DB
var table = resultDataSet.Tables[0];
var results = table
.Rows
.Cast()
?.Select(x => new ResultModel
{
TestCases = x["TestCases"] as string,
Message = x["ErrorMessage"] as string,
ResultStatus = x["ResultStatus"] as string,
DataKey = x["ValidationKey"] as string,
TestType = x["TestType"] as string
});
// TestCases = array of multiple test cases
// Message =error msg based on case we have to add
// ResultStatus =Passed or Failed in test cases
// DataKey =some key like 4252634343567TSA
// TestType =smoke/unit test
bool isValidKey = await _Ichekkey.IsValidcertificateKey(string key)
int testCasesCount = Convert.ToInt32(table.Rows[0]["TestCases"]);
bool keyFound;
bool alltcPassed;
foreach (var data in results)
{
if (!String.IsNullOrEmpty(data.DataKey))
{
keyFound = true;
List FailedTestCases = new List();
if (data.ResultStatus == "Failed")
{
FailedTestCases.Add(data.TestCases);
}
if (FailedTestCases.Count > 0)
{
alltcPassed = false;
}
else
{
// passed
alltcPassed = true;
}
}
// blocked here confused to continue to check and assign the case results and messages
}
return result;
}
Can anyone help me? Thanks in advance...