示例#1
0
        public async Task ReadAsStringAsyncReturnsEmptyString()
        {
            var nullContent = new NullContent();
            var result      = await nullContent.ReadAsStringAsync();

            Assert.Equal(string.Empty, result);
        }
示例#2
0
        private HttpContent CreateHttpContent(RestRequest restRequest)
        {
            if (restRequest.Method != HttpMethod.Post && restRequest.Method != HttpMethod.Put)
            {
                return(null);
            }

            HttpContent httpContent;

            switch (restRequest.ContentType)
            {
            case RestContentType.Json:
                var json = this.Serializer.Serialize(restRequest.Content);
                httpContent = new StringContent(json, restRequest.ContentEncoding, "application/json");
                if (restRequest.ContentEncoding == null)
                {
                    httpContent.Headers.ContentType.CharSet = null;
                }
                httpContent.Headers.ContentLength = json.Length;
                break;

            case RestContentType.FormUrlEncoded:
                httpContent = new CustomFormUrlEncodedContent(restRequest.Content);
                break;

            default:
                httpContent = new NullContent();
                break;
            }
            if (httpContent.Headers.ContentLength == null)
            {
                httpContent.Headers.ContentLength = 0;
            }
            return(httpContent);
        }
        public IEnumerator ContentProvider_WhenGivenNullContent_Exits()
        {
            var content = new NullContent();

            LogAssert.Expect(LogType.Error, "SelectionUtilityTests.NullContent: Releasing content named 'Null' because it returned null value.");
            SelectionUtility.ShowInWindow(content);
            for (var i = 0; i < 10; ++i)
            {
                yield return(null);
            }
            Assert.That(Resources.FindObjectsOfTypeAll <ContentWindow>().Any(), Is.False);
        }
示例#4
0
 // The empty constructor should not call the base constructor
 // Otherwise the document will be initialized after empty construction and the factory will initialize it again
 public TestDocument()
 {
     Metadata        = new TestMetadata();
     ContentProvider = new NullContent();
 }
示例#5
0
        public void ContentLengthIsZero()
        {
            var nullContent = new NullContent();

            Assert.Equal(0, nullContent.Headers.ContentLength);
        }
示例#6
0
        public void ContentRangeIsNull()
        {
            var nullContent = new NullContent();

            Assert.Null(nullContent.Headers.ContentRange);
        }
示例#7
0
        public void ContentMD5IsNull()
        {
            var nullContent = new NullContent();

            Assert.Null(nullContent.Headers.ContentMD5);
        }
示例#8
0
        public void ContentLanguageIsEmpty()
        {
            var nullContent = new NullContent();

            Assert.Equal(0, nullContent.Headers.ContentLanguage.Count);
        }
示例#9
0
        public void ContentEncodingIsEmpty()
        {
            var nullContent = new NullContent();

            Assert.Equal(0, nullContent.Headers.ContentEncoding.Count);
        }
示例#10
0
        public void AllowIsEmpty()
        {
            var nullContent = new NullContent();

            Assert.Equal(0, nullContent.Headers.Allow.Count);
        }
示例#11
0
        public void ContentDispositionIsNull()
        {
            var nullContent = new NullContent();

            Assert.Null(nullContent.Headers.ContentDisposition);
        }
示例#12
0
 private void Awake()
 {
     nullContent = new NullContent();
     CellContent = nullContent;
 }