public void RunClassifyAsync_OptionsOk_ChewckRunClassifyAsyncCalled() { // Arrange var options = new ClassifyOptions() { Source = @"C:\Source", Target = @"C:\Target", Recursive = true, Hierarchy = "Year,Month", ActionType = ActionType.Move, }; var expectedTask = Task.FromResult(0); _classifyOperation.ClassifyAsync(options.Source, options.Target, options.Recursive, options.ActionType, options.HierarchyTyped.ToArray()).Returns(expectedTask); // Act var task = _target.RunClassifyAsync(options); // Assert _classifyOperation.Received(1).ClassifyAsync(options.Source, options.Target, true, options.ActionType, options.HierarchyTyped.ToArray()); Assert.AreSame(expectedTask, task); }
public void RunClassifyAsync_TargetNull_SetTargetAsSource() { // Arrange var options = new ClassifyOptions() { Source = @"C:\Source", Target = null, Recursive = false, Hierarchy = "Year,Month", ActionType = ActionType.Link, }; // Act _target.RunClassifyAsync(options); // Assert _classifyOperation.Received(1).ClassifyAsync(options.Source, options.Source, false, ActionType.Link, options.HierarchyTyped.ToArray()); }
/// <summary> /// Runs the classify operation. /// </summary> /// <returns>A task that represents the classify operation.</returns> /// <param name="classifyOptions">Parsed classify options.</param> public Task RunClassifyAsync(ClassifyOptions classifyOptions) { if (classifyOptions == null) throw new ArgumentNullException("classifyOptions"); LogHelper.InitializeLogging(classifyOptions); Log.T("Processing 'classify' operation."); if (string.IsNullOrWhiteSpace(classifyOptions.Target)) { Log.I("Target was empty, use source '{0}' as target.", classifyOptions.Source); classifyOptions.Target = classifyOptions.Source; } return _classifyOperation.ClassifyAsync( classifyOptions.Source, classifyOptions.Target, classifyOptions.Recursive, classifyOptions.ActionType, classifyOptions.HierarchyTyped.ToArray()); }