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 ShouldContainImageProviderAndImageDisplayTemplatesWhenCreated() { // Given // When var dataStore = new ProcessingChainDataStore(); // Then Assert.AreEqual(2, dataStore.ProcessingChainTemplate.Count); Assert.IsTrue(dataStore.ProcessingChainTemplate.Any(i => i.GetType() == typeof(ImageProviderTemplate))); Assert.IsTrue(dataStore.ProcessingChainTemplate.Any(i => i.GetType() == typeof(ImageDisplayTemplateTemplate))); }