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 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)); }