示例#1
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));
        }
示例#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 IsDraggingReturnsFalseForUnkownObject()
        {
            var connected = new object();

            var dragDrop = new ConnectedDragDrop(this._uriDisconnectTable);

            dragDrop.Drag(connected);

            Assert.IsFalse(dragDrop.IsDragging(new object()));
            Assert.IsFalse(dragDrop.IsDragging(new object()));
        }
示例#4
0
        public void IsDraggingReturnsTrueAfterDrag()
        {
            var connected = new object();

            var dragDrop = new ConnectedDragDrop(this._uriDisconnectTable);

            dragDrop.Drag(connected);

            Assert.IsTrue(dragDrop.IsDragging(connected));
            Assert.IsTrue(dragDrop.IsActive);
        }
示例#5
0
        public void RegistersTargetConnectorInUriDisconnectTableOnDrop()
        {
            var connected       = new object();
            var targetConnector = Substitute.For <IUriPlacementConnector>();

            var dragDrop = new ConnectedDragDrop(this._uriDisconnectTable);

            dragDrop.Drag(connected);
            dragDrop.Drop(targetConnector);

            this._uriDisconnectTable.Received(1)[connected] = targetConnector;
        }
示例#6
0
        public void ConnectsToTargetPlacementConnectorOnDrop()
        {
            var connected       = new object();
            var targetConnector = Substitute.For <IUriPlacementConnector>();

            var dragDrop = new ConnectedDragDrop(this._uriDisconnectTable);

            dragDrop.Drag(connected);
            dragDrop.Drop(targetConnector);

            targetConnector.Received(1).Connect(connected);
        }
示例#7
0
        public void DisconnectsFromUriDisconnectTableEntryOnDrag()
        {
            var connected       = new object();
            var sourceConnector = Substitute.For <IUriPlacementConnector>();

            this._uriDisconnectTable[connected].Returns(sourceConnector);

            var dragDrop = new ConnectedDragDrop(this._uriDisconnectTable);

            dragDrop.Drag(connected);

            sourceConnector.Received(1).Disconnect(connected);
        }
示例#8
0
        public void IsDraggingReturnsFalseAfterDrop()
        {
            var connected = new object();
            var connector = Substitute.For <IUriPlacementConnector>();

            var dragDrop = new ConnectedDragDrop(this._uriDisconnectTable);

            dragDrop.Drag(connected);
            dragDrop.Drop(connector);

            Assert.IsFalse(dragDrop.IsDragging(connected));
            Assert.IsFalse(dragDrop.IsActive);
        }
示例#9
0
        public void IsDraggingReturnsTrueBeforeDisconnectFromUriDisconnectTableEntry()
        {
            var connected       = new object();
            var sourceConnector = Substitute.For <IUriPlacementConnector>();

            this._uriDisconnectTable[connected].Returns(sourceConnector);

            var dragDrop = new ConnectedDragDrop(this._uriDisconnectTable);

            sourceConnector
            .When(_ => _.Disconnect(connected))
            .Do(args => Assert.IsTrue(dragDrop.IsDragging(args[0])));

            dragDrop.Drag(connected);
        }
示例#10
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));
        }
示例#11
0
        public void IsDraggingReturnsTrueBeforeConnectToTargetPlacementConnector()
        {
            var connected       = new object();
            var targetConnector = Substitute.For <IUriPlacementConnector>();

            var dragDrop = new ConnectedDragDrop(this._uriDisconnectTable);

            dragDrop.Drag(connected);

            targetConnector
            .When(_ => _.Connect(connected))
            .Do(args => Assert.IsTrue(dragDrop.IsDragging(args[0])));

            dragDrop.Drop(targetConnector);
        }
示例#12
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));
        }
示例#13
0
        public void RegistersInUriDisconnectTableAfterDisconnectFromSourcePlacementConnector()
        {
            var connected       = new object();
            var sourceConnector = Substitute.For <IUriPlacementConnector>();

            this._uriDisconnectTable[connected].Returns(sourceConnector);

            sourceConnector
            .When(_ => _.Disconnect(connected))
            .Do(_ => this._uriDisconnectTable.DidNotReceiveWithAnyArgs()[connected] = null);

            var dragDrop = new ConnectedDragDrop(this._uriDisconnectTable);

            dragDrop.Drag(connected);

            this._uriDisconnectTable.Received(1)[connected] = dragDrop;
        }
示例#14
0
        public void RaisesDraggedClosedOnDisconnect()
        {
            var connected = new object();
            var connector = Substitute.For <IUriPlacementConnector>();

            var dragDrop = new ConnectedDragDrop(this._uriDisconnectTable);

            dragDrop.Drag(connected);

            var wasRaised = false;

            dragDrop.DraggedClosed += (sender, e) => wasRaised = true;

            IUriPlacementConnector dragDropConnector = dragDrop;

            dragDropConnector.Disconnect(connected);

            Assert.IsTrue(wasRaised);
        }
示例#15
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();
        }
示例#16
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();
        }