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()); }
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); }
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); }