public void SetUp() { _dataClientConfiguration = XmlDataConfiguration(); var client = new JustGivingDataClient(_dataClientConfiguration); _customCodeClient = CreateCustomCodeClient(client); }
public void FixtureSetUp() { var clientConfiguration = GetDefaultDataClientConfiguration() .With((clientConfig) => clientConfig.WireDataFormat = WireDataFormat.Xml); var client = new JustGivingDataClient(clientConfiguration); var customCodeClient = CreateCustomCodeClient(client); customCodeClient.SetPageCustomCodes(TestContext.KnownPageIdWithCustomCodes, new PageCustomCodes { CustomCode1 = TestContext.KnownPageCustomCode1, CustomCode2 = TestContext.KnownPageCustomCode2, CustomCode3 = TestContext.KnownPageCustomCode3, CustomCode4 = TestContext.KnownPageCustomCode4, CustomCode5 = TestContext.KnownPageCustomCode5, CustomCode6 = TestContext.KnownPageCustomCode6 }); customCodeClient.SetEventCustomCodes(TestContext.KnownEventIdForEventCustomCodes, new EventCustomCodes { CustomCode1 = TestContext.KnownEventCustomCode1, CustomCode2 = TestContext.KnownEventCustomCode2, CustomCode3 = TestContext.KnownEventCustomCode3 }); _startDate = TestContext.ValidPageSearchStartDate; _endDate = TestContext.ValidPageSearchEndDate; }
public void CanProcessLotOfData() { var clientConfiguration = GetDefaultDataClientConfiguration(); var dataClient = new JustGivingDataClient(clientConfiguration); CreatePaymentsClient(dataClient); var startDate = TestContext.StartDate; var endDate = startDate.AddMonths(3); var data = new List <PaymentSummary>(); while (data.Count == 0 && startDate <= TestContext.StartDate.AddMonths(9)) { var response = PaymentsClient.RetrievePaymentsBetween(startDate, endDate); if (response.Any()) { data.AddRange(response); } startDate = endDate.AddDays(1); endDate = startDate.AddMonths(3); } Assert.That(data.Count > 0); }
private byte[] GetPagesCreated(DataClientConfiguration clientConfiguration, DataFileFormat fileFormat) { var client = new JustGivingDataClient(clientConfiguration); var pagesClient = new PagesApi(client.HttpChannel); return(pagesClient.RetrievePagesCreated(_startDate, _endDate, fileFormat)); }
private Payment GetPayment(DataClientConfiguration clientConfiguration, int paymentId = 0) { var client = new JustGivingDataClient(clientConfiguration); CreatePaymentsClient(client); var payment = PaymentsClient.RetrieveReport<Payment>(paymentId == 0 ? TestContext.KnownGiftAidPaymentId : paymentId); return payment; }
public void GetPaymentListAndDownloadSeveralPayments() { var clientConfiguration = GetDefaultDataClientConfiguration() .With((clientConfig) => clientConfig.WireDataFormat = WireDataFormat.Json) .With((clientConfig) => clientConfig.IsZipSupportedByClient = true); var client = new JustGivingDataClient(clientConfiguration); var paymentClient = new PaymentsApi(client.HttpChannel); int count = 0; const int numberToDownload = 10; var payments = paymentClient.RetrievePaymentsBetween(new DateTime(2012, 06, 01), new DateTime(2012, 06, 30)); foreach (var payment in payments) { if (count >= numberToDownload) { break; } var report = client.Payment.RetrieveReport <Payment>(payment.PaymentRef); Assert.That(report, Is.Not.Null); count++; } }
public void CanSetMultipleCustomCodes() { var clientConfiguration = XmlDataClientConfiguration(); var client = new JustGivingDataClient(clientConfiguration); var response = client.CustomCodes.SetEventCustomCodes(new[] { new EventCustomCodesListItem { EventId = TestContext.KnownEventId, CustomCode1 = "foo" }, new EventCustomCodesListItem { EventId = TestContext.KnownEventId + 1, CustomCode1 = "bar" } }); Assert.That(response.Count(r => r.Status == 200), Is.GreaterThanOrEqualTo(1)); }
public void BadEventId_DateRange_Returns404() { var clientConfiguration = DefaultClientConfiguration(); var client = new JustGivingDataClient(clientConfiguration); var pagesClient = CreatePagesClient(client); Assert.Throws<ResourceNotFoundException>(() => pagesClient.RetrievePagesCreated(DateTime.Now.AddMonths(-12), DateTime.Now.AddMonths(-10), -1)); }
public void ErrorIfAuthenticationFails() { _dataClientConfiguration = GetDefaultDataClientConfiguration().With((clientConfig) => clientConfig.Password = "******"); _client = new JustGivingDataClient(_dataClientConfiguration); var paymentClient = new PaymentsApi(_client.HttpChannel); var response = paymentClient.NoOp(); Assert.That(response, Is.EqualTo(HttpStatusCode.Unauthorized)); }
private Payment GetPayment(DataClientConfiguration clientConfiguration, int paymentId = 0) { var client = new JustGivingDataClient(clientConfiguration); CreatePaymentsClient(client); var payment = PaymentsClient.RetrieveReport <Payment>(paymentId == 0 ? TestContext.KnownGiftAidPaymentId : paymentId); return(payment); }
public void CanDoNoOp() { _dataClientConfiguration = GetDefaultDataClientConfiguration(); _client = new JustGivingDataClient(_dataClientConfiguration); var paymentClient = new PaymentsApi(_client.HttpChannel); var response = paymentClient.NoOp(); Assert.That(response, Is.EqualTo(HttpStatusCode.OK)); }
public void BadEventId_DateRange_Returns404() { var clientConfiguration = DefaultClientConfiguration(); var client = new JustGivingDataClient(clientConfiguration); var pagesClient = CreatePagesClient(client); Assert.Throws <ResourceNotFoundException>(() => pagesClient.RetrievePagesCreated(DateTime.Now.AddMonths(-12), DateTime.Now.AddMonths(-10), -1)); }
public void ResourceExists_ReturnsPayment_RawJson() { var clientConfiguration = GetDefaultDataClientConfiguration() .With((clientConfig) => clientConfig.WireDataFormat = WireDataFormat.Json); var client = new JustGivingDataClient(clientConfiguration); CreatePaymentsClient(client); var payment = PaymentsClient.RetrieveReport<Payment>(TestContext.KnownDonationPaymentId); Assert.IsNotNull(payment); }
public void DateRange_HasContent() { var clientConfiguration = DefaultClientConfiguration(); var client = new JustGivingDataClient(clientConfiguration); var pagesClient = CreatePagesClient(client); var report = pagesClient.RetrievePagesCreated(_startDate, _endDate, TestContext.KnownEventIdWithPage); Assert.That(report.Pages.Count, Is.GreaterThan(0)); }
public void PagesModified_DateRange_HasContent() { var clientConfiguration = GetDefaultDataClientConfiguration(); var client = new JustGivingDataClient(clientConfiguration); var pagesClient = CreatePagesClient(client); var report = pagesClient.RetrievePagesModified(_startDate, _endDate); Assert.That(report.Pages.Count, Is.GreaterThan(0)); }
public void DateRange_HasContent() { var clientConfiguration = GetDefaultDataClientConfiguration(); var client = new JustGivingDataClient(clientConfiguration); var pagesClient = CreatePagesClient(client); var report = pagesClient.RetrievePagesCreated(_startDate, _endDate); Assert.That(report.Pages.Count, Is.GreaterThan(0)); }
public void EventCustomCodes_Existing_ReturnsResult(string customCode1, string customCode2, string customCode3) { var clientConfiguration = XmlDataClientConfiguration(); var client = new JustGivingDataClient(clientConfiguration); var pagesClient = CreatePagesClient(client); var report = pagesClient.Search(new PageCreatedSearchQuery { EventCustomCode1 = customCode1, EventCustomCode2 = customCode2, EventCustomCode3 = customCode3, IsActivePage = TestContext.PageStatus }, _startDate, _endDate); Assert.That(report.Pages.Count, Is.GreaterThan(0)); }
public void PageCustomCodes_Existing_ReturnsResult(string pageCustomCode1, string pageCustomCode2, string pageCustomCode3, string pageCustomCode4, string pageCustomCode5, string pageCustomCode6) { var clientConfiguration = XmlDataClientConfiguration(); var client = new JustGivingDataClient(clientConfiguration); var pagesClient = CreatePagesClient(client); var report = pagesClient.Search(new PageCreatedSearchQuery { PageCustomCode1 = pageCustomCode1, PageCustomCode2 = pageCustomCode2, PageCustomCode3 = pageCustomCode3, PageCustomCode4 = pageCustomCode4, PageCustomCode5 = pageCustomCode5, PageCustomCode6 = pageCustomCode6 }, _startDate, _endDate); Assert.That(report.Pages.Count, Is.GreaterThan(0)); }
public void DateRange_CannotExceedThreeMonths() { // Arrange var clientConfiguration = GetDefaultDataClientConfiguration(); var client = new JustGivingDataClient(clientConfiguration); var pagesClient = CreatePagesClient(client); var excep = Assert.Throws<ErrorResponseException>(() => pagesClient.RetrievePagesCreated(new DateTime(2011, 4, 28), DateTime.Now)); Assert.That(excep.Message.Contains("400")); }
public void ResourceExists_ReturnsPayment_RawJson() { var clientConfiguration = GetDefaultDataClientConfiguration() .With((clientConfig) => clientConfig.WireDataFormat = WireDataFormat.Json); var client = new JustGivingDataClient(clientConfiguration); CreatePaymentsClient(client); var payment = PaymentsClient.RetrieveReport <Payment>(TestContext.KnownDonationPaymentId); Assert.IsNotNull(payment); }
public void AllPagesBelongToEvent() { var clientConfiguration = DefaultClientConfiguration(); var client = new JustGivingDataClient(clientConfiguration); var pagesClient = CreatePagesClient(client); var report = pagesClient.RetrievePagesCreated(_startDate, _endDate, TestContext.KnownEventIdWithPage); Assert.That(report.Pages.Count(p => p.Event.Id == TestContext.KnownEventIdWithPage), Is.GreaterThan(0)); Assert.That(report.Pages.Count(p => p.Event.Id != TestContext.KnownEventIdWithPage), Is.EqualTo(0)); }
public void ResourceDoesNotExist_ThrowsNotFoundException() { var clientConfiguration = GetDefaultDataClientConfiguration() .With((clientConfig) => clientConfig.WireDataFormat = WireDataFormat.Json) .With((clientConfig) => clientConfig.IsZipSupportedByClient = true); var client = new JustGivingDataClient(clientConfiguration); CreatePaymentsClient(client); Assert.Throws<ResourceNotFoundException>(() => PaymentsClient.RetrieveReport<Payment>(BadPaymentId)); }
public void DateRange_ContentIsWithinBounds() { var clientConfiguration = GetDefaultDataClientConfiguration(); var client = new JustGivingDataClient(clientConfiguration); var pagesClient = CreatePagesClient(client); var report = pagesClient.RetrievePagesCreated(_startDate, _endDate); // Assert Assert.That(report.Pages.Count(p => p.CreatedDate < _startDate), Is.EqualTo(0)); Assert.That(report.Pages.Count(p => p.CreatedDate > _endDate), Is.EqualTo(0)); }
public void PagesModified_DateRange_CannotExceedThreeMonths() { // Arrange var clientConfiguration = GetDefaultDataClientConfiguration(); var client = new JustGivingDataClient(clientConfiguration); var pagesClient = CreatePagesClient(client); var excep = Assert.Throws <ErrorResponseException>(() => pagesClient.RetrievePagesModified(new DateTime(2011, 4, 28), DateTime.Now)); Assert.That(excep.Message.Contains("400")); }
public void FilterByStatus_ExcludesExpectedResult() { var clientConfiguration = XmlDataClientConfiguration(); var client = new JustGivingDataClient(clientConfiguration); var report = client.Pages.Search(new PageCreatedSearchQuery { PageCustomCode1 = TestContext.KnownPageCustomCode1, IsActivePage = !TestContext.PageStatus }, _startDate, _endDate); Assert.That(report.Pages.Count, Is.EqualTo(0)); }
public void AuthenticationSuccess_DoesNotReturnHttp401Unauthorised() { var clientConfiguration = GetDefaultDataClientConfiguration() .With((clientConfig) => clientConfig.IsZipSupportedByClient = true); var client = new JustGivingDataClient(clientConfiguration); var paymentClient = new PaymentsApi(client.HttpChannel); var payment = paymentClient.RetrieveReport<Payment>(_paymentId); Assert.That(payment.HttpStatusCode, Is.Not.EqualTo(HttpStatusCode.Unauthorized)); }
public void DateRange_CannotExceedThreeMonths() { var clientConfiguration = GetDefaultDataClientConfiguration(); var startDate = DateTime.Now.Date.AddYears(-2); var endDate = startDate.AddYears(1); var client = new JustGivingDataClient(clientConfiguration); CreatePaymentsClient(client); var exception = Assert.Throws<ErrorResponseException>(() => PaymentsClient.RetrievePaymentsBetween(startDate, endDate)); Assert.That(exception.Message.Contains("400")); }
public void FilterByAppeal_ExcludesExpectedResult() { var clientConfiguration = XmlDataClientConfiguration(); var client = new JustGivingDataClient(clientConfiguration); var pagesClient = CreatePagesClient(client); var report = pagesClient.Search(new PageCreatedSearchQuery { PageCustomCode1 = TestContext.KnownPageCustomCode1, AppealName = "flurble" }, _startDate, _endDate); Assert.That(report.Pages.Count, Is.EqualTo(0)); }
public void AuthenticationSuccess_DoesNotReturnHttp401Unauthorised() { var clientConfiguration = GetDefaultDataClientConfiguration() .With((clientConfig) => clientConfig.IsZipSupportedByClient = true); var client = new JustGivingDataClient(clientConfiguration); var paymentClient = new PaymentsApi(client.HttpChannel); var payment = paymentClient.RetrieveReport <Payment>(_paymentId); Assert.That(payment.HttpStatusCode, Is.Not.EqualTo(HttpStatusCode.Unauthorized)); }
public void EventCustomCodes_SomeExistingSomeNot_NoResult(string customCode1, string customCode2, string customCode3) { var clientConfiguration = XmlDataClientConfiguration(); var client = new JustGivingDataClient(clientConfiguration); var pagesClient = CreatePagesClient(client); var report = pagesClient.Search(new PageCreatedSearchQuery { EventCustomCode1 = customCode1, EventCustomCode2 = customCode2, EventCustomCode3 = customCode3 }, new DateTime(2004, 1, 1), new DateTime(2004, 2, 1)); Assert.That(report.Pages.Count, Is.EqualTo(0)); }
public void ResourceDoesNotExist_ThrowsNotFoundException() { var clientConfiguration = GetDefaultDataClientConfiguration() .With((clientConfig) => clientConfig.WireDataFormat = WireDataFormat.Json) .With((clientConfig) => clientConfig.IsZipSupportedByClient = true); var client = new JustGivingDataClient(clientConfiguration); CreatePaymentsClient(client); Assert.Throws <ResourceNotFoundException>(() => PaymentsClient.RetrieveReport <Payment>(BadPaymentId)); }
public void FilterByExpiresBeforeDate_ExcludesExpectedResult() { var clientConfiguration = XmlDataClientConfiguration(); var client = new JustGivingDataClient(clientConfiguration); var pagesClient = CreatePagesClient(client); var report = pagesClient.Search(new PageCreatedSearchQuery { PageCustomCode1 = TestContext.KnownPageCustomCode1, PageExpiresBefore = TestContext.KnownExpiryDate.AddDays(-1) }, new DateTime(2004, 1, 1), new DateTime(2004, 2, 1)); Assert.That(report.Pages.Count, Is.EqualTo(0)); }
public void When_GettingPaymentReportForKnownPaymentId_DataIsReturned(PaymentType paymentType, DataFileFormat fileFormat) { var clientConfiguration = GetDefaultDataClientConfiguration() .With((clientConfig) => clientConfig.WireDataFormat = WireDataFormat.Other); var client = new JustGivingDataClient(clientConfiguration); CreatePaymentsClient(client); var payment = PaymentsClient.RetrieveReport(GetPaymentId(paymentType), fileFormat); AssertResponseDoesNotHaveAnError(payment); Assert.IsNotNull(payment); }
public void DateRange_CannotExceedThreeMonths() { var clientConfiguration = GetDefaultDataClientConfiguration(); var startDate = DateTime.Now.Date.AddYears(-2); var endDate = startDate.AddYears(1); var client = new JustGivingDataClient(clientConfiguration); CreatePaymentsClient(client); var exception = Assert.Throws <ErrorResponseException>(() => PaymentsClient.RetrievePaymentsBetween(startDate, endDate)); Assert.That(exception.Message.Contains("400")); }
public void AuthenticationFailure_ReturnsHttp401Unauthorised() { var clientConfiguration = GetDefaultDataClientConfiguration() .With((clientConfig) => clientConfig.Username = "") .With((clientConfig) => clientConfig.Password = ""); var client = new JustGivingDataClient(clientConfiguration); var paymentClient = new PaymentsApi(client.HttpChannel); var exception = Assert.Throws<ErrorResponseException>(() => paymentClient.RetrieveReport<Payment>(_paymentId)); Assert.That(exception.Message.Contains("401")); }
public void AuthenticationFailure_ReturnsHttp401Unauthorised() { var clientConfiguration = GetDefaultDataClientConfiguration() .With((clientConfig) => clientConfig.Username = "") .With((clientConfig) => clientConfig.Password = ""); var client = new JustGivingDataClient(clientConfiguration); var paymentClient = new PaymentsApi(client.HttpChannel); var exception = Assert.Throws <ErrorResponseException>(() => paymentClient.RetrieveReport <Payment>(_paymentId)); Assert.That(exception.Message.Contains("401")); }
public void HasContent(DataFileFormat fileFormat) { var clientConfiguration = GetDefaultDataClientConfiguration() .With((clientConfig) => clientConfig.WireDataFormat = WireDataFormat.Other); var client = new JustGivingDataClient(clientConfiguration); var pagesClient = CreatePagesClient(client); var data = pagesClient.RetrievePagesCreated(_startDate, _endDate, fileFormat); Assert.That(data, Is.Not.Null); AssertResponseDoesNotHaveAnError(data); Assert.That(data.Length, Is.GreaterThan(0)); }
public void FilterByExpiryDate_IncludesExpectedResult() { var clientConfiguration = XmlDataClientConfiguration(); var client = new JustGivingDataClient(clientConfiguration); var pagesClient = CreatePagesClient(client); var report = pagesClient.Search(new PageCreatedSearchQuery { PageCustomCode1 = TestContext.KnownPageCustomCode1, PageExpiresAfter = new DateTime(2000, 01, 01), //2017-03-08 00:00:00.000 PageExpiresBefore = new DateTime(2020, 01, 01) }, _startDate, _endDate); Assert.That(report.Pages.Count, Is.GreaterThan(0)); }
public void CanGetDataBetweenTwoDates() { var clientConfiguration = GetDefaultDataClientConfiguration(); var dataClient = new JustGivingDataClient(clientConfiguration); CreatePaymentsClient(dataClient); var startDate = TestContext.StartDate; var endDate = startDate.AddMonths(3); var response = PaymentsClient.RetrievePaymentsBetween(startDate, endDate); Assert.IsNotNull(response); Assert.That(response.Count(), Is.GreaterThan(0)); Assert.That(response.FirstOrDefault(i => i.PaymentDate > endDate), Is.Null); Assert.That(response.FirstOrDefault(i => i.PaymentDate < startDate), Is.Null); }
public void When_GettingPaymentReportForKnownPaymentId_DataIsReturned_AndCanBeWrittenInValidFormat(PaymentType paymentType, DataFileFormat fileFormat) { var clientConfiguration = GetDefaultDataClientConfiguration() .With((clientConfig) => clientConfig.WireDataFormat = WireDataFormat.Other); var client = new JustGivingDataClient(clientConfiguration); CreatePaymentsClient(client); var payment = PaymentsClient.RetrieveReport(GetPaymentId(paymentType), fileFormat); SpreadsheetInfo.SetLicense(TestContext.GemBoxSerial); var sheet = new ExcelFile(); using (var stream = new MemoryStream(payment)) { sheet.LoadCsv(stream, CsvType.CommaDelimited); stream.Close(); } AssertResponseDoesNotHaveAnError(payment); Assert.That(sheet.Worksheets.Count, Is.GreaterThan(0)); }
public void GetPaymentListAndDownloadSeveralPayments() { var clientConfiguration = GetDefaultDataClientConfiguration() .With((clientConfig) => clientConfig.WireDataFormat = WireDataFormat.Json) .With((clientConfig) => clientConfig.IsZipSupportedByClient = true); var client = new JustGivingDataClient(clientConfiguration); var paymentClient = new PaymentsApi(client.HttpChannel); int count = 0; const int numberToDownload = 10; var payments = paymentClient.RetrievePaymentsBetween(new DateTime(2012, 06, 01), new DateTime(2012, 06, 30)); foreach(var payment in payments) { if (count >= numberToDownload) break; var report = client.Payment.RetrieveReport<Payment>(payment.PaymentRef); Assert.That(report, Is.Not.Null); count++; } }
public void CanProcessLotOfData() { var clientConfiguration = GetDefaultDataClientConfiguration(); var dataClient = new JustGivingDataClient(clientConfiguration); CreatePaymentsClient(dataClient); var startDate = TestContext.StartDate; var endDate = startDate.AddMonths(3); var data = new List<PaymentSummary>(); while (data.Count == 0 && startDate <= TestContext.StartDate.AddMonths(9)) { var response = PaymentsClient.RetrievePaymentsBetween(startDate, endDate); if (response.Any()) { data.AddRange(response); } startDate = endDate.AddDays(1); endDate = startDate.AddMonths(3); } Assert.That(data.Count > 0); }
public void IsValidCsvData(DataFileFormat fileFormat) { var clientConfiguration = GetDefaultDataClientConfiguration() .With((clientConfig) => clientConfig.WireDataFormat = WireDataFormat.Other); var client = new JustGivingDataClient(clientConfiguration); var pagesClient = CreatePagesClient(client); var startDate = new DateTime(2011,4,28); var endDate = new DateTime(2011,6,28); var data = pagesClient.RetrievePagesCreated(startDate, endDate, fileFormat); SpreadsheetInfo.SetLicense(TestContext.GemBoxSerial); var sheet = new ExcelFile(); using (var stream = new MemoryStream(data)) { LoadDataInToWorkSheet(stream, sheet, fileFormat); } Assert.That(sheet.Worksheets.Count, Is.GreaterThan(0)); }
private byte[] GetPagesCreated(DataClientConfiguration clientConfiguration, DataFileFormat fileFormat) { var client = new JustGivingDataClient(clientConfiguration); var pagesClient = new PagesApi(client.HttpChannel); return pagesClient.RetrievePagesCreated(_startDate, _endDate, fileFormat); }