当前位置: 首页>>代码示例>>C#>>正文


C# TestData.Open方法代码示例

本文整理汇总了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);
			}
		}
开发者ID:AIBrain,项目名称:mega-client,代码行数:36,代码来源:FileTransferTests.cs

示例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);
			}
		}
开发者ID:AIBrain,项目名称:mega-client,代码行数:19,代码来源:FileTransferTests.cs


注:本文中的TestData.Open方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。