예제 #1
0
        private FileContent GetChangedFileContent()
        {
            if (File.Exists(FilePath))
            {
                var binaryFileContent = new BinaryFileContent();
                binaryFileContent.Load(FilePath);
                int fileSize = binaryFileContent.FileContents.Length;

                FileContent fileContent;
                if (binaryFileContent.IsTextFile())
                {
                    fileContent = new StringFileContent();
                    fileContent.Load(FilePath);
                }
                else
                {
                    fileContent = binaryFileContent;
                }

                fileContent.LastWriteTime = File.GetLastWriteTime(FilePath);
                fileContent.FileSize      = fileSize;
                return(fileContent);
            }
            return(new DirectoryContent());
        }
예제 #2
0
        public void ContentType_is_attached_to_HttpContent(string testContent)
        {
            const string testContentType = "test/json";

            var fileContent = new StringFileContent(testContent, contentType: testContentType);
            var httpContent = fileContent.ToContent();

            httpContent.Headers.ContentType.MediaType.ShouldBe(testContentType);
        }
예제 #3
0
        public async Task ToContent_returns_StringContent(string testContent)
        {
            var fileContent = new StringFileContent(testContent);
            var httpContent = fileContent.ToContent();

            httpContent.ShouldNotBeNull();
            var actualValue = await httpContent.ReadAsStringAsync();

            actualValue.ShouldBe(testContent);
        }