Exemplo n.º 1
0
        public void WhenUpdateDocumentFromFile_ThenCheckResponse()
        {
            // Arrange
            using (SimpleServer.Create(TestHelpers.BaseUrl, ProductRequestHandler))
            {
                var client = new YouScribeClient(TestHelpers.BaseUrl);

                client.AuthorizeAsync("test", "password").Wait();

                var request = client.CreateProductRequest();

                // Act
                bool ok = request.UpdateDocumentAsync(42, new Models.Products.ProductUpdateModel
                {
                    Description = "ok"
                },
                                                      new[] {
                    new YouScribe.Rest.Models.FileModel {
                        Content = new MemoryStream(), FileName = "test2.pdf", ContentType = "application/pdf"
                    }
                }).Result;

                // Assert
                Assert.True(ok);
            }
        }
        public void WhenSendingRequest__ThenMustTimeout()
        {
            using (SimpleServer.Create(TestHelpers.BaseUrl,
                c => {
                    Task.Delay(2000).Wait();
                    c.Response.Close();
                }))
            {
                YouScribeClient.DefaultTimeout = TimeSpan.FromMilliseconds(200);
                var client = new YouScribeClient(TestHelpers.BaseUrl);

                var ex = Assert.Throws<AggregateException>(() =>
                    {
                        client.AuthorizeAsync("test", "password").Wait();

                        var request = client.CreateProductRequest();

                        // Act
                        var response = request.GetRightAsync(42).Result;

                        // Assert
                        Assert.Equal(110, response);
                    });

            }
        }
        public void WhenSendingRequest__ThenMustTimeout()
        {
            using (SimpleServer.Create(TestHelpers.BaseUrl,
                                       c => {
                Task.Delay(2000).Wait();
                c.Response.Close();
            }))
            {
                YouScribeClient.DefaultTimeout = TimeSpan.FromMilliseconds(200);
                var client = new YouScribeClient(TestHelpers.BaseUrl);

                var ex = Assert.Throws <AggregateException>(() =>
                {
                    client.AuthorizeAsync("test", "password").Wait();

                    var request = client.CreateProductRequest();

                    // Act
                    var response = request.GetRightAsync(42).Result;

                    // Assert
                    Assert.Equal(110, response);
                });
            }
        }
Exemplo n.º 4
0
        public void WhenPublishDocumentFromUrl_ThenCheckResponse()
        {
            // Arrange
            using (SimpleServer.Create(TestHelpers.BaseUrl, ProductRequestHandler))
            {
                var client = new YouScribeClient(TestHelpers.BaseUrl);

                client.AuthorizeAsync("test", "password").Wait();

                var request = client.CreateProductRequest();

                // Act
                var product = request.PublishDocumentAsync(new Models.Products.ProductModel
                {
                    Title = "my document title"
                },
                                                           new[] {
                    new Uri("http://exemple.com/test.pdf")
                }).Result;

                // Assert
                Assert.NotNull(product);
                Assert.Equal(42, product.Id);
                Assert.Equal("my document title", product.Title);
                Assert.Equal("{\"Id\":0,\"Title\":\"my document title\",\"Description\":null,\"Collection\":null,\"PublishDate\":null,\"EAN13\":null,\"Public\":true,\"IsFree\":true,\"Price\":null,\"People\":null,\"Languages\":null,\"Tags\":null,\"CategoryId\":0,\"ThemeId\":0,\"AllowPasteAndCut\":false,\"AllowPrint\":false,\"AllowPrintOnDemand\":false,\"AllowDownload\":true,\"AllowStreaming\":true,\"IsAdultContent\":false,\"PreviewNbPage\":null,\"PreviewPercentPage\":null,\"PreviewRange\":null,\"CopyrightInformation\":0,\"LicenceName\":null}",
                             requestContent);
            }
        }
Exemplo n.º 5
0
        public void WhenAuthorizeUser_ThenCheckToken()
        {
            // Arrange
            using (SimpleServer.Create(TestHelpers.BaseUrl, UserAuthorizedHandler))
            {
                var client = new YouScribeClient(TestHelpers.BaseUrl);

                // Act
                bool isAuthorized = client.AuthorizeAsync("test", "password").Result;

                // Assert
                Assert.True(isAuthorized);
            }
        }
Exemplo n.º 6
0
        public void WhenAuthorizeInvalidUser_ThenCheckToken()
        {
            // Arrange
            using (SimpleServer.Create(TestHelpers.BaseUrl, UserAuthorizedHandler))
            {
                var client = new YouScribeClient(TestHelpers.BaseUrl);

                // Act
                bool isAuthorized = client.AuthorizeAsync("test", "assword").Result;

                // Assert
                Assert.False(isAuthorized);
            }
        }
        public void WhenSetEventFrequency_ThenCheckResponse()
        {
            // Arrange
            using (SimpleServer.Create(TestHelpers.BaseUrl, EventHandler))
            {
                var client = new YouScribeClient(TestHelpers.BaseUrl);
                client.AuthorizeAsync("test", "password").Wait();

                var request = client.CreateAccountEventRequest();

                // Act
                bool ok = request.SetEventFrequencyAsync(Models.Accounts.NotificationFrequency.ByWeek).Result;

                // Assert
                Assert.True(ok);
            }
        }
        public void WhenSubscribeToEvent_ThenCheckResponse()
        {
            // Arrange
            using (SimpleServer.Create(TestHelpers.BaseUrl, EventHandler))
            {
                var client = new YouScribeClient(TestHelpers.BaseUrl);
                client.AuthorizeAsync("test", "password").Wait();

                var request = client.CreateAccountEventRequest();

                // Act
                bool ok = request.SubscribeToEventAsync("PublicaFeatured").Result;

                // Assert
                Assert.True(ok);
            }
        }
        public void WhenSetEventFrequency_ThenCheckResponse()
        {
            // Arrange
            using (SimpleServer.Create(TestHelpers.BaseUrl, EventHandler))
            {
                var client = new YouScribeClient(TestHelpers.BaseUrl);
                client.AuthorizeAsync("test", "password").Wait();

                var request = client.CreateAccountEventRequest();

                // Act
                bool ok = request.SetEventFrequencyAsync(Models.Accounts.NotificationFrequency.ByWeek).Result;

                // Assert
                Assert.True(ok);
            }
        }
        public void WhenSetAsPaypalPublisher_ThenCheckResponse()
        {
            // Arrange
            using (SimpleServer.Create(TestHelpers.BaseUrl, Publisherandler))
            {
                var client = new YouScribeClient(TestHelpers.BaseUrl);
                client.AuthorizeAsync("test", "password").Wait();

                var request = client.CreateAccountPublisherRequest();

                // Act
                bool ok = request.SetAsPaypalPublisherAsync(new Models.Accounts.AccountPublisherPaypalModel()).Result;

                // Assert
                Assert.True(ok);
                Assert.Equal("{\"PaypalEmail\":null,\"IsProfessional\":false,\"CorporateName\":null,\"SiretNumber\":null,\"VATNumber\":null,\"Street\":null,\"Street2\":null,\"ZipCode\":null,\"State\":null,\"City\":null,\"CountryCode\":null,\"Civility\":0,\"FirstName\":null,\"LastName\":null,\"PhoneNumber\":null}", requestContent);
            }
        }
Exemplo n.º 11
0
        public void WhenDeletePicture_ThenCheckResponse()
        {
            // Arrange
            using (SimpleServer.Create(TestHelpers.BaseUrl, AccountHandler))
            {
                var client = new YouScribeClient(TestHelpers.BaseUrl);

                client.AuthorizeAsync("test", "password").Wait();

                var request = client.CreateAccountRequest();

                // Act
                bool ok = request.DeletePictureAsync().Result;

                // Assert
                Assert.True(ok);
            }
        }
Exemplo n.º 12
0
        public void WhenUploadPictureFromUrl_ThenCheckResponse()
        {
            // Arrange
            using (SimpleServer.Create(TestHelpers.BaseUrl, AccountHandler))
            {
                var client = new YouScribeClient(TestHelpers.BaseUrl);

                client.AuthorizeAsync("test", "password").Wait();

                var request = client.CreateAccountRequest();

                // Act
                bool ok = request.UploadPictureAsync(new Uri("http://exmple.com/image.jpg")).Result;

                // Assert
                Assert.True(ok);
            }
        }
Exemplo n.º 13
0
        public void WhenSetAsPaypalPublisher_ThenCheckResponse()
        {
            // Arrange
            using (SimpleServer.Create(TestHelpers.BaseUrl, Publisherandler))
            {
                var client = new YouScribeClient(TestHelpers.BaseUrl);
                client.AuthorizeAsync("test", "password").Wait();

                var request = client.CreateAccountPublisherRequest();

                // Act
                bool ok = request.SetAsPaypalPublisherAsync(new Models.Accounts.AccountPublisherPaypalModel()).Result;

                // Assert
                Assert.True(ok);
                Assert.Equal("{\"PaypalEmail\":null,\"IsProfessional\":false,\"CorporateName\":null,\"SiretNumber\":null,\"VATNumber\":null,\"Street\":null,\"Street2\":null,\"ZipCode\":null,\"State\":null,\"City\":null,\"CountryCode\":null,\"Civility\":0,\"FirstName\":null,\"LastName\":null,\"PhoneNumber\":null}", requestContent);
            }
        }
Exemplo n.º 14
0
        public void WhenUpdateDocumentThumbnailFromPage_ThenCheckResponse()
        {
            // Arrange
            using (SimpleServer.Create(TestHelpers.BaseUrl, ProductRequestHandler))
            {
                var client = new YouScribeClient(TestHelpers.BaseUrl);

                client.AuthorizeAsync("test", "password").Wait();

                var request = client.CreateProductRequest();

                // Act
                bool ok = request.UpdateDocumentThumbnailAsync(42, 2).Result;

                // Assert
                Assert.True(ok);
            }
        }
Exemplo n.º 15
0
        public void WhenCheckForProductRight_ThenCheckResponse()
        {
            // Arrange
            using (SimpleServer.Create(TestHelpers.BaseUrl, ProductRequestHandler))
            {
                var client = new YouScribeClient(TestHelpers.BaseUrl);

                client.AuthorizeAsync("test", "password").Wait();

                var request = client.CreateProductRequest();

                // Act
                var response = request.GetRightAsync(42).Result;

                // Assert
                Assert.Equal(110, response);
            }
        }
Exemplo n.º 16
0
        public void WhenCheckForProductRight_ThenCheckResponse()
        {
            // Arrange
            using (SimpleServer.Create(TestHelpers.BaseUrl, ProductRequestHandler))
            {
                var client = new YouScribeClient(TestHelpers.BaseUrl);

                client.AuthorizeAsync("test", "password").Wait();

                var request = client.CreateProductRequest();

                // Act
                var response = request.GetRightAsync(42).Result;

                // Assert
                Assert.Equal(110, response);
            }
        }
Exemplo n.º 17
0
        public void WhenSetSpokenLanguages_ThenCheckResponse()
        {
            // Arrange
            using (SimpleServer.Create(TestHelpers.BaseUrl, AccountHandler))
            {
                var client = new YouScribeClient(TestHelpers.BaseUrl);

                client.AuthorizeAsync("test", "password").Wait();

                var request = client.CreateAccountRequest();

                // Act
                bool ok = request.SetSpokenLanguagesAsync(new[] { "fr", "en" }).Result;

                // Assert
                Assert.True(ok);
                Assert.Equal("Languages=fr&Languages=en", requestContent);
            }
        }
        public void WhenSetUserType_ThenCheckResponse()
        {
            // Arrange
            using (SimpleServer.Create(TestHelpers.BaseUrl, AccountUserTypeHandler))
            {
                var client = new YouScribeClient(TestHelpers.BaseUrl);

                client.AuthorizeAsync("test", "password").Wait();

                var request = client.CreateAccountUserTypeRequest();

                // Act
                bool ok = request.SetUserTypeAsync(new Models.Accounts.UserTypeModel { Id = 25 }).Result;

                // Assert
                Assert.True(ok);
                Assert.Equal("{\"Id\":25,\"Name\":null,\"Label\":null}", requestContent);
            }
        }
Exemplo n.º 19
0
        public void WhenGeneratePrivateEmbedIframeTag_ThenCheckCode()
        {
            // Arrange
            using (SimpleServer.Create(TestHelpers.BaseUrl, GenerateEmbledHandler))
            {
                var client = new YouScribeClient(TestHelpers.BaseUrl);
                client.AuthorizeAsync("test", "password").Wait();

                var request = client.CreateEmbedRequest();

                int productId = 1;

                // Act
                var tag = request.GeneratePrivateIframeTagAsync(productId).Result;

                // Assert
                Assert.NotEmpty(tag);
                Assert.Equal("embed3", tag);
            }
        }
Exemplo n.º 20
0
        public void WhenGeneratePrivateEmbedIframeTagWithFeatures_ThenCheckCode()
        {
            // Arrange
            using (SimpleServer.Create(TestHelpers.BaseUrl, GenerateEmbledHandler))
            {
                var client = new YouScribeClient(TestHelpers.BaseUrl);
                client.AuthorizeAsync("test", "password").Wait();

                var request = client.CreateEmbedRequest();

                int productId = 1;

                // Act
                var tag = request.GeneratePrivateIframeTagAsync(productId, new Models.Products.PrivateEmbedGenerateModel { Width = 600, Height = 300, AccessPeriod = "1d" }).Result;

                // Assert
                Assert.NotEmpty(tag);
                Assert.Equal("embed4", tag);
            }
        }
Exemplo n.º 21
0
        public void WhenDownloadProductExtractToStreamFromExtension_ThenCheckResponse()
        {
            // Arrange
            using (SimpleServer.Create(TestHelpers.BaseUrl, ProductRequestHandler))
            {
                var client = new YouScribeClient(TestHelpers.BaseUrl);

                client.AuthorizeAsync("test", "password").Wait();

                var request = client.CreateProductRequest();

                // Act
                // Assert
                using (var stream = new MemoryStream())
                {
                    request.DownloadExtractToStreamAsync(43, 1, stream, new Progress <DownloadBytesProgress>()).Wait();
                    Assert.Equal(57210, stream.Length);
                }
            }
        }
        public void WhenSetUserType_ThenCheckResponse()
        {
            // Arrange
            using (SimpleServer.Create(TestHelpers.BaseUrl, AccountUserTypeHandler))
            {
                var client = new YouScribeClient(TestHelpers.BaseUrl);

                client.AuthorizeAsync("test", "password").Wait();

                var request = client.CreateAccountUserTypeRequest();

                // Act
                bool ok = request.SetUserTypeAsync(new Models.Accounts.UserTypeModel {
                    Id = 25
                }).Result;

                // Assert
                Assert.True(ok);
                Assert.Equal("{\"Id\":25,\"Name\":null,\"Label\":null}", requestContent);
            }
        }
Exemplo n.º 23
0
        public void WhenUploadPictureFromLocalFile_ThenCheckResponse()
        {
            // Arrange
            using (SimpleServer.Create(TestHelpers.BaseUrl, AccountHandler))
            {
                var client = new YouScribeClient(TestHelpers.BaseUrl);

                client.AuthorizeAsync("test", "password").Wait();

                var request = client.CreateAccountRequest();

                // Act
                bool ok = request.UploadPictureAsync(new Models.FileModel {
                    Content = new MemoryStream(), ContentType = "image/png", FileName = "test.png"
                }).Result;

                // Assert
                Assert.Contains("Content-Disposition: form-data; name=file; filename=test.png; filename*=utf-8''test.png", requestContent);
                Assert.True(ok);
            }
        }
Exemplo n.º 24
0
        public void WhenUpdateAccount_ThenCheckResponse()
        {
            // Arrange
            using (SimpleServer.Create(TestHelpers.BaseUrl, AccountHandler))
            {
                var client = new YouScribeClient(TestHelpers.BaseUrl);

                client.AuthorizeAsync("test", "password").Wait();

                var request = client.CreateAccountRequest();

                // Act
                bool ok = request.UpdateAsync(new Models.Accounts.AccountModel {
                    Id = 42, FirstName = "kikou"
                }).Result;

                // Assert
                Assert.True(ok);
                Assert.Equal("{\"Id\":42,\"UserName\":null,\"Password\":null,\"Email\":null,\"FirstName\":\"kikou\",\"LastName\":null,\"Gender\":null,\"Civility\":null,\"BirthDate\":null,\"CountryCode\":null,\"BlogUrl\":null,\"WebSiteUrl\":null,\"FacebookPage\":null,\"TwitterPage\":null,\"City\":null,\"Biography\":null,\"PhoneNumber\":null,\"EmailIsPublic\":false,\"EmailStatus\":null,\"DomainLanguageIsoCode\":null,\"TrackingId\":\"00000000-0000-0000-0000-000000000000\",\"YsAuthToken\":null}",
                             requestContent);
            }
        }
Exemplo n.º 25
0
        public void WhenGeneratePrivateEmbedIframeTagWithFeatures_ThenCheckCode()
        {
            // Arrange
            using (SimpleServer.Create(TestHelpers.BaseUrl, GenerateEmbledHandler))
            {
                var client = new YouScribeClient(TestHelpers.BaseUrl);
                client.AuthorizeAsync("test", "password").Wait();

                var request = client.CreateEmbedRequest();

                int productId = 1;

                // Act
                var tag = request.GeneratePrivateIframeTagAsync(productId, new Models.Products.PrivateEmbedGenerateModel {
                    Width = 600, Height = 300, AccessPeriod = "1d"
                }).Result;

                // Assert
                Assert.NotEmpty(tag);
                Assert.Equal("embed4", tag);
            }
        }
Exemplo n.º 26
0
        public void WhenUpdateDocumentThumbnailFromFile_ThenCheckResponse()
        {
            // Arrange
            using (SimpleServer.Create(TestHelpers.BaseUrl, ProductRequestHandler))
            {
                var client = new YouScribeClient(TestHelpers.BaseUrl);

                client.AuthorizeAsync("test", "password").Wait();

                var request = client.CreateProductRequest();

                // Act
                bool ok = request.UpdateDocumentThumbnailAsync(42, new YouScribe.Rest.Models.FileModel
                {
                    Content     = new MemoryStream(),
                    FileName    = "image.jpg",
                    ContentType = "image/jpg"
                }).Result;

                // Assert
                Assert.True(ok);
            }
        }
Exemplo n.º 27
0
        public void WhenDownloadProductExtractFromExtension_ThenCheckResponse()
        {
            // Arrange
            using (SimpleServer.Create(TestHelpers.BaseUrl, ProductRequestHandler))
            {
                var client = new YouScribeClient(TestHelpers.BaseUrl);

                client.AuthorizeAsync("test", "password").Wait();

                var request = client.CreateProductRequest();

                // Act
                var response = request.DownloadExtractAsync(43, "pdf").Result;

                // Assert
                Assert.NotNull(response);
                using (var stream = new MemoryStream())
                {
                    response.CopyTo(stream);
                    Assert.Equal(57210, stream.Length);
                }
            }
        }
Exemplo n.º 28
0
        public void WhenDownloadProductExtractFromFormatTypeId_ThenCheckResponse()
        {
            // Arrange
            using (SimpleServer.Create(TestHelpers.BaseUrl, ProductRequestHandler))
            {
                var client = new YouScribeClient(TestHelpers.BaseUrl);

                client.AuthorizeAsync("test", "password").Wait();

                var request = client.CreateProductRequest();

                // Act
                var response = request.DownloadExtractAsync(43, 1).Result;

                // Assert
                Assert.NotNull(response);
                using (var stream = new MemoryStream())
                {
                    response.CopyTo(stream);
                    Assert.Equal(57210, stream.Length);
                }
            }
        }
Exemplo n.º 29
0
        public void WhenUpdateDocumentFromUrl_ThenCheckResponse()
        {
            // Arrange
            using (SimpleServer.Create(TestHelpers.BaseUrl, ProductRequestHandler))
            {
                var client = new YouScribeClient(TestHelpers.BaseUrl);

                client.AuthorizeAsync("test", "password").Wait();

                var request = client.CreateProductRequest();

                // Act
                bool ok = request.UpdateDocumentAsync(42, new Models.Products.ProductUpdateModel
                {
                    Description = "ok"
                },
                                                      new[] {
                    new Uri("http://exemple.com/test2.pdf")
                }).Result;

                // Assert
                Assert.True(ok);
            }
        }
        public void WhenUnSubscribeToEvent_ThenCheckResponse()
        {
            // Arrange
            using (SimpleServer.Create(TestHelpers.BaseUrl, EventHandler))
            {
                var client = new YouScribeClient(TestHelpers.BaseUrl);
                client.AuthorizeAsync("test", "password").Wait();

                var request = client.CreateAccountEventRequest();

                // Act
                bool ok = request.UnSubscribeToEventAsync(new Models.Accounts.AccountEventModel { Id = 6 }).Result;

                // Assert
                Assert.True(ok);
            }
        }
Exemplo n.º 31
0
        public void WhenDownloadProductToStreamFromFormatTypeId_ThenCheckResponse()
        {
            // Arrange
            using (SimpleServer.Create(TestHelpers.BaseUrl, ProductRequestHandler))
            {
                var client = new YouScribeClient(TestHelpers.BaseUrl);

                client.AuthorizeAsync("test", "password").Wait();

                var request = client.CreateProductRequest();

                // Act
                // Assert
                using (var stream = new MemoryStream())
                {
                    request.DownloadFileToStreamAsync(42, "pdf", stream, new Progress<DownloadBytesProgress>()).Wait();
                    Assert.Equal(57210, stream.Length);
                }
            }
        }
Exemplo n.º 32
0
        public void WhenGeneratePrivateEmbedIframeTag_ThenCheckCode()
        {
            // Arrange
            using (SimpleServer.Create(TestHelpers.BaseUrl, GenerateEmbledHandler))
            {
                var client = new YouScribeClient(TestHelpers.BaseUrl);
                client.AuthorizeAsync("test", "password").Wait();

                var request = client.CreateEmbedRequest();

                int productId = 1;

                // Act
                var tag = request.GeneratePrivateIframeTagAsync(productId).Result;

                // Assert
                Assert.NotEmpty(tag);
                Assert.Equal("embed3", tag);
            }
        }
Exemplo n.º 33
0
        public void WhenPublishDocumentFromUrl_ThenCheckResponse()
        {
            // Arrange
            using (SimpleServer.Create(TestHelpers.BaseUrl, ProductRequestHandler))
            {
                var client = new YouScribeClient(TestHelpers.BaseUrl);

                client.AuthorizeAsync("test", "password").Wait();

                var request = client.CreateProductRequest();

                // Act
                var product = request.PublishDocumentAsync(new Models.Products.ProductModel
                {
                    Title = "my document title"
                },
                new[] {
                    new Uri("http://exemple.com/test.pdf")
                }).Result;

                // Assert
                Assert.NotNull(product);
                Assert.Equal(42, product.Id);
                Assert.Equal("my document title", product.Title);
                Assert.Equal("{\"Id\":0,\"Title\":\"my document title\",\"Description\":null,\"Collection\":null,\"PublishDate\":null,\"EAN13\":null,\"Public\":true,\"IsFree\":true,\"Price\":null,\"People\":null,\"Languages\":null,\"Tags\":null,\"CategoryId\":0,\"ThemeId\":0,\"AllowPasteAndCut\":false,\"AllowPrint\":false,\"AllowPrintOnDemand\":false,\"AllowDownload\":true,\"AllowStreaming\":true,\"IsAdultContent\":false,\"PreviewNbPage\":null,\"PreviewPercentPage\":null,\"PreviewRange\":null,\"CopyrightInformation\":0,\"LicenceName\":null}",
                    requestContent);
            }
        }
Exemplo n.º 34
0
        public void WhenUpdateDocumentFromFile_ThenCheckResponse()
        {
            // Arrange
            using (SimpleServer.Create(TestHelpers.BaseUrl, ProductRequestHandler))
            {
                var client = new YouScribeClient(TestHelpers.BaseUrl);

                client.AuthorizeAsync("test", "password").Wait();

                var request = client.CreateProductRequest();

                // Act
                bool ok = request.UpdateDocumentAsync(42, new Models.Products.ProductUpdateModel
                {
                    Description = "ok"
                },
                new[] {
                    new YouScribe.Rest.Models.FileModel { Content = new MemoryStream(), FileName ="test2.pdf", ContentType = "application/pdf" }
                }).Result;

                // Assert
                Assert.True(ok);
            }
        }
Exemplo n.º 35
0
        public void WhenUpdateAccount_ThenCheckResponse()
        {
            // Arrange
            using (SimpleServer.Create(TestHelpers.BaseUrl, AccountHandler))
            {
                var client = new YouScribeClient(TestHelpers.BaseUrl);

                client.AuthorizeAsync("test", "password").Wait();

                var request = client.CreateAccountRequest();

                // Act
                bool ok = request.UpdateAsync(new Models.Accounts.AccountModel { Id = 42, FirstName = "kikou" }).Result;

                // Assert
                Assert.True(ok);
                Assert.Equal("{\"Id\":42,\"UserName\":null,\"Password\":null,\"Email\":null,\"FirstName\":\"kikou\",\"LastName\":null,\"Gender\":null,\"Civility\":null,\"BirthDate\":null,\"CountryCode\":null,\"BlogUrl\":null,\"WebSiteUrl\":null,\"FacebookPage\":null,\"TwitterPage\":null,\"City\":null,\"Biography\":null,\"PhoneNumber\":null,\"EmailIsPublic\":false,\"DomainLanguageIsoCode\":null,\"TrackingId\":\"00000000-0000-0000-0000-000000000000\",\"YsAuthToken\":null}",
                    requestContent);
            }
        }
Exemplo n.º 36
0
        public void WhenUploadPictureFromLocalFile_ThenCheckResponse()
        {
            // Arrange
            using (SimpleServer.Create(TestHelpers.BaseUrl, AccountHandler))
            {
                var client = new YouScribeClient(TestHelpers.BaseUrl);

                client.AuthorizeAsync("test", "password").Wait();

                var request = client.CreateAccountRequest();

                // Act
                bool ok = request.UploadPictureAsync(new Models.FileModel { Content = new MemoryStream(), ContentType = "image/png", FileName = "test.png" }).Result;

                // Assert
                Assert.Contains("Content-Disposition: form-data; name=file; filename=test.png; filename*=utf-8''test.png", requestContent);
                Assert.True(ok);
            }
        }
Exemplo n.º 37
0
        public void WhenUpdateDocumentThumbnailFromFile_ThenCheckResponse()
        {
            // Arrange
            using (SimpleServer.Create(TestHelpers.BaseUrl, ProductRequestHandler))
            {
                var client = new YouScribeClient(TestHelpers.BaseUrl);

                client.AuthorizeAsync("test", "password").Wait();

                var request = client.CreateProductRequest();

                // Act
                bool ok = request.UpdateDocumentThumbnailAsync(42, new YouScribe.Rest.Models.FileModel
                {
                    Content = new MemoryStream(),
                    FileName = "image.jpg",
                    ContentType = "image/jpg"
                }).Result;

                // Assert
                Assert.True(ok);
            }
        }
Exemplo n.º 38
0
        public void WhenUpdateDocumentThumbnailFromUrl_ThenCheckResponse()
        {
            // Arrange
            using (SimpleServer.Create(TestHelpers.BaseUrl, ProductRequestHandler))
            {
                var client = new YouScribeClient(TestHelpers.BaseUrl);

                client.AuthorizeAsync("test", "password").Wait();

                var request = client.CreateProductRequest();

                // Act
                bool ok = request.UpdateDocumentThumbnailAsync(42, new Uri("http://exemple.com/thumbnail.png")).Result;

                // Assert
                Assert.True(ok);
            }
        }
Exemplo n.º 39
0
        public void WhenUploadPictureFromUrl_ThenCheckResponse()
        {
            // Arrange
            using (SimpleServer.Create(TestHelpers.BaseUrl, AccountHandler))
            {
                var client = new YouScribeClient(TestHelpers.BaseUrl);

                client.AuthorizeAsync("test", "password").Wait();

                var request = client.CreateAccountRequest();

                // Act
                bool ok = request.UploadPictureAsync(new Uri("http://exmple.com/image.jpg")).Result;

                // Assert
                Assert.True(ok);
            }
        }
Exemplo n.º 40
0
        public void WhenUpdateDocumentFromUrl_ThenCheckResponse()
        {
            // Arrange
            using (SimpleServer.Create(TestHelpers.BaseUrl, ProductRequestHandler))
            {
                var client = new YouScribeClient(TestHelpers.BaseUrl);

                client.AuthorizeAsync("test", "password").Wait();

                var request = client.CreateProductRequest();

                // Act
                bool ok = request.UpdateDocumentAsync(42, new Models.Products.ProductUpdateModel
                {
                    Description = "ok"
                },
                new[] {
                    new Uri("http://exemple.com/test2.pdf")
                }).Result;

                // Assert
                Assert.True(ok);
            }
        }
Exemplo n.º 41
0
        public void WhenSetSpokenLanguages_ThenCheckResponse()
        {
            // Arrange
            using (SimpleServer.Create(TestHelpers.BaseUrl, AccountHandler))
            {
                var client = new YouScribeClient(TestHelpers.BaseUrl);

                client.AuthorizeAsync("test", "password").Wait();

                var request = client.CreateAccountRequest();

                // Act
                bool ok = request.SetSpokenLanguagesAsync(new[] { "fr", "en" }).Result;

                // Assert
                Assert.True(ok);
                Assert.Equal("Languages=fr&Languages=en", requestContent);
            }
        }