/// <summary>
        /// Perform the copy operation of an <see cref="ElementDefinition"/>
        /// </summary>
        /// <param name="elementDefinition">The <see cref="ElementDefinition"/> to copy</param>
        /// <param name="targetIteration">The target container</param>
        /// <param name="keyStates">The <see cref="DragDropKeyStates"/> used in the drag-and-drop operation</param>
        public async Task Copy(ElementDefinition elementDefinition, Iteration targetIteration, DragDropKeyStates keyStates)
        {
            // copy the payload to this iteration
            var ownedIsChanged       = keyStates == Constants.DryCopy || keyStates == Constants.CtrlCopy;
            var copyOperationHelper  = new CopyPermissionHelper(this.session, ownedIsChanged);
            var copyPermissionResult = copyOperationHelper.ComputeCopyPermission(elementDefinition, targetIteration);

            var operationKind = keyStates.GetCopyOperationKind();

            if (copyPermissionResult.ErrorList.Any())
            {
                // show permission information
                var copyConfirmationDialog = new CopyConfirmationDialogViewModel(copyPermissionResult.CopyableThings, copyPermissionResult.ErrorList);

                var dialogResult = this.dialogNavigationService.NavigateModal(copyConfirmationDialog);
                if (dialogResult != null && dialogResult.Result == true)
                {
                    await this.WriteCopyOperation(elementDefinition, targetIteration, operationKind.Value);
                }
            }
            else if (copyPermissionResult.CopyableThings.Any())
            {
                await this.WriteCopyOperation(elementDefinition, targetIteration, operationKind.Value);
            }
        }
        public void VerifyThatIfNoThingsToCopyTheProceedCommandIsDisabled()
        {
            var copyableThings = new List <Thing>();

            var dialog = new CopyConfirmationDialogViewModel(copyableThings, new Dictionary <Thing, string>());

            Assert.IsFalse(dialog.ProceedCommand.CanExecute(null));
            Assert.IsEmpty(dialog.CopyPermissionDetails);
            Assert.AreEqual("The copy operation cannot be performed.", dialog.CopyPermissionMessage);
        }
        public void VerifyThatTheDialogResultIsNegativeWhenTheCancelCommandIsExecuted()
        {
            var copyableThings = new List <Thing> {
                this.elementDefinition
            };

            var dialog = new CopyConfirmationDialogViewModel(copyableThings, new Dictionary <Thing, string>());

            dialog.CancelCommand.Execute(null);

            Assert.IsFalse((bool)dialog.DialogResult.Result);
        }
        public void VerifyThatDialogCanBeConstructed()
        {
            var copyableThings = new List <Thing> {
                this.elementDefinition
            };

            var dialog = new CopyConfirmationDialogViewModel(copyableThings, new Dictionary <Thing, string>());

            Assert.AreEqual("Copy Confirmation", dialog.Title);

            Assert.IsTrue(dialog.ProceedCommand.CanExecute(null));
            Assert.IsTrue(dialog.CancelCommand.CanExecute(null));

            Assert.IsNotEmpty(dialog.CopyPermissionDetails);
            Assert.AreEqual("A partial copy will be performed.", dialog.CopyPermissionMessage);
        }