public void AdditionalRequestSettingsTest() { var reqeust = new DateTimeConverRequest { DateTimes = new[] { System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }, FromTimeZone = "Asia/Tokyo", ToTimeZone = "UTC" }; var handler = new DefaultManager(); // additional request settings such as HTTP method, endpoint, content type, and URL parameters. They will override values specified in the data contact attribute using (LogHelper.LoggerForCurrentTest.EnterReproStep("Sending a request with additional settings.")) { var response = handler.Send(reqeust, additionalSettings: new DefaultManager.AdditionalRequestSettings { HttpMethod = Porters.TestCoreFramework.Enums.HttpMethod.PUT, UrlParameters = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("urlParam[[1]", "val1+1"), new KeyValuePair <string, string>("urlParam[2]]", "val2+2"), new KeyValuePair <string, string>("urlParam[[1]", "val1+1") //we can have repeating parameters in URL }, Endpoint = "privateapi/noauth/datetime/convert/?test", ContentType = "application/pdf" }); PrAssert.That(response, PrIs.Not.SuccessfulResponse()); } }
public void SimpleNegativeTest() { var reqeust = new DateTimeConverRequest { DateTimes = new[] { System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }, FromTimeZone = "Asia/Tokyo", ToTimeZone = "UTC" }; var handler = new DefaultManager(); // sending a request without custom handler and without specifying response data contract. Also a request transformation function is registered var response = handler.Send(reqeust, Transformation); PrAssert.That(response, PrIs.Not.SuccessfulResponse()); }
private void PerformDateTimeConvertTest(String from, String to, String[] dateTimes, Action <PrivateApiResponse <DateTimeConvertResponse> > verifyAction) { var request = new DateTimeConverRequest() { DateTimes = dateTimes, FromTimeZone = from, ToTimeZone = to }; var handler = new DefaultManager(); var response = handler.Send <DateTimeConvertResponse>(request); verifyAction(response); }
[TestCaseEx(SuppressAuthentication = true)] // to disable automatic authentication. Otherwise it will be performed either during the first request, or on demand, with method Authenticate. public void SimplePositiveTest() { var reqeust = new DateTimeConverRequest { DateTimes = new[] { System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }, FromTimeZone = "Asia/Tokyo", ToTimeZone = "UTC" }; var handler = new DefaultManager(); using (LogHelper.LoggerForCurrentTest.EnterReproStep("Sending a request using DefaultManager.")) { // sending a request without custom handler. All connection information will be taken from PrivateApiDataContractAttribute applied to data contract var response = handler.Send <DateTimeConvertResponse>(reqeust); PrAssert.That(response, PrIs.SuccessfulResponse <DateTimeConvertResponse>()); PrAssert.That(response.Result.DateTimes, Is.Not.Null.And.All.Not.Null.And.All.Not.Empty); } }