コード例 #1
0
        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));
        }
コード例 #2
0
        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"));
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        public void RetrievePage_WhenProvidedWithABadPage_ThrowsResourceNotFoundException(WireDataFormat format)
        {
            var client     = TestContext.CreateClientNoCredentials(format);
            var pageClient = new PageApi(client.HttpChannel);

            var exception = Assert.Throws <ResourceNotFoundException>(() => pageClient.Retrieve(Guid.NewGuid().ToString()));

            Assert.IsInstanceOf <ResourceNotFoundException>(exception);
        }
コード例 #6
0
        public void RetrivePage_WhenProvidedShortName_ReturnsNotEmptyCollectionOfTeams(WireDataFormat format)
        {
            //arrange
            var client     = TestContext.CreateClientNoCredentials(format);
            var pageClient = new PageApi(client.HttpChannel);

            //act
            var result = pageClient.Retrieve("my-test-890");

            //assert
            Assert.IsNotEmpty(result.Teams);
        }
コード例 #7
0
        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)));
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        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));
        }