public void ReadAsFile_Test() { var dataDirectory = @"Data\BeastSaber"; var jsonFile = Path.Combine(dataDirectory, "bookmarked_by_zingabopp1.json"); using (var mockContent = new MockHttpContent(jsonFile)) { var expectedString = File.ReadAllText(mockContent.FileSourcePath); var dirPath = new DirectoryInfo(DownloadPath); var destPath = Path.Combine(dirPath.FullName, Path.GetFileName(mockContent.FileSourcePath)); mockContent.ReadAsFileAsync(destPath, true).Wait(); var actualString = mockContent.ReadAsStringAsync().Result; Assert.AreEqual(expectedString, actualString); AssertAsync.ThrowsExceptionAsync <InvalidOperationException>(async() => await mockContent.ReadAsFileAsync(destPath, false).ConfigureAwait(false)).Wait(); } }