예제 #1
0
        public TFormat GetData <TFormat>(ConnectedDragDropKey <TFormat> key)
        {
            Contract.Requires <ArgumentNullException>(key != null);
            Contract.Requires <InvalidOperationException>(this.IsActive);

            return(default(TFormat));
        }
예제 #2
0
        public void ThrowsExceptionWhenGettingDataForResolvedNotConnected()
        {
            var key  = new ConnectedDragDropKey <Type>();
            var data = typeof(ConnectedDragDropTests);

            var dragDrop = new ConnectedDragDrop(this._uriDisconnectTable);

            ExceptionAssert.Throws <InvalidOperationException>(() => dragDrop.GetData(key));
        }
예제 #3
0
        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));
        }
예제 #4
0
        /// <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));
        }
예제 #5
0
        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));
        }
예제 #6
0
        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));
        }
예제 #7
0
        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();
        }
예제 #8
0
        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();
        }
예제 #9
0
 /// <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;
 }
예제 #10
0
 /// <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));
 }
예제 #11
0
        public bool GetDataPresent <TFormat>(ConnectedDragDropKey <TFormat> key)
        {
            Contract.Requires <ArgumentNullException>(key != null);

            return(default(bool));
        }
예제 #12
0
 public void SetData <TFormat>(ConnectedDragDropKey <TFormat> key, TFormat data)
 {
     Contract.Requires <ArgumentNullException>(key != null);
     Contract.Requires <InvalidOperationException>(this.IsActive);
 }