/* * This method is abstracted/private and so is only available when you do INUnitClient cli = new NUNitClient(); * client calls this method to post test data to Stratus * */ void ISiaClient.Post() { var testResultData = GetTestResultData(this.FileName); //We will assume we formatted test data into JSON var jsonTestResultData = FormatTestResultData(TestDataFormatter.JSON, testResultData); //Populate SIAModel with formmatted data SIAModel = new SIAModel(); SIAModel.ProjectName = jsonTestResultData[0]; SIAModel.TestID = jsonTestResultData[1]; SIAModel.TestStatus = jsonTestResultData[2]; //Using the compatible SIAModel that Stratus understands, POST result Console.WriteLine($"Posting to Stratus: \nProject Name: {SIAModel.ProjectName}\nTest ID: {SIAModel.TestID}\nStatus: {SIAModel.TestStatus}\n..."); }
/* * when client is incompatible with the reporter, an adapter is then used. * Automapping will be necessary here to sync the contract/payload needed for posting to reporter. * adapter calls this method of the client to help post test data a reporter not supported by the client. * */ public void PostTestResults(string testData) { var testResultData = testData; //We will assume we formatted test data into JSON var jsonTestResultData = FormatTestResultData(TestDataFormatter.JSON, testResultData); //Populate NUnitModel with formmatted data NUnitModel = new NUnitModel(); NUnitModel.ProjName = jsonTestResultData[0]; NUnitModel.TestId = jsonTestResultData[1]; NUnitModel.TestStatus = jsonTestResultData[2]; //Perform Any automapping needed. var SIAModel = new SIAModel(); SIAModel.ProjectName = NUnitModel.ProjName; SIAModel.TestID = NUnitModel.TestId; SIAModel.TestStatus = NUnitModel.TestStatus; //Post to Stratus using its expected payload in SIAModel format Console.WriteLine($"Posting to Stratus: \nProject Name: {SIAModel.ProjectName}\nTest ID: {SIAModel.TestID}\nStatus: {SIAModel.TestStatus}\n..."); }