public void FileDrop() { var captureImageMock = new Mock <ICaptureImageService>(); var captureImageService = captureImageMock.Object; var imageProvider = new ImageProvider(WeakReferenceMessenger.Default, captureImageService); var dropTarget = new ImageDropTarget(captureImageService, imageProvider, true); var mock = new Mock <IDropInfo>(); var elm = new ListView(); mock.SetupGet(d => d.VisualTarget).Returns(elm); mock.SetupGet(d => d.Data).Returns(CreateData()); captureImageMock.Setup(c => c.IsImageFile(It.IsAny <string>())).Returns(true); dropTarget.DragOver(mock.Object); dropTarget.Drop(mock.Object); mock.VerifySet(d => d.NotHandled = It.IsAny <bool>(), Times.Never()); mock.VerifySet(d => d.Effects = DragDropEffects.Copy); mock.VerifySet(d => d.DropTargetAdorner = It.IsAny <Type>(), Times.Never()); captureImageMock.Verify(c => c.GetImageFromFile(@"C:\Foo\bar1.jpg")); captureImageMock.Verify(c => c.GetImageFromFile(@"C:\Foo\bar2.jpg")); captureImageMock.Verify(c => c.GetImageFromFile(@"C:\Foo\bar10.jpg")); captureImageMock.Verify(c => c.GetImageFromFile(@"C:\Foo\foo2.jpg"));
public void NotMatchAllowOtherDrop() { var captureImageMock = new Mock <ICaptureImageService>(); var captureImageService = captureImageMock.Object; var imageProvider = new ImageProvider(WeakReferenceMessenger.Default, captureImageService); var dropTarget = new ImageDropTarget(captureImageService, imageProvider, true); var mock = new Mock <IDropInfo>(); var elm = new ListView(); mock.SetupGet(d => d.VisualTarget).Returns(elm); dropTarget.DragOver(mock.Object); mock.VerifySet(d => d.NotHandled = true, Times.Once()); dropTarget.Drop(mock.Object); mock.VerifySet(d => d.NotHandled = true, Times.Exactly(2)); }
public void SameVisualSource() { var captureImageMock = new Mock <ICaptureImageService>(); var captureImageService = captureImageMock.Object; var imageProvider = new ImageProvider(WeakReferenceMessenger.Default, captureImageService); var dropTarget = new ImageDropTarget(captureImageService, imageProvider); var mock = new Mock <IDropInfo>(); var elm = new ListView(); mock.SetupGet(d => d.VisualTarget).Returns(elm); var dragInfoMock = new Mock <IDragInfo>(); dragInfoMock.SetupGet(d => d.VisualSource).Returns(elm); mock.SetupGet(d => d.DragInfo).Returns(dragInfoMock.Object); dropTarget.DragOver(mock.Object); dropTarget.Drop(mock.Object); mock.VerifySet(d => d.NotHandled = It.IsAny <bool>(), Times.Never()); }