public void Content_SerializeObject_Equal() { var contentItems = new List<ContentItem> { new ContentItem { Content = "This is a sample tweet", Charset = "utf-8", ContentType = "text/plain", Created = 1420070400, Forward = false, Id = "245160944223793152", ContentLanguage = ContentLanguage.En, Reply = false, SourceId = "twitter", Updated = 1420070400, UserId = "bob" } }; var content = new Content(contentItems); var actual = JsonConvert.SerializeObject(content); var expected = "{\"ContentItems\":[{\"Charset\":\"utf-8\",\"Content\":\"This is a sample tweet\",\"ContentType\":\"text/plain\",\"Created\":1420070400,\"Forward\":false,\"Id\":\"245160944223793152\",\"ContentLanguage\":\"en\",\"ParentId\":null,\"Reply\":false,\"SourceId\":\"twitter\",\"Updated\":1420070400,\"UserId\":\"bob\"}]}"; Assert.Equal(expected, actual); }
public void ProfileOptions_Constructor2_Equal() { var content = new Content(); var contentItems = new List<ContentItem> { new ContentItem { Content = "This is a sample tweet", Charset = "utf-8", ContentType = "text/plain", Created = 1454450300, Forward = false, Id = "245160944223793152", ContentLanguage = ContentLanguage.En, Reply = false, SourceId = "twitter", Updated = 1454450300, UserId = "bob" } }; content.ContentItems = contentItems; var profileOptions = new ProfileOptions(content); Assert.Equal("application/json", profileOptions.ContentType); Assert.Equal(1, content.ContentItems.Count()); Assert.Equal(ContentLanguage.En, profileOptions.ContentLanguage); Assert.Equal(AcceptLanguage.En, profileOptions.AcceptLanguage); Assert.Equal(false, profileOptions.IncludeRaw); Assert.Null(profileOptions.Text); }
public void BuildRequestMessage_WithEmptyContentItem_ThrowsArgumentOutOfRangeException() { IContent content = new Content(); var options = new ProfileOptions(content); var requestBuilder = new ProfileRequestBuilder(); var exception = Record.Exception(() => requestBuilder.BuildRequestMessage(ServiceUrl, options, false)); Assert.NotNull(exception); Assert.IsType<ArgumentOutOfRangeException>(exception); }
public async Task GetProfileAsync_WithContentItems_IsNotNull() { var content1 = File.ReadAllText("SampleContent1.txt"); var content2 = File.ReadAllText("SampleContent2.txt"); var service = new PersonalityInsightsService(Settings.Username, Settings.Password); var contentItems = new List<ContentItem> { new ContentItem(content1), new ContentItem(content2) }; var content = new Content(contentItems); var options = new ProfileOptions(content); var profile = await service.GetProfileAsync(options).ConfigureAwait(false); Assert.NotNull(profile); }
public void Content_ConstructorWithContentItems_Equal() { var contentItems = new List<ContentItem> { new ContentItem { Content = "This is a sample tweet", Charset = "utf-8", ContentType = "text/plain", Created = 1454448603, Forward = false, Id = "245160944223793152", ContentLanguage = ContentLanguage.En, Reply = false, SourceId = "twitter", Updated = 1454448603, UserId = "bob" } }; var content = new Content(contentItems); Assert.InRange(content.ContentItems.Count(), 1, 5); }
public async Task BuildRequestMessage_ProfileWithContentItems_Equal() { var content = new Content(); var contentItems = new List<ContentItem> { new ContentItem { Content = "This is a sample tweet", Charset = "utf-8", ContentType = "text/plain", Created = 1420070400, Forward = false, Id = "245160944223793152", ContentLanguage = ContentLanguage.En, Reply = false, SourceId = "twitter", Updated = 1420070400, UserId = "bob" } }; content.ContentItems = contentItems; var expected = "{\"ContentItems\":[{\"Charset\":\"utf-8\",\"Content\":\"This is a sample tweet\",\"ContentType\":\"text/plain\",\"Created\":1420070400,\"Forward\":false,\"Id\":\"245160944223793152\",\"ContentLanguage\":\"en\",\"ParentId\":null,\"Reply\":false,\"SourceId\":\"twitter\",\"Updated\":1420070400,\"UserId\":\"bob\"}]}"; var options = new ProfileOptions(content); var requestBuilder = new ProfileRequestBuilder(); var message = requestBuilder.BuildRequestMessage(ServiceUrl, options, false); var actual = await message.Content.ReadAsStringAsync().ConfigureAwait(false); Assert.Equal(expected, actual); }