public void RegisterWhenProvidedWithADomainThatDoesNotExist_ThrowsException(WireDataFormat format) { const string domainThatDoesNotExistOnJustGiving = "Incorrect.com"; var client = TestContext.CreateClientValidCredentials(format); client.SetWhiteLabelDomain(domainThatDoesNotExistOnJustGiving); var pageClient = new PageApi(client.HttpChannel); var pageShortName = "api-test-" + Guid.NewGuid(); var pageCreationRequest = new RegisterPageRequest { ActivityType = null, PageShortName = pageShortName, PageTitle = "api test", EventName = "The Other Occasion of ApTest and APITest", CharityId = 2050, EventId = 1, TargetAmount = 20M, EventDate = DateTime.Now.AddDays(5) }; var exception = Assert.Throws<ErrorResponseException>(() => pageClient.Create(pageCreationRequest)); Assert.That(exception.Response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest)); }
public void Register_WhenProvidedWithANonDefaultDomain_CreatesANewPageOnThatDomain(WireDataFormat format) { var client = TestContext.CreateClientValidRflCredentials(format); var domain = TestConfigurationsHelper.GetProperty<ITestConfigurations, string>(x => x.RflDomain); client.SetWhiteLabelDomain(domain); var pageClient = new PageApi(client.HttpChannel); var pageShortName = "api-test-" + Guid.NewGuid(); var pageCreationRequest = new RegisterPageRequest { ActivityType = null, Attribution = null, CharityId = 2050, PageShortName = pageShortName, PageTitle = "Page created on domain " + domain + " by an integration test", EventDate = null, EventName = null, EventId = TestConfigurationsHelper.GetProperty<ITestConfigurations, int>(x => x.RflEventReference), //Was 1 for local TargetAmount = null }; var registrationResponse = pageClient.Create(pageCreationRequest); Assert.That(registrationResponse.Next.Uri, Is.StringContaining(domain)); }
public void RetrievePageSmsCode_WhenProvidedKnownFundraisingPage_ReturnSmsCode(WireDataFormat format) { //arrange var client = TestContext.CreateClientValidCredentials(format); var smsResources = new SmsApi(client.HttpChannel); var fundraisingResources = new PageApi(client.HttpChannel); var validRegisterRequest = ValidRegisterPageRequest(); fundraisingResources.Create(validRegisterRequest); //act var result = smsResources.RetrievePageSmsCode(validRegisterRequest.PageShortName); //assert Assert.IsNotNullOrEmpty(result.Urn); }
public void Create_ValidEvent_ReturnsEventRegistrationResponse(WireDataFormat format) { //arrange var client = TestContext.CreateClientValidCredentials(format); var teamResources = new TeamApi(client.HttpChannel); var fundraiseResources = new PageApi(client.HttpChannel); var validRegisterPageRequest = ValidRegisterPageRequest(); var validRequest = ValidTeamRequest(validRegisterPageRequest.PageShortName); fundraiseResources.Create(validRegisterPageRequest); //act var result = teamResources.CreateOrUpdate(validRequest); //assert Assert.That(result.Id, Is.Not.EqualTo(0)); }
public void Retrieve_AndATeamExists_ReturnsTeam(WireDataFormat format) { //arrange var client = TestContext.CreateClientValidCredentials(format); var teamResources = new TeamApi(client.HttpChannel); var fundraiseResources = new PageApi(client.HttpChannel); var validRegisterPageRequest = ValidRegisterPageRequest(); fundraiseResources.Create(validRegisterPageRequest); var validRequest = ValidTeamRequest(validRegisterPageRequest.PageShortName); var response = teamResources.CreateOrUpdate(validRequest); //act var result = teamResources.Retrieve(validRequest.TeamShortName); //assert Assert.That(result.Id, Is.EqualTo(response.Id)); }
public void UpdatePageSmsCode_WhenProvidedValidRequestAndValidCredentials_ReturnTrue(WireDataFormat format) { //arrange var client = TestContext.CreateClientValidCredentials(format); var smsResources = new SmsApi(client.HttpChannel); var fundraisingResources = new PageApi(client.HttpChannel); var validRegisterRequest = ValidRegisterPageRequest(); fundraisingResources.Create(validRegisterRequest); var randomSmsCodeToUpdate = GenerateRandomSmsCode(); var validRequest = new SmsApi.SmsUpdate {Urn = randomSmsCodeToUpdate}; //act var result = smsResources.UpdatePageSmsCode(validRegisterRequest.PageShortName, validRequest); //assert Assert.IsTrue(result); }
public void Register_WhenProvidedWithValidAuthenticationAndDetails_CreatesANewPage(WireDataFormat format) { var client = TestContext.CreateClientValidCredentials(format); var pageClient = new PageApi(client.HttpChannel); var pageShortName = "api-test-" + Guid.NewGuid(); var pageCreationRequest = new RegisterPageRequest { ActivityType = ActivityType.OtherCelebration, PageShortName = pageShortName, PageTitle = "api test", EventName = "The Other Occasion of ApTest and APITest", CharityId = 2050, TargetAmount = 20M, EventDate = DateTime.Now.AddDays(5) }; var registrationResponse = pageClient.Create(pageCreationRequest); Assert.That(registrationResponse.Next.Uri, Is.StringContaining(pageShortName)); }
public void PageUpdatesAddPost_WhileSupportedValidCredentialsAndValidRequest_ReturnTrue(WireDataFormat format) { //arrange var client = TestContext.CreateClientValidCredentials(format); var fundraisingResource = new PageApi(client.HttpChannel); var validUpdateRequest = ValidUpdateRequest(); var validRegisterPageRequest = ValidRegisterPageRequest(); var resultOfRegisterPage = fundraisingResource.Create(validRegisterPageRequest); //act var result = fundraisingResource.PageUpdatesAddPost(validRegisterPageRequest.PageShortName, validUpdateRequest); //assert Assert.IsTrue(result); }
public void DeletePageUpdate_WhileSupportedValidCredentials_ReturnTrue(WireDataFormat format) { //arrage var client = TestContext.CreateClientValidCredentials(format); var fundraisingResource = new PageApi(client.HttpChannel); var validUpdateRequest = ValidUpdateRequest(); var validRegisterPageRequest = ValidRegisterPageRequest(); fundraisingResource.Create(validRegisterPageRequest); fundraisingResource.PageUpdatesAddPost(validRegisterPageRequest.PageShortName, validUpdateRequest); var pageUpdatesResult = fundraisingResource.PageUpdates(validRegisterPageRequest.PageShortName); var update = pageUpdatesResult.First(); //act var result = fundraisingResource.DeletePageUpdate(validRegisterPageRequest.PageShortName, update.Id.Value); //assert Assert.IsTrue(result); }
public void RetrieveDonationsForPageByReference_WhileSuppliedCorrectReference_ReturnDonations( WireDataFormat format) { //arrange var client = TestContext.CreateClientNoCredentials(format); var fundraisinResources = new PageApi(client.HttpChannel); const string validPageShortName = ""; const string validReference = ""; //act var result = fundraisinResources.RetrieveDonationsForPageByReference(validPageShortName, validReference); //assert Assert.IsNotNull(result); CollectionAssert.IsNotEmpty(result.Donations); }
public void PageUpdate_ReturnPageUpdate(WireDataFormat format) { //arrange var client = TestContext.CreateClientNoCredentials(format); var fundraisingResources = new PageApi(client.HttpChannel); const string validPageShortName = "my-test-8901"; const int validUpdateId = 100142; //act var result = fundraisingResources.PageUpdate(validPageShortName, validUpdateId); //assert Assert.IsNotNull(result); }
public void IsPageShortNameRegistered_WhenSuppliedUnknownDomain_ThrowsException(WireDataFormat format) { var client = TestContext.CreateClientInvalidCredentials(format); var pageClient = new PageApi(client.HttpChannel); const string unknownDomain = "unknownDomain.justgiving.com"; var exception = Assert.Throws<ErrorResponseException>(() => pageClient.IsPageShortNameRegistered("rasha25", unknownDomain)); Assert.That(exception.Response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest)); }
public void Register_WithWhatAndWhy_CreatesCorrectly(WireDataFormat format) { var guid = Guid.NewGuid(); var client = TestContext.CreateClientValidCredentials(format); var pageClient = new PageApi(client.HttpChannel); var pageShortName = "api-test-" + guid; var pageCreationRequest = new RegisterPageRequest { ActivityType = ActivityType.OtherCelebration, PageShortName = pageShortName, PageTitle = "api test Name", EventName = "ApiTest", PageSummaryWhat = "saving the universe", PageSummaryWhy = "because I'm Batman", CharityId = 2050, TargetAmount = 20M, EventDate = DateTime.Now.AddDays(5), }; pageClient.Create(pageCreationRequest); var page = pageClient.Retrieve(pageShortName); Assert.That(page.PageSummaryWhat, Is.EqualTo("saving the universe")); Assert.That(page.PageSummaryWhy, Is.EqualTo("because I'm Batman")); }
public void IsPageShortNameRegistered_WhenSuppliedPageNameUnlikelyToExist_ReturnsFalse(WireDataFormat format) { var client = TestContext.CreateClientInvalidCredentials(format); var pageClient = new PageApi(client.HttpChannel); var exists = pageClient.IsPageShortNameRegistered(Guid.NewGuid().ToString()); Assert.IsFalse(exists); }
public void DeleteImage_WhileSupportedValidCredentialsAndValidRequest_ReturnTrue(WireDataFormat format) { //arrange var client = TestContext.CreateClientValidCredentials(format); var fundraisingResources = new PageApi(client.HttpChannel); var validRegisterPageRequest = ValidRegisterPageRequest(); fundraisingResources.Create(validRegisterPageRequest); var validAddImageRequest = ValidAddFundraisingPageImageRequest(validRegisterPageRequest.PageShortName); fundraisingResources.AddImage(validAddImageRequest); var images = fundraisingResources.GetImages(new GetFundraisingPageImagesRequest { PageShortName = validRegisterPageRequest.PageShortName }); var image = images.First(); //act var result = fundraisingResources.DeleteImage(validRegisterPageRequest.PageShortName, image.Url); //assert Assert.IsTrue(result); }
public void Cannot_Create_Page_For_Event_Using_Event_Reference_And_Id(WireDataFormat format) { var client = TestContext.CreateClientValidCredentials(format); var pageClient = new PageApi(client.HttpChannel); var pageShortName = "api-test-" + Guid.NewGuid(); var pageCreationRequest = new RegisterPageRequest { ActivityType = null, PageShortName = pageShortName, PageTitle = "When Provided With Valid Authentication Details And An Empty Activity Type - Creates New Page", EventName = "The Other Occasion of ApTest and APITest", CharityId = 2050, EventId = 1, TargetAmount = 20M, EventDate = DateTime.Now.AddDays(5) }; var ex = Assert.Throws<ErrorResponseException>(() => pageClient.Create("foo", pageCreationRequest)); Assert.That(ex.Response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest)); }
public void Can_Create_Page_For_Event_Using_Event_Reference(WireDataFormat format) { var client = TestContext.CreateClientValidCredentials(format); var pageClient = new PageApi(client.HttpChannel); var pageShortName = "api-test-" + Guid.NewGuid(); var pageCreationRequest = new RegisterPageRequest { ActivityType = null, PageShortName = pageShortName, PageTitle = "When Provided With Valid Authentication Details And An Empty Activity Type - Creates New Page", EventName = "The Other Occasion of ApTest and APITest", CharityId = 2050, TargetAmount = 20M, EventDate = DateTime.Now.AddDays(5) }; pageClient.Create("341_RFL2010", pageCreationRequest); }
public void AddFundraisingPageVideo_WhenCredentialsValidAndRequestValid_ReturnsSuccessful(WireDataFormat format) { //arrange var client = TestContext.CreateClientValidCredentials(format); var pageClient = new PageApi(client.HttpChannel); var pageCreationRequest = ValidRegisterPageRequest(); pageClient.Create(pageCreationRequest); var addVideoRequest = new AddFundraisingPageVideoRequest { Url = "http://www.youtube.com/watch?v=MSxjbF18BBM", Caption = "neckbrace", PageShortName = pageCreationRequest.PageShortName }; //act var result = pageClient.AddVideo(addVideoRequest); //assert Assert.IsNotNullOrEmpty(result.Next.Rel); }
public void AddFundraisingPageImage_WhenCredentialsValidAndRequestValid_ReturnsSuccessful(WireDataFormat format) { //arrange var client = TestContext.CreateClientValidCredentials(format); var pageClient = new PageApi(client.HttpChannel); var pageCreationRequest = ValidRegisterPageRequest(); pageClient.Create(pageCreationRequest); var validAddImageRequest = ValidAddFundraisingPageImageRequest(pageCreationRequest.PageShortName); //act var result = pageClient.AddImage(validAddImageRequest); //assert Assert.IsNotNullOrEmpty(result.Next.Rel); }
public void AddFundraisingPageVideo_WhenCredentialsValidAndRequestNotValid_ThrowsException(WireDataFormat format) { //arrange var client = TestContext.CreateClientValidCredentials(format); var pageClient = new PageApi(client.HttpChannel); var pageCreationRequest = ValidRegisterPageRequest(); pageClient.Create(pageCreationRequest); var addVideoRequest = new AddFundraisingPageVideoRequest { Url = "", Caption = "", PageShortName = pageCreationRequest.PageShortName }; //act var response = Assert.Throws<ErrorResponseException>(() => pageClient.AddVideo(addVideoRequest)); //arrange Assert.That(response.Response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest)); }
public void FundraisingPageAttribution_WhileSupportedValidCredentials_ReturnFundraisingPageAttribution(WireDataFormat format) { //arrange var client = TestContext.CreateClientValidCredentials(format); var fundraisingResources = new PageApi(client.HttpChannel); var validRegisterPageRequest = ValidRegisterPageRequest(); var createdPage = fundraisingResources.Create(validRegisterPageRequest); var validRequest = ValidAppendFundraisingPageAttributionRequest(); var appendAttributeRequest = fundraisingResources.AppendToFundraisingPageAttribution(validRegisterPageRequest.PageShortName, validRequest); //act var result = fundraisingResources.FundraisingPageAttribution(validRegisterPageRequest.PageShortName); //assert Assert.IsNotNullOrEmpty(result.Attribution); }
public void Register_WhenProvidedWithValidAuthenticationAndDetailsAndAnEmptyActivityType_TheResponseContainsThePageId(WireDataFormat format) { var client = TestContext.CreateClientValidCredentials(format); var pageClient = new PageApi(client.HttpChannel); var pageShortName = "api-test-" + Guid.NewGuid(); var pageCreationRequest = new RegisterPageRequest { ActivityType = null, PageShortName = pageShortName, PageTitle = "api test", EventName = "The Other Occasion of ApTest and APITest", CharityId = 2050, EventId = TestConfigurationsHelper.GetProperty<ITestConfigurations, int>(x => x.ValidEventId), TargetAmount = 20M, EventDate = DateTime.Now.AddDays(5) }; var registrationResponse = pageClient.Create(pageCreationRequest); Assert.That(registrationResponse.PageId != 0); }
public void UpdateFundraisingPageAttribution_WhileSupportedValidCredentialsAndValidRequest_ReturnTrue(WireDataFormat format) { //arrange var client = TestContext.CreateClientValidCredentials(format); var fundraisingResources = new PageApi(client.HttpChannel); var validRegisterPageRequest = ValidRegisterPageRequest(); fundraisingResources.Create(validRegisterPageRequest); var validAppendRequest = ValidAppendFundraisingPageAttributionRequest(); fundraisingResources.AppendToFundraisingPageAttribution(validRegisterPageRequest.PageShortName, validAppendRequest); var validRequest = ValidUpdateFundraisingPageAttributionRequest(); //act var result = fundraisingResources.UpdateFundraisingPageAttribution(validRegisterPageRequest.PageShortName, validRequest); //assert Assert.IsTrue(result); }
public void UploadImage_WhenProvidedVaildCredentialsAndInvalidPage_ThrowsException(WireDataFormat format) { var client = TestContext.CreateClientValidCredentials(format); var pageClient = new PageApi(client.HttpChannel); var exception = Assert.Throws<ErrorResponseException>(() => pageClient.UploadImage(Guid.NewGuid().ToString(), "my image", File.ReadAllBytes("jpg.jpg"), "image/jpeg")); Assert.That(exception.Response.StatusCode, Is.EqualTo(HttpStatusCode.NotFound)); }
public void CancelPage_WhileSupportedValidCredentials_ReturnTrue(WireDataFormat format) { //arrange var client = TestContext.CreateClientValidCredentials(format); var fundraisingResources = new PageApi(client.HttpChannel); var validRegisterPageRequest = ValidRegisterPageRequest(); fundraisingResources.Create(validRegisterPageRequest); //act var result = fundraisingResources.CancelPage(validRegisterPageRequest.PageShortName); //assert Assert.IsTrue(result); }
public void IsPageShortNameRegistered_WhenSuppliedPageNameUnlikelyToExistOnNonDefaultDomain_ReturnsFalse(WireDataFormat format) { //arrange var client = TestContext.CreateClientInvalidCredentials(format); var pageClient = new PageApi(client.HttpChannel); //act var exists = pageClient.IsPageShortNameRegistered("rasha25", TestConfigurationsHelper.GetProperty<ITestConfigurations, string>(x => x.RflDomain)); //assert Assert.IsFalse(exists); }
public string Create_Page_With_Custom_Theme(WireDataFormat format) { var client = TestContext.CreateClientValidCredentials(format); var pageClient = new PageApi(client.HttpChannel); var pageShortName = "api-test-" + Guid.NewGuid(); var pageCreationRequest = new RegisterPageRequest { ActivityType = ActivityType.OtherCelebration, PageShortName = pageShortName, PageTitle = "Page with custom theme", EventName = "Test", CharityId = 2050, TargetAmount = 20M, EventDate = DateTime.Now.AddDays(5), Theme = new PageTheme { BackgroundColour = "#FF0000", ButtonColour = "#FFFF00", ButtonTextColour = "#00FF00", TitleColour = "#0000FF" } }; pageClient.Create(pageCreationRequest); return pageShortName; }
public void UploadImage_WhenProvidedCredentialsAndValidPageAndImage_UploadsImage(WireDataFormat format) { var client = TestContext.CreateClientValidCredentials(format); var pageClient = new PageApi(client.HttpChannel); // Create Page var pageCreationRequest = new RegisterPageRequest { ActivityType = ActivityType.OtherCelebration, PageShortName = "api-test-" + Guid.NewGuid(), PageTitle = "Page Created For Update Story Integration Test", EventName = "Story Update Testing", CharityId = 2050, TargetAmount = 20M, EventDate = DateTime.Now.AddDays(5) }; pageClient.Create(pageCreationRequest); var imageName = Guid.NewGuid().ToString(); pageClient.UploadImage(pageCreationRequest.PageShortName, imageName, File.ReadAllBytes("jpg.jpg"), "image/jpeg"); // Assert var pageData = pageClient.Retrieve(pageCreationRequest.PageShortName); Assert.That(pageData.Media.Images[0].Caption, Is.StringContaining(imageName)); }
public void JointTeam_WhenProvidedValidRequestAndValidCredentials_ReturnTrue(WireDataFormat format) { //arrange var client = TestContext.CreateClientValidCredentials(format); var teamResources = new TeamApi(client.HttpChannel); var fundraisingResources = new PageApi(client.HttpChannel); var validRegisterPageRequest = ValidRegisterPageRequest(); fundraisingResources.Create(validRegisterPageRequest); var validTeamRequest = ValidTeamRequest(validRegisterPageRequest.PageShortName); teamResources.CreateOrUpdate(validTeamRequest); var validRegisterPageRequestSecond = ValidRegisterPageRequest(); fundraisingResources.Create(validRegisterPageRequestSecond); var validJoinTeamRequest = ValidJoinTeamRequest(validRegisterPageRequestSecond.PageShortName); //act var result = teamResources.JointTeam(validTeamRequest.TeamShortName, validJoinTeamRequest); //assert Assert.IsTrue(result); }
public void Register_SuppliedValidAuthenticationAndValidRegisterPageRequestWithNewRememberedPersonDetails_CanRetrievePageWithRememberedPersonData(WireDataFormat format) { var guid = Guid.NewGuid(); var client = TestContext.CreateClientValidCredentials(format); var pageClient = new PageApi(client.HttpChannel); var pageShortName = "api-test-" + guid; var firstName = "FirstName-api-test"; var lastName = string.Format("Last-{0}", guid); string inMemNameAttribution = String.Format("{0} {1}{2}", firstName, lastName, guid).Trim(); var rememberedPersonReference = new RememberedPersonReference { Relationship = "Other", RememberedPerson = new RememberedPerson { FirstName = firstName, LastName = lastName, Gender = Gender.Male.ToString(), Town = String.Format("town-{0}", guid), DateOfBirth = DateTime.Now.AddYears(-50), DateOfDeath = DateTime.Now.AddDays(-1), } }; var pageCreationRequest = new RegisterPageRequest { ActivityType = ActivityType.InMemory, Attribution = inMemNameAttribution, PageShortName = pageShortName, PageTitle = "api test InMem Name", EventName = "The InMem ApiTest", CharityId = 2050, TargetAmount = 20M, EventDate = DateTime.Now.AddDays(5), RememberedPersonReference = rememberedPersonReference, }; pageClient.Create(pageCreationRequest); FundraisingPage page = pageClient.Retrieve(pageShortName); Assert.NotNull(page.RememberedPersonSummary.Name); Assert.That(page.RememberedPersonSummary.Next.Uri, Is.StringContaining(String.Format("remember/{0}", page.RememberedPersonSummary.Id))); }