本文整理汇总了C#中TestData.Open方法的典型用法代码示例。如果您正苦于以下问题:C# TestData.Open方法的具体用法?C# TestData.Open怎么用?C# TestData.Open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestData
的用法示例。
在下文中一共展示了TestData.Open方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestFileDownload
/// <summary>
/// Downloads the specified test file and verifies its contents.
/// </summary>
private async Task TestFileDownload(TestData.TestFile testFile)
{
var target = Path.GetTempFileName();
try
{
Debug.WriteLine("Temporary local file: " + target);
using (var feedback = new DebugFeedbackChannel("Test"))
{
using (var initializing = feedback.BeginSubOperation("InitializeData"))
await TestData.Current.BringToInitialState(initializing);
var client = new MegaClient(TestData.Current.Email1, TestData.Current.Password1);
var filesystem = await client.GetFilesystemSnapshotAsync(feedback);
var file = testFile.TryFind(filesystem);
if (file == null)
Assert.Fail("Could not find expected file to download: " + testFile.Name);
await file.DownloadContentsAsync(target, feedback);
using (var expectedContents = testFile.Open())
using (var contents = File.OpenRead(target))
TestHelper.AssertStreamsAreEqual(expectedContents, contents);
}
}
finally
{
File.Delete(target);
}
}
示例2: TestFileUpload
/// <summary>
/// Uploads the specified test file and ensures that it looks like it really did get uploaded.
/// </summary>
private async Task TestFileUpload(TestData.TestFile testFile)
{
using (var feedback = new DebugFeedbackChannel("Test"))
{
var client = new MegaClient(TestData.Current.Email1, TestData.Current.Password1);
var filesystem = await client.GetFilesystemSnapshotAsync(feedback);
// Just stick it in the root, do not care about what already exists there.
CloudItem file;
using (var stream = testFile.Open())
file = await filesystem.Files.NewFileAsync(testFile.Name, stream, feedback);
Assert.AreEqual(testFile.Name, file.Name);
Assert.AreEqual(testFile.Size, file.Size);
}
}