public void CreateRequest_WithNullParameters_ThrowsArgumentNullException(HttpMethod httpMethod, string url)
 {
     var requestBuilder = new ProfileRequestBuilder();
     var exception = Record.Exception(() => requestBuilder.CreateRequest(null, null));
     Assert.NotNull(exception);
     Assert.IsType<ArgumentNullException>(exception);
 }
        public void BuildRequestMessage_AcceptLanguageHeader_Equal(AcceptLanguage acceptLanguage)
        {
            var options = new ProfileOptions("Hello World") {AcceptLanguage = acceptLanguage};
            var requestBuilder = new ProfileRequestBuilder();
            var message = requestBuilder.BuildRequestMessage(ServiceUrl, options, false);

            Assert.Equal($"{acceptLanguage}".ToLower(), message.Headers.AcceptLanguage.First().Value);
        }
        public async Task BuildRequestMessage_ProfileWithText_Equal(string content)
        {
            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(content, actual);
        }
        public void BuildRequestMessage_WithNullArguments_ThrowsArgumentNullException(string serviceUrl,
            ProfileOptions options)
        {
            var requestBuilder = new ProfileRequestBuilder();

            var exception =
                Record.Exception(() => requestBuilder.BuildRequestMessage(serviceUrl, options, false));
            Assert.NotNull(exception);
            Assert.IsType<ArgumentNullException>(exception);
        }
        public void CreateRequest_Equal()
        {
            var requestBuilder = new ProfileRequestBuilder();

            var request = requestBuilder.CreateRequest(HttpMethod.Get, ServiceUrl);

            Assert.NotNull(request);
            Assert.Equal(ServiceUrl, request.RequestUri.ToString());
            Assert.Equal(HttpMethod.Get, request.Method);
        }
        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 void BuildRequestMessage_ContentLanguageHeader_Equal(ContentLanguage contentLanguage)
        {
            var options = new ProfileOptions("Hello World") {ContentLanguage = contentLanguage};
            var requestBuilder = new ProfileRequestBuilder();
            var message = requestBuilder.BuildRequestMessage(ServiceUrl, options, false);

            Assert.Equal($"{contentLanguage}".ToLower(), message.Content.Headers.ContentLanguage.FirstOrDefault());
        }
        public void BuildRequestMessage_AcceptHeaders_Equal(string expected, bool asCsv)
        {
            var options = new ProfileOptions("Hello World");
            var requestBuilder = new ProfileRequestBuilder();
            var message = requestBuilder.BuildRequestMessage(ServiceUrl, options, asCsv);

            Assert.Equal(expected, message.Headers.Accept.First().MediaType);
        }
 public void BuildRequestMessage_Uri_Equal(string serviceUrl, ProfileOptions options)
 {
     var requestBuilder = new ProfileRequestBuilder();
     var message = requestBuilder.BuildRequestMessage(ServiceUrl, options, false);
     Assert.Equal(serviceUrl, message.RequestUri.ToString());
 }
        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);
        }