コード例 #1
0
		/// <summary>
		/// Runs the prune operation.
		/// </summary>
		/// <returns>A task that represents the prune operation.</returns>
		/// <param name="renameOption">Parsed prune options.</param>
		public Task RunPruneAsync(PruneOptions pruneOption)
		{
			if (pruneOption == null)
				throw new ArgumentNullException("pruneOption");

			LogHelper.InitializeLogging(pruneOption);

            Log.T("Processing 'prune' operation.");
			pruneOption.FilesOrDirectories = _optionsUtils.EnsureFilesOrDirectoriesValues(pruneOption);

            if (pruneOption.Gather)
            {
                Log.D("Processing 'prune gather' operation.");
                return _pruneOperation.GatherAsync(pruneOption.FilesOrDirectories, pruneOption.Recursive, pruneOption.AcceptanceThreshold);
            }
            if (pruneOption.Commit)
            {
                Log.D("Processing 'prune commit' operation.");
                return _pruneOperation.CommitAsync(pruneOption.FilesOrDirectories, pruneOption.Recursive);
            }
            return Task.FromResult(0);
		}
コード例 #2
0
		public void RunPruneAsync_CommitTrue_CheckCommitAsyncCalled()
		{
			// Arrange
			var options = new PruneOptions() {
				FilesOrDirectories = new[] { "SomeVerb", @"C:\Temp" },
				Recursive = true,
				AcceptanceThreshold = 65,
				Commit = true,
			};

			var filesOrDirectories = new List<string>() { "SomeVerb", @"C:\Temp" };
			_optionUtils.EnsureFilesOrDirectoriesValues(options).Returns(filesOrDirectories);

			var expectedTask = Task.FromResult(0);
			_pruneOperation.CommitAsync(filesOrDirectories, options.Recursive).Returns(expectedTask);

			// Act
			var task = _target.RunPruneAsync(options);

			// Assert
			_pruneOperation.Received(1).CommitAsync(filesOrDirectories, options.Recursive);
			Assert.AreSame(expectedTask, task);
		}
コード例 #3
0
		public void RunPruneAsync_OptionsOk_CheckEnsureFilesOrDirectoriesValuesCalled()
		{
			// Arrange
			var options = new PruneOptions() {
				FilesOrDirectories = new[] { "SomeVerb", @"C:\Temp" },
				Recursive = true,
				Gather = true,
			};

			var expected = new List<string>() { "SomeVerb", @"C:\Temp" };
			_optionUtils.EnsureFilesOrDirectoriesValues(options).Returns(expected);

			// Act
			_target.RunPruneAsync(options);

			// Assert
			_optionUtils.Received(1).EnsureFilesOrDirectoriesValues(options);
			CollectionAssert.AreEquivalent(expected, options.FilesOrDirectories);
		}