public void VerityThatPropertiesAreSetByConstructor()
        {
            this.viewModel = new OkDialogViewModel("the title", "the message");

            Assert.AreEqual("the title", viewModel.Title);
            Assert.AreEqual("the message", viewModel.Message);
        }
        public void VerifyThatYesCommandWorksAsExpected()
        {
            this.viewModel = new OkDialogViewModel("", "");
            this.viewModel.OkCommand.CanExecute(null);

            this.viewModel.OkCommand.Execute(null);

            Assert.IsTrue((bool)this.viewModel.DialogResult.Result.Value);
        }
예제 #3
0
        /// <summary>
        /// Add a row representing a <see cref="ElementUsage"/>
        /// </summary>
        /// <param name="elementUsage">The <see cref="ElementUsage"/> to add</param>
        private void AddElementUsage(ElementUsage elementUsage)
        {
            if (!this.elementUsageListenerCache.ContainsKey(elementUsage))
            {
                var listener = CDPMessageBus.Current.Listen <ObjectChangedEvent>(elementUsage)
                               .Where(
                    objectChange =>
                    objectChange.EventKind == EventKind.Updated &&
                    objectChange.ChangedThing.RevisionNumber > this.RevisionNumber)
                               .ObserveOn(RxApp.MainThreadScheduler)
                               .Subscribe(x => this.UpdateOptionDependentElementUsage((ElementUsage)x.ChangedThing));
                this.elementUsageListenerCache.Add(elementUsage, listener);
            }

            // avoid duplicate and filter on Option
            if (this.ContainedRows.Any(x => x.Thing == elementUsage) || elementUsage.ExcludeOption.Contains(this.Option))
            {
                return;
            }

            //checking for cyclic relation between element usages and element definition
            var iteration = this.Thing.Container as Iteration;

            foreach (var element in iteration.Element)
            {
                if (element.Name != null && elementUsage.Name != null)
                {
                    if (element.Name == elementUsage.Name)
                    {
                        if (element.HasUsageOf(this.Thing))
                        {
                            string title   = "Error exists in Model";
                            string message = "A cyclic reference problem is encountered with the following items:" +
                                             "\n" +
                                             this.Thing.ClassKind + ": " + this.Thing.Name + "(" + this.Thing.ShortName +
                                             ")" + "\n" + elementUsage.Container.ClassKind + ": " + elementUsage.Name +
                                             "(" + elementUsage.ShortName + ")" + "\n" +
                                             "All cyclic reference problems have to be solved by a person with the appropriate rights.";

                            var dialogOk     = new OkDialogViewModel(title, message);
                            var dialogResult = this.dialogNavigationService.NavigateModal(dialogOk);

                            logger.Error(message);
                            if (dialogResult.Result.HasValue)
                            {
                                return;
                            }
                        }
                    }
                }
            }

            var row = new ElementUsageRowViewModel(elementUsage, this.Option, this.Session, this);

            this.ContainedRows.SortedInsert(row, ChildRowComparer);
        }