private static MockFileDropWindow SetupWindow() { var window = new MockFileDropWindow() { Top = -10000, }; //ウインドウ表示 window.Show(); return(window); }
public async Task Drop_OneFile() { MockFileDropWindow window = SetupWindow(); //ステージ1 初期状態 window.TargetTextBlock.Text .Should().BeEmpty("初期状態なので空のはず"); //ステージ2 DropPreview const string dropFilePath = @"D:\Documents"; string[] dropFilePaths = new[] { dropFilePath }; DragEventArgs dragEventArgs = CreateDragEventArgs(dropFilePaths, window, DragDrop.PreviewDragOverEvent); dragEventArgs.Handled .Should().BeFalse("プレビュー前なので、まだハンドルされてない"); dragEventArgs.Effects .Should().NotBe(DragDropEffects.Copy, "プレビュー前なので、定まっていない"); window.RaiseEvent(dragEventArgs); dragEventArgs.Handled .Should().BeTrue("プレビュー後なので、ハンドルされている"); dragEventArgs.Effects .Should().Be(DragDropEffects.Copy, "プレビュー後なので、定まっている"); //ステージ3 Drop後 DragEventArgs dragEventArgs2 = CreateDragEventArgs(dropFilePaths, window, DragDrop.DropEvent); window.RaiseEvent(dragEventArgs2); await Task.Delay(100); window.TargetTextBlock.Text .Should().Contain(dropFilePath, because: "ドロップされたフィルパスがUIに反映されているはず"); }