Esempio n. 1
0
        /// <summary>
        /// Execute the <see cref="CopyElementDefinitionCommand"/>
        /// </summary>
        private async Task ExecuteCopyElementDefinition()
        {
            var elementDef = this.SelectedThing.Thing as ElementDefinition;
            var copyUsage  = true;

            if ((elementDef != null) && elementDef.ContainedElement.Any())
            {
                var yesNoDialogViewModel = new YesNoDialogViewModel("Confirmation", "Would you like to copy the Element Usages?");
                var result = this.DialogNavigationService.NavigateModal(yesNoDialogViewModel);

                copyUsage = result.Result.HasValue && result.Result.Value;
            }

            try
            {
                this.IsBusy = true;
                var copyCreator = new CopyElementDefinitionCreator(this.Session);
                await copyCreator.Copy((ElementDefinition)this.SelectedThing.Thing, copyUsage);
            }
            catch (Exception exception)
            {
                logger.Error(exception, "An error occured when creating a copy of an Element Definition");
            }
            finally
            {
                this.IsBusy = false;
            }
        }
        public void VerifyThatCopyWithoutUsageWorks()
        {
            var copy = new CopyElementDefinitionCreator(this.session.Object);

            copy.Copy(this.elementDef1, false);
            this.session.Verify(x => x.Write(It.Is <OperationContainer>(c => c.Operations.Count(op => op.OperationKind == OperationKind.Create) == 5)));
        }