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_SuppliedValidAuthenticationAndValidRegisterPageRequestWithCompanyAppealId_CanRetrieveCompanyId(WireDataFormat format) { //arrange var client = TestContext.CreateClientValidCredentials(format); var pageClient = new PageApi(client.HttpChannel); var pageShortName = "api-test-" + Guid.NewGuid(); const int companyAppealId = 200002; var pageCreationRequest = new RegisterPageRequest { CompanyAppealId = companyAppealId, 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) }; pageClient.Create(pageCreationRequest); //act var result = pageClient.Retrieve(pageShortName); //assert Assert.That(result.CompanyAppealId, Is.EqualTo(companyAppealId)); }
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 UpdatePageStory_WhenProvidedCredentialsAndValidPage_PostsUpdate(WireDataFormat format) { var client = TestContext.CreateClientValidCredentials(format); var pageClient = new PageApi(client.HttpChannel); // Create Page var pageShortName = "api-test-" + Guid.NewGuid(); var pageCreationRequest = new RegisterPageRequest { ActivityType = ActivityType.OtherCelebration, PageShortName = pageShortName, PageTitle = "Page Created For Update Story Integration Test", EventName = "Story Update Testing", CharityId = 2050, TargetAmount = 20M, EventDate = DateTime.Now.AddDays(5) }; pageClient.Create(pageCreationRequest); // Act var update = DateTime.Now + ": Unit Test Update"; pageClient.UpdateStory(pageCreationRequest.PageShortName, update); // Assert var pageData = pageClient.Retrieve(pageShortName); Assert.That(pageData.Story, Is.StringContaining(update)); }
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 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 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 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 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 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 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 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_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))); }
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_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 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 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 RetrievePage_WhenProvidedWithAKnownPage_ReturnsPublicPageView(WireDataFormat format) { var client = TestContext.CreateClientValidCredentials(format); var pageClient = new PageApi(client.HttpChannel); // Create Page var pageShortName = "api-test-" + Guid.NewGuid(); var pageCreationRequest = new RegisterPageRequest { ActivityType = ActivityType.OtherCelebration, PageShortName = pageShortName, PageTitle = "Page Created For Update Story Integration Test", EventName = "Story Update Testing", CharityId = 2050, TargetAmount = 20M, EventDate = DateTime.Now.AddDays(5), CustomCodes = new PageCustomCodes { CustomCode1 = "code1", CustomCode2 = "code2", CustomCode3 = "code3", CustomCode4 = "code4", CustomCode5 = "code5", CustomCode6 = "code6" } }; pageClient.Create(pageCreationRequest); // Act var pageData = pageClient.Retrieve(pageShortName); Assert.NotNull(pageData); Assert.That(pageData.PageCreatorName, Is.Not.Empty); Assert.AreEqual(pageData.PageShortName, pageCreationRequest.PageShortName); Assert.AreEqual(pageData.PageTitle, pageCreationRequest.PageTitle); Assert.AreEqual(pageData.EventName, pageCreationRequest.EventName); Assert.AreEqual(pageData.TargetAmount, pageCreationRequest.TargetAmount); Assert.IsNotNullOrEmpty(pageData.SmsCode); Assert.That(pageData.TotalRaisedSms, Is.Not.Empty); }
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 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 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 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 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 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 Register_SuppliedValidAuthenticationAndValidRegisterPageRequestWithInMemName_CanRetrieveNameFromAttribution(WireDataFormat format) { var client = TestContext.CreateClientValidCredentials(format); var pageClient = new PageApi(client.HttpChannel); var pageShortName = "api-test-" + Guid.NewGuid(); const string inMemName = "Matheu"; var pageCreationRequest = new RegisterPageRequest { ActivityType = ActivityType.InMemory, Attribution = inMemName, PageShortName = pageShortName, PageTitle = "api test InMem Name", EventName = "The InMem ApiTest", CharityId = 2050, TargetAmount = 20M, EventDate = DateTime.Now.AddDays(5) }; pageClient.Create(pageCreationRequest); FundraisingPage page = pageClient.Retrieve(pageShortName); Assert.That(page.Attribution, Is.EqualTo(inMemName)); }
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); }