SubscribeAsync() public method

public SubscribeAsync ( string pattern, Action handler ) : Task
pattern string
handler Action
return Task
		public async Task TestSubscription()
		{
			var fileSystem = new FileSystem(TestContext.TestRunDirectory);
			fileSystem.RemoveFile(TestFileName);

			Assert.AreEqual(false, fileSystem.FileExists(TestFileName));

			var c = new TaskCompletionSource<IFileInfo>();
			using (await fileSystem.SubscribeAsync(TestFilePattern, s => c.TrySetResult(s)).ConfigureAwait(false))
			{
				using (var writer = new StreamWriter(fileSystem.OpenWrite(TestFileName)))
				{
					writer.BaseStream.SetLength(0);
					writer.Write("123456789");
				}

				var result = await c.Task.ConfigureAwait(false);
				Assert.AreEqual(TestFileName.ToString(), Path.GetFileName(result.FilePath.ToString()));
			}
		}