Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

i have some logical and architectural doubts here.I am stuck on some bad logic and architect.Somebody
please help me to solve this issue.I have a dot net core 3.1 app.I need to loop through some testCasesCountand i need to 
check and certify one key Based on that i need to do this all..Basicaly i am checking some testcases and key validation.Please find below conditions

1.KEY CAN BE NULL------- NOT CERTIFIED
2.KEY CAN BE THERE BUT NOT THE EXACT KEY---------NOT CERTIFIED
3.KEY IS THERE,EXACT ONE-------CERTIFIED
4.ResultStatus =This is test case result status.Passed or Failed in test cases


                               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



           ResultStatus , DataKey       values can determine following cases         

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 OR 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'


 how i can loop through all cases? 
 





                       

What I have tried:

 i have this method:-

        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,// array of multiple test cases Test case ID '1',Test case ID '123' etc
                                Message = x["ErrorMessage"] as string, //error  msg
                                ResultStatus = x["ResultStatus"] as string //Passed or Failed
                                DataKey = x["ValidationKey"] as string,//some key like 4252634343567TSA
                                TestType = x["TestType"] as string //smoke/unit test
                            });


bool isValidKey = await _Ichekkey.IsValidcertificateKey(string key)//DataKey i have to use .Any better way to call this method otherthan this in architecturalway?

  int testCasesCount = Convert.ToInt32(table.Rows[0]["TestCases"]);
  
  // var results contain all information to loop how i can do that loop with above cases.
  
        }
  




 I am stuck on here  how i can loop through all cases? (results )
 which is the right way to call bool isValidKey = await _Ichekkey.IsValidcertificateKey(string key)
Posted
Updated 30-Jun-21 6:56am
v3
Comments
[no name] 30-Jun-21 13:38pm    
foreach ( var result in results ) { ... }
[no name] 1-Jul-21 0:13am    
I am aware of this syntax but how I can loop through multiple cases and assign the values and error message i have blocked here


public Task<resultmodel> GetTestResults(string infoset){

//getting "resultDataSet" from DB

var table = resultDataSet.Tables[0];

var results = table
.Rows
.Cast<datarow>()
?.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.SyntheticDataKey))
{
keyFound = true;

List<string> FailedTestCases = new List<string>();

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;
}
[no name] 1-Jul-21 16:57pm    
Seems you should be returning a list / collection of results.
[no name] 2-Jul-21 2:44am    
didnt get you sir

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900