public TFormat GetData <TFormat>(ConnectedDragDropKey <TFormat> key) { Contract.Requires <ArgumentNullException>(key != null); Contract.Requires <InvalidOperationException>(this.IsActive); return(default(TFormat)); }
public void ThrowsExceptionWhenGettingDataForResolvedNotConnected() { var key = new ConnectedDragDropKey <Type>(); var data = typeof(ConnectedDragDropTests); var dragDrop = new ConnectedDragDrop(this._uriDisconnectTable); ExceptionAssert.Throws <InvalidOperationException>(() => dragDrop.GetData(key)); }
public void ThrowsExceptionWhenSettingDataWhileNotDragging() { var key = new ConnectedDragDropKey <Type>(); var data = typeof(ConnectedDragDropTests); var dragDrop = new ConnectedDragDrop(this._uriDisconnectTable); ExceptionAssert.Throws <InvalidOperationException>(() => dragDrop.SetData(key, data)); }
/// <summary> /// Gets the data saved for dragging. /// </summary> /// <typeparam name="TFormat">The data type.</typeparam> /// <param name="key">The key for data lookup.</param> /// <returns>The requested data or default value of the <typeparamref name="TFormat"/> type, /// if the data wasn't found.</returns> public TFormat GetData <TFormat>(ConnectedDragDropKey <TFormat> key) { if (this._data.Contains(key)) { return((TFormat)this._data[key]); } return(default(TFormat)); }
public void ReturnsDataNotPresentForDataHasNotBeenSet() { var connected = new object(); var key1 = new ConnectedDragDropKey <Type>(); var key2 = new ConnectedDragDropKey <Assembly>(); var dragDrop = new ConnectedDragDrop(this._uriDisconnectTable); dragDrop.Drag(connected); dragDrop.SetData(key1, typeof(ConnectedDragDropTests)); Assert.IsFalse(dragDrop.GetDataPresent(key2)); }
public void SetsMultipleFormatData() { var connected = new object(); var key1 = new ConnectedDragDropKey <Type>(); var key2 = new ConnectedDragDropKey <Assembly>(); var dragDrop = new ConnectedDragDrop(this._uriDisconnectTable); dragDrop.Drag(connected); dragDrop.SetData(key1, typeof(ConnectedDragDropTests)); dragDrop.SetData(key2, typeof(ConnectedDragDropTests).Assembly); Assert.AreSame(typeof(ConnectedDragDropTests), dragDrop.GetData(key1)); Assert.AreSame(typeof(ConnectedDragDropTests).Assembly, dragDrop.GetData(key2)); }
public void DoNotDisposesDataOnDrop() { var connected = new object(); var dragDrop = new ConnectedDragDrop(this._uriDisconnectTable); dragDrop.Drag(connected); var key1 = new ConnectedDragDropKey <IDisposable>(); var key2 = new ConnectedDragDropKey <IContainer>(); var disposable1 = Substitute.For <IDisposable>(); var disposable2 = Substitute.For <IContainer>(); dragDrop.SetData(key1, disposable1); dragDrop.SetData(key2, disposable2); var targetConnector = Substitute.For <IUriPlacementConnector>(); dragDrop.Drop(targetConnector); disposable1.DidNotReceive().Dispose(); disposable2.DidNotReceive().Dispose(); }
public void DisposesDataOnDisconnect() { var connected = new object(); var dragDrop = new ConnectedDragDrop(this._uriDisconnectTable); dragDrop.Drag(connected); var key1 = new ConnectedDragDropKey <IDisposable>(); var key2 = new ConnectedDragDropKey <IContainer>(); var disposable1 = Substitute.For <IDisposable>(); var disposable2 = Substitute.For <IContainer>(); dragDrop.SetData(key1, disposable1); dragDrop.SetData(key2, disposable2); IUriPlacementConnector dragDropConnector = dragDrop; dragDropConnector.Disconnect(connected); disposable1.Received(1).Dispose(); disposable2.Received(1).Dispose(); }
/// <summary> /// Saves the given data for dragging. /// </summary> /// <typeparam name="TFormat">The data type.</typeparam> /// <param name="key">The key for the data being saved.</param> /// <param name="data">The data being saved for dragging.</param> public void SetData <TFormat>(ConnectedDragDropKey <TFormat> key, TFormat data) { this._data[key] = data; }
/// <summary> /// Checks presence of the data saved for dragging. /// </summary> /// <typeparam name="TFormat">The data type.</typeparam> /// <param name="key">The key for data lookup.</param> /// <returns>true, if the data are present; otherwise false.</returns> public bool GetDataPresent <TFormat>(ConnectedDragDropKey <TFormat> key) { return(this._data.Contains(key)); }
public bool GetDataPresent <TFormat>(ConnectedDragDropKey <TFormat> key) { Contract.Requires <ArgumentNullException>(key != null); return(default(bool)); }
public void SetData <TFormat>(ConnectedDragDropKey <TFormat> key, TFormat data) { Contract.Requires <ArgumentNullException>(key != null); Contract.Requires <InvalidOperationException>(this.IsActive); }