public void ShouldCreateNewObjectWhenDroppedFromDifferentCollectionThanSourceCollection() { // Given const int index = 1; var element = new TwoPointNonUniformityCorrectionTemplate(); var dataSource = new ProcessingChainDataStore(); var targetCollection = dataSource.ProcessingChainTemplate; var sourceCollection = new List <IProcessingChainElementTemplate> { element }; sourceCollection.Insert(index, element); var dropInfo = new TestDropInfo { Data = element, TargetCollection = targetCollection, DragInfo = new TestDragInfo { SourceCollection = sourceCollection }, InsertIndex = index }; var dropHandler = new ProcessingChainDropHandler(); // When dropHandler.Drop(dropInfo); var targetCollectionElement = targetCollection[index]; // Then Assert.IsNotNull(targetCollectionElement); Assert.AreEqual(index, targetCollection.IndexOf(targetCollectionElement)); Assert.IsFalse(ReferenceEquals(element, targetCollectionElement)); }
public void ShouldThrowExceptionWhenObjectDroppedFromOtherCollectionDoesNotContainParameterlessConstructor() { // Given const int index = 1; var element = new ParameterlessConstructorTestObject(1); var dataSource = new ProcessingChainDataStore(); var sourceCollection = new List <object> { element }; var targetCollection = dataSource.ProcessingChainTemplate; var dropInfo = new TestDropInfo { Data = element, TargetCollection = targetCollection, DragInfo = new TestDragInfo { SourceCollection = sourceCollection }, InsertIndex = index }; var dropHandler = new ProcessingChainDropHandler(); // When // Then Assert.Throws <ArgumentException>(() => dropHandler.Drop(dropInfo)); }
public void ShouldNotAllowToDragOverItemsAtStartOrEndOfCollection(int index) { // Given var dropInfo = new TestDropInfo { Data = new TwoPointNonUniformityCorrectionTemplate(), TargetCollection = new object[3], InsertIndex = index }; var dropHandler = new ProcessingChainDropHandler(); // When dropHandler.DragOver(dropInfo); // Then Assert.AreEqual(DragDropEffects.None, dropInfo.Effects); }
public void ShouldNotAllowToDragOverItemsOtherThanImageProcessingAlgorithmTemplates(Type elementType, bool shouldAllowToDragOver) { // Given var dropInfo = new TestDropInfo { Data = elementType.GetConstructor(Type.EmptyTypes)?.Invoke(null), TargetCollection = new object[3], DragInfo = new TestDragInfo { SourceCollection = new object[3] }, InsertIndex = 1 }; var dropHandler = new ProcessingChainDropHandler(); // When dropHandler.DragOver(dropInfo); // Then Assert.AreEqual(shouldAllowToDragOver, dropInfo.Effects != DragDropEffects.None); }