public void InvalidGetCounty() { string Test_Result = String.Empty; string Message = String.Empty; try { for (int i = 0; i < invalidCountryPrimaryKeyId.Count; i++) { //Call WebService method Country actual = target.GetCountry(Convert.ToInt32(invalidCountryPrimaryKeyId[i])); if (i == 0) { Test_Result = _Assert.Execute(() => _Assert.AssertTrue(actual == null, "Reponse should be an error message", root)); Message = "Verify that an error message is returned when a junk Value is given as an input"; } else { Test_Result = _Assert.Execute(() => _Assert.AssertTrue(actual == null, "Reponse should be NULL", root)); Message = "Verify that an error message is returned when a Blank Value is given as an input"; } if (Test_Result == "") { _writer.WriteLog(serviceName, "InvalidGetCounty", DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString(), Message, SBWSCommon.StatusLevelOptions.PASS.ToString(), Test_Result, root); } else { _writer.WriteLog(serviceName, "InvalidGetCounty", DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString(), Message, SBWSCommon.StatusLevelOptions.FAIL.ToString(), Test_Result, root); //throw new Exception(Test_Result); } } } catch (Exception) { //throw; } }
public void GetCourses_valid() { #region Local var GetCoursesRequest getCoursesRequest = new GetCoursesRequest(); GetCoursesResponse getCoursesResponse = new GetCoursesResponse(); CourseResponse courseResponse = new CourseResponse(); Course[] Course = null; StringBuilder sbError = new StringBuilder(); string Test_Result_Upsert = String.Empty; #endregion try { for (int i = 0; i < 5; i++) { if (i == 0)//If Provided ContactCrmId has entitlement for the given ProductCrmId { getCoursesRequest.contactCrmId = ValidNonCebUser[0]; getCoursesRequest.productCrmId = ProductCrmId; } else if (i == 1)//method should return all the courses with in a given ProductCrmId(Course bundle) { getCoursesRequest.contactCrmId = null; getCoursesRequest.productCrmId = ProductCrmId; } else if (i == 2)//number of courses returned in response object of method is mapped with SFDC data { getCoursesRequest.contactCrmId = ValidNonCebUser[0]; getCoursesRequest.productCrmId = ProductCrmId; } try { getCoursesResponse = target.GetCourses(getCoursesRequest); courseResponse = getCoursesResponse.GetCoursesResult; if (courseResponse.Courses.Length > 0) { Course = courseResponse.Courses; } bool IsEntitledChk = true; if (i == 0 || i == 1) { //Validate Course having isentite true for (int j = 0; j < Course.Length; j++) { if (Course[j].IsEntitled == false) { IsEntitledChk = false; } } } //TODO: Call SFDC replica for validation of return courses if (i == 0) { Test_Result_Upsert = _Assert.Execute( () => _Assert.AssertTrue(getCoursesResponse != null, "getCoursesResponse return null", root), () => _Assert.AssertTrue(courseResponse.Courses.Length > 0, "courseResponse return count 0", root), () => _Assert.AssertTrue(IsEntitledChk == true, "IsEntitledChk return false against getcourse", root), () => _Assert.AssertTrue(Course[0].CourseCategory != null, "CourseCategory is null", root), () => _Assert.AssertTrue(Course[0].CourseCrmId != null, "CourseCrmId is null", root), () => _Assert.AssertTrue(Course[0].CourseName != null, "CourseName is null", root), () => _Assert.AssertTrue(Course[0].CourseNumber != null, "CourseNumber is null", root) ); if (Test_Result_Upsert == "") { if (i == 0) { _writer.WriteLog(serviceName, "GetCourses_valid|ContactCrmId::" + getCoursesRequest.contactCrmId + "|ProductCrmId::" + getCoursesRequest.productCrmId, DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString(), "Call GetCourses method If Provided ContactCrmId has entitlement for the given ProductCrmId than, IsEntitled response object is true ", SBWSCommon.StatusLevelOptions.PASS.ToString(), "To Verify that fields available while calling GetCourses Method CourseCategory[0]:" + Course[0].CourseCategory + "|CourseCrmId[0]:" + Course[0].CourseCrmId + "|CourseName[0]:" + Course[0].CourseName + "|CourseNumber[0]:" + Course[0].CourseNumber + "|IsEntitled response object is true", root); } } else { _writer.WriteLog(serviceName, "GetCourses_valid|ContactCrmId::" + getCoursesRequest.contactCrmId + "|ProductCrmId::" + getCoursesRequest.productCrmId, DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString(), "Call GetCourses method If Provided ContactCrmId has entitlement for the given ProductCrmId than, IsEntitled response object is true ", SBWSCommon.StatusLevelOptions.FAIL.ToString(), "To Verify that fields available while calling GetCourses Method CourseCategory[0]:" + Course[0].CourseCategory + "|CourseCrmId[0]:" + Course[0].CourseCrmId + "|CourseName[0]:" + Course[0].CourseName + "|CourseNumber[0]:" + Course[0].CourseNumber + "|IsEntitled response object is true|Error:" + Test_Result_Upsert, root); } } else if (i == 1) { Test_Result_Upsert = _Assert.Execute( () => _Assert.AssertTrue(getCoursesResponse != null, "getCoursesResponse return null", root), () => _Assert.AssertTrue(courseResponse.Courses.Length > 0, "courseResponse return count 0", root), () => _Assert.AssertTrue(IsEntitledChk == true, "IsEntitledChk return false against getcourse", root) ); if (Test_Result_Upsert == "") { _writer.WriteLog(serviceName, "GetCourses_valid|ContactCrmId::" + getCoursesRequest.contactCrmId + "|ProductCrmId::" + getCoursesRequest.productCrmId, DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString(), "Call GetCourses method should return all the courses with in a given ProductCrmId(Course bundle) ", SBWSCommon.StatusLevelOptions.PASS.ToString(), "To Verify that fields available while calling GetCourses Method | Course lenth:" + Course.Length, root); } else { _writer.WriteLog(serviceName, "GetCourses_valid|ContactCrmId::" + getCoursesRequest.contactCrmId + "|ProductCrmId::" + getCoursesRequest.productCrmId, DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString(), "Call GetCourses method should return all the courses with in a given ProductCrmId(Course bundle) ", SBWSCommon.StatusLevelOptions.FAIL.ToString(), "To Verify that fields available while calling GetCourses Method | Course lenth:" + Course.Length + "+Error:" + Test_Result_Upsert, root); } } else if (i == 2) { Test_Result_Upsert = _Assert.Execute( () => _Assert.AssertTrue(getCoursesResponse != null, "getCoursesResponse return null", root), () => _Assert.AssertTrue(courseResponse.Courses.Length > 0, "courseResponse return count 0", root), () => _Assert.AssertTrue(IsEntitledChk == true, "IsEntitledChk return false against getcourse", root) ); if (Test_Result_Upsert == "") { _writer.WriteLog(serviceName, "GetCourses_valid|ContactCrmId::" + getCoursesRequest.contactCrmId + "|ProductCrmId::" + getCoursesRequest.productCrmId, DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString(), "Call GetCourses method should return all the courses with in a given ProductCrmId(Course bundle) ", SBWSCommon.StatusLevelOptions.PASS.ToString(), "To Verify that fields available while calling GetCourses Method | Course lenth:" + Course.Length, root); } else { _writer.WriteLog(serviceName, "GetCourses_valid|ContactCrmId::" + getCoursesRequest.contactCrmId + "|ProductCrmId::" + getCoursesRequest.productCrmId, DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString(), "Call GetCourses method should return all the courses with in a given ProductCrmId(Course bundle) ", SBWSCommon.StatusLevelOptions.FAIL.ToString(), "To Verify that fields available while calling GetCourses Method | Course lenth:" + Course.Length + "+Error:" + Test_Result_Upsert, root); } } } catch (Exception ex0) { throw; } } } catch (Exception ex) { throw; } finally { getCoursesRequest = null; getCoursesResponse = null; } }