Пример #1
0
        public void Setup()
        {
            this.securityContext             = new Mock <ISecurityContext>();
            this.parametricConstraintService = new Mock <IParametricConstraintService>();
            this.relationalExpressionService = new Mock <IRelationalExpressionService>();

            this.npgsqlTransaction = null;

            this.sideEffect = new RelationalExpressionSideEffect
            {
                ParametricConstraintService = this.parametricConstraintService.Object,
                RelationalExpressionService = this.relationalExpressionService.Object
            };

            this.relationalExpression1 = new RelationalExpression(Guid.NewGuid(), 1);
            this.relationalExpression2 = new RelationalExpression(Guid.NewGuid(), 1);

            this.parametricConstraint = new ParametricConstraint(Guid.NewGuid(), 1);
            this.parametricConstraint.Expression.Add(this.relationalExpression1.Iid);
            this.parametricConstraint.Expression.Add(this.relationalExpression2.Iid);

            this.relationalExpressionService.Setup(x => x.GetShallow(It.IsAny <NpgsqlTransaction>(), It.IsAny <string>(), new[] { this.relationalExpression1.Iid }, this.securityContext.Object)).Returns(new[] { this.relationalExpression1 });
            this.relationalExpressionService.Setup(x => x.GetShallow(It.IsAny <NpgsqlTransaction>(), It.IsAny <string>(), new[] { this.relationalExpression2.Iid }, this.securityContext.Object)).Returns(new[] { this.relationalExpression2 });
            this.relationalExpressionService.Setup(x => x.GetShallow(It.IsAny <NpgsqlTransaction>(), It.IsAny <string>(), new[] { this.relationalExpression1.Iid, this.relationalExpression2.Iid }, this.securityContext.Object)).Returns(new[] { this.relationalExpression1, this.relationalExpression2 });

            this.parametricConstraintService.Setup(x => x.GetShallow(It.IsAny <NpgsqlTransaction>(), It.IsAny <string>(), new[] { this.parametricConstraint.Iid }, this.securityContext.Object)).Returns(new[] { this.parametricConstraint });
        }
        public void Setup()
        {
            this.assembler = new Assembler(this.uri);

            RxApp.MainThreadScheduler = Scheduler.CurrentThread;
            this.session           = new Mock <ISession>();
            this.permissionService = new Mock <IPermissionService>();
            this.permissionService.Setup(x => x.CanRead(It.IsAny <Thing>())).Returns(true);
            this.permissionService.Setup(x => x.CanWrite(It.IsAny <Thing>())).Returns(true);
            this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object);
            this.session.Setup(x => x.DataSourceUri).Returns(this.uri.ToString);

            this.domain = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "test"
            };

            this.requirement = new Requirement
            {
                Owner = this.domain
            };

            this.parametricConstraint = new ParametricConstraint {
                Container = this.requirement
            };
            this.parametricConstraintRowViewModel = new ParametricConstraintRowViewModel(this.parametricConstraint, this.session.Object, null);
        }
        public void TestGetOwnerThrowEx()
        {
            var parametricConstraint = new ParametricConstraint();

            Assert.Throws <ContainmentException>(() =>
            {
                Console.WriteLine(parametricConstraint.Owner);
            });
        }
Пример #4
0
        /// <summary>
        /// Removes a row
        /// </summary>
        /// <param name="constraint">The associated <see cref="ParametricConstraint"/> to remove</param>
        private void RemoveConstraint(ParametricConstraint constraint)
        {
            var row = this.parametricConstraints.ContainedRows.SingleOrDefault(x => x.Thing == constraint);

            if (row != null)
            {
                this.parametricConstraints.ContainedRows.Remove(row);
                row.Dispose();
            }
        }
        public void TestGetOwner()
        {
            var thing = new ParametricConstraint();
            var req   = new Requirement();

            req.Owner = new DomainOfExpertise();
            req.ParametricConstraint.Add(thing);

            Assert.IsTrue(ReferenceEquals(req.Owner, thing.Owner));
        }
Пример #6
0
        public void Setup()
        {
            this.session = new Mock <ISession>();
            this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>();
            this.cache = new ConcurrentDictionary <CacheKey, Lazy <Thing> >();
            var dal = new Mock <IDal>();

            dal.Setup(x => x.MetaDataProvider).Returns(new MetaDataProvider());
            this.session.Setup(x => x.DalVersion).Returns(new Version(1, 1, 0));
            this.session.Setup(x => x.Dal).Returns(dal.Object);

            this.siteDir        = new SiteDirectory(Guid.NewGuid(), this.cache, this.uri);
            this.modelsetup     = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri);
            this.iterationsetup = new IterationSetup(Guid.NewGuid(), this.cache, this.uri);
            this.srdl           = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri);
            this.mrdl           = new ModelReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri)
            {
                RequiredRdl = this.srdl
            };
            this.siteDir.Model.Add(this.modelsetup);
            this.modelsetup.IterationSetup.Add(this.iterationsetup);
            this.siteDir.SiteReferenceDataLibrary.Add(this.srdl);
            this.modelsetup.RequiredRdl.Add(this.mrdl);

            this.model = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri)
            {
                EngineeringModelSetup = this.modelsetup
            };
            this.iteration = new Iteration(Guid.NewGuid(), this.cache, this.uri)
            {
                IterationSetup = this.iterationsetup
            };
            this.requirement          = new Requirement(Guid.NewGuid(), this.cache, this.uri);
            this.relationalExpression = new RelationalExpression(Guid.NewGuid(), this.cache, this.uri);
            this.parametricConstraint = new ParametricConstraint(Guid.NewGuid(), this.cache, this.uri);
            this.requirement.ParametricConstraint.Add(this.parametricConstraint);
            this.parametricConstraint.Expression.Add(this.relationalExpression);
            this.reqSpec = new RequirementsSpecification(Guid.NewGuid(), this.cache, this.uri);
            this.reqSpec.Requirement.Add(this.requirement);
            this.grp = new RequirementsGroup(Guid.NewGuid(), this.cache, this.uri);
            this.reqSpec.Group.Add(this.grp);
            this.cache.TryAdd(new CacheKey(this.reqSpec.Iid, null), new Lazy <Thing>(() => this.reqSpec));

            this.model.Iteration.Add(this.iteration);
            this.iteration.RequirementsSpecification.Add(this.reqSpec);

            this.clone = this.parametricConstraint.Clone(false);
            var transactionContext = TransactionContextResolver.ResolveContext(this.iteration);

            this.thingTransaction = new ThingTransaction(transactionContext, this.clone);

            this.dateRelationalExpression = new RelationalExpression(Guid.NewGuid(), this.cache, this.uri);
            this.dateRelationalExpression.ParameterType = new DateParameterType();
            this.dateRelationalExpression.Value         = new ValueArray <string>(new[] { "2019-12-31" });
        }
Пример #7
0
        public void SetUp()
        {
            this.parametricConstraint = new ParametricConstraint(Guid.NewGuid(), null, null);

            this.relationalExpression =
                new RelationalExpressionBuilder()
                .WithSimpleQuantityKindParameterType()
                .WithValue("10")
                .Build();

            this.parametricConstraint.Expression.Add(this.relationalExpression);

            this.requirement1 = new Requirement(Guid.NewGuid(), null, null);

            this.requirement1.ParametricConstraint.Add(this.parametricConstraint);

            this.requirementsSpecification = new RequirementsSpecification(Guid.NewGuid(), null, null);
            this.requirementsSpecification.Requirement.Add(this.requirement1);

            this.requirementsGroup1 = new RequirementsGroup(Guid.NewGuid(), null, null);
            this.requirementsGroup2 = new RequirementsGroup(Guid.NewGuid(), null, null);

            this.requirementsSpecification.Group.Add(this.requirementsGroup1);
            this.requirementsGroup1.Group.Add(this.requirementsGroup2);

            this.requirement1.Group = this.requirementsGroup1;

            this.requirementsContainerVerifier = new RequirementsContainerVerifier(this.requirementsSpecification);

            this.requirementsGroupVerifier1 = new RequirementsContainerVerifier(this.requirementsGroup1);
            this.requirementsGroupVerifier2 = new RequirementsContainerVerifier(this.requirementsGroup2);

            this.iteration = new Iteration(Guid.NewGuid(), null, null);

            this.elementDefinition = new ElementDefinition(Guid.NewGuid(), null, null);
            var elementUsage = new ElementUsage(Guid.NewGuid(), null, null)
            {
                ElementDefinition = this.elementDefinition
            };

            this.elementDefinition.ContainedElement.Add(elementUsage);

            var parameter =
                new ParameterBuilder()
                .WithSimpleQuantityKindParameterType()
                .WithValue("10")
                .AddToElementDefinition(this.elementDefinition)
                .Build();

            this.iteration.Element.Add(this.elementDefinition);

            this.RegisterBinaryRelationShip(parameter, this.relationalExpression);
        }
Пример #8
0
        /// <summary>
        /// Serialize the <see cref="ParametricConstraint"/>
        /// </summary>
        /// <param name="parametricConstraint">The <see cref="ParametricConstraint"/> to serialize</param>
        /// <returns>The <see cref="JObject"/></returns>
        private JObject Serialize(ParametricConstraint parametricConstraint)
        {
            var jsonObject = new JObject();

            jsonObject.Add("classKind", this.PropertySerializerMap["classKind"](Enum.GetName(typeof(CDP4Common.CommonData.ClassKind), parametricConstraint.ClassKind)));
            jsonObject.Add("excludedDomain", this.PropertySerializerMap["excludedDomain"](parametricConstraint.ExcludedDomain.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("excludedPerson", this.PropertySerializerMap["excludedPerson"](parametricConstraint.ExcludedPerson.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("expression", this.PropertySerializerMap["expression"](parametricConstraint.Expression.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("iid", this.PropertySerializerMap["iid"](parametricConstraint.Iid));
            jsonObject.Add("modifiedOn", this.PropertySerializerMap["modifiedOn"](parametricConstraint.ModifiedOn));
            jsonObject.Add("revisionNumber", this.PropertySerializerMap["revisionNumber"](parametricConstraint.RevisionNumber));
            jsonObject.Add("thingPreference", this.PropertySerializerMap["thingPreference"](parametricConstraint.ThingPreference));
            jsonObject.Add("topExpression", this.PropertySerializerMap["topExpression"](parametricConstraint.TopExpression));
            return(jsonObject);
        }
Пример #9
0
        public void SetUp()
        {
            this.andExpression         = new AndExpression();
            this.orExpression          = new OrExpression();
            this.exclusiveOrExpression = new ExclusiveOrExpression();
            this.notExpression         = new NotExpression();
            this.relationalExpression1 = new RelationalExpression();
            this.relationalExpression2 = new RelationalExpression();
            this.relationalExpression3 = new RelationalExpression();
            this.relationalExpression4 = new RelationalExpression();

            this.parametricConstraint = new ParametricConstraint();

            this.parametricConstraint.Expression.AddRange(new List <BooleanExpression>
            {
                this.andExpression,
                this.orExpression,
                this.exclusiveOrExpression,
                this.notExpression,
                this.relationalExpression1,
                this.relationalExpression2,
                this.relationalExpression3,
                this.relationalExpression4
            });

            foreach (var expression in this.parametricConstraint.Expression)
            {
                expression.Container = this.parametricConstraint;
            }

            this.testCaseList = new Dictionary <ExpressionNumber, BooleanExpression>
            {
                { ExpressionNumber.And, this.andExpression },
                { ExpressionNumber.Or, this.orExpression },
                { ExpressionNumber.ExclusiveOr, this.exclusiveOrExpression },
                { ExpressionNumber.Not, this.notExpression },
                { ExpressionNumber.Relational1, this.relationalExpression1 },
                { ExpressionNumber.Relational2, this.relationalExpression2 },
                { ExpressionNumber.Relational3, this.relationalExpression3 },
                { ExpressionNumber.Relational4, this.relationalExpression4 }
            };
        }
        public void SetUp()
        {
            this.relationalExpressionRuleChecker = new RelationalExpressionRuleChecker();

            this.modelReferenceDataLibrary = new ModelReferenceDataLibrary();
            this.engineeringModelSetup     = new EngineeringModelSetup();
            this.engineeringModel          = new EngineeringModel();
            this.iteration = new Iteration();
            this.requirementsSpecification = new RequirementsSpecification();
            this.requirement          = new Requirement();
            this.parametricConstraint = new ParametricConstraint();
            this.relationalExpression = new RelationalExpression()
            {
                Iid = Guid.Parse("56d52d2f-fe41-4e35-8723-4fa310c254f3")
            };

            this.engineeringModelSetup.RequiredRdl.Add(this.modelReferenceDataLibrary);
            this.engineeringModel.EngineeringModelSetup = this.engineeringModelSetup;
            this.engineeringModel.Iteration.Add(this.iteration);
            this.iteration.RequirementsSpecification.Add(this.requirementsSpecification);
            this.requirementsSpecification.Requirement.Add(this.requirement);
            this.requirement.ParametricConstraint.Add(this.parametricConstraint);
            this.parametricConstraint.Expression.Add(this.relationalExpression);
        }
Пример #11
0
        public void Setup()
        {
            this.session                      = new Mock <ISession>();
            this.permissionService            = new Mock <IPermissionService>();
            this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>();
            this.cache = new ConcurrentDictionary <CacheKey, Lazy <Thing> >();

            var dal = new Mock <IDal>();

            dal.Setup(x => x.MetaDataProvider).Returns(new MetaDataProvider());
            this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object);
            this.session.Setup(x => x.DalVersion).Returns(new Version(1, 1, 0));
            this.session.Setup(x => x.Dal).Returns(dal.Object);
            this.thingDialogNavigationService.Setup(
                x =>
                x.Navigate(
                    It.IsAny <Thing>(),
                    It.IsAny <IThingTransaction>(),
                    this.session.Object,
                    false,
                    ThingDialogKind.Create,
                    this.thingDialogNavigationService.Object,
                    It.IsAny <Thing>(),
                    It.IsAny <IEnumerable <Thing> >())).Returns(true);

            this.siteDir        = new SiteDirectory(Guid.NewGuid(), this.cache, this.uri);
            this.modelsetup     = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri);
            this.iterationsetup = new IterationSetup(Guid.NewGuid(), this.cache, this.uri);
            this.srdl           = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri);
            this.mrdl           = new ModelReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri)
            {
                RequiredRdl = this.srdl
            };
            this.siteDir.Model.Add(this.modelsetup);
            this.modelsetup.IterationSetup.Add(this.iterationsetup);
            this.siteDir.SiteReferenceDataLibrary.Add(this.srdl);
            this.modelsetup.RequiredRdl.Add(this.mrdl);

            this.model = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri)
            {
                EngineeringModelSetup =
                    this.modelsetup
            };
            this.iteration = new Iteration(Guid.NewGuid(), this.cache, this.uri)
            {
                IterationSetup = this.iterationsetup
            };
            this.requirement           = new Requirement(Guid.NewGuid(), this.cache, this.uri);
            this.relationalExpression  = new RelationalExpression(Guid.NewGuid(), this.cache, this.uri);
            this.andExpression         = new AndExpression(Guid.NewGuid(), this.cache, this.uri);
            this.orExpression          = new OrExpression(Guid.NewGuid(), this.cache, this.uri);
            this.exclusiveOrExpression = new ExclusiveOrExpression(Guid.NewGuid(), this.cache, this.uri);
            this.notExpression         = new NotExpression(Guid.NewGuid(), this.cache, this.uri);
            this.parametricConstraint  = new ParametricConstraint(Guid.NewGuid(), this.cache, this.uri);
            this.requirement.ParametricConstraint.Add(this.parametricConstraint);
            this.parametricConstraint.Expression.Add(this.relationalExpression);
            this.reqSpec = new RequirementsSpecification(Guid.NewGuid(), this.cache, this.uri);
            this.reqSpec.Requirement.Add(this.requirement);
            this.grp = new RequirementsGroup(Guid.NewGuid(), this.cache, this.uri);
            this.reqSpec.Group.Add(this.grp);
            this.cache.TryAdd(new CacheKey(this.reqSpec.Iid, null), new Lazy <Thing>(() => this.reqSpec));

            this.model.Iteration.Add(this.iteration);
            this.iteration.RequirementsSpecification.Add(this.reqSpec);

            this.clone = this.requirement.Clone(false);

            var transactionContext = TransactionContextResolver.ResolveContext(this.iteration);

            this.thingTransaction = new ThingTransaction(transactionContext, this.clone);
        }
Пример #12
0
        public void Setup()
        {
            RxApp.MainThreadScheduler = Scheduler.CurrentThread;
            this.session       = new Mock <ISession>();
            this.viewModelBase = new FakeViewModelBase(this.session.Object);

            this.andExpression = new AndExpression();
            this.SetClassKind(this.andExpression, ClassKind.AndExpression);

            this.andExpressionViewModel = new Mock <IRowViewModelBase <AndExpression> >();
            this.andExpressionViewModel.SetupGet(x => x.Thing).Returns(this.andExpression);

            this.andRelationalExpression1          = new RelationalExpression();
            this.andRelationalExpression1ViewModel = new Mock <IRowViewModelBase <RelationalExpression> >();
            this.andRelationalExpression1ViewModel.SetupGet(x => x.ContainedRows).Returns(new DisposableReactiveList <IRowViewModelBase <Thing> >());
            this.andRelationalExpression1ViewModel.SetupGet(x => x.Thing).Returns(this.andRelationalExpression1);
            this.andRelationalExpression1ViewModel.SetupGet(x => x.ContainerViewModel).Returns(this.andExpressionViewModel.Object);

            this.andRelationalExpression2          = new RelationalExpression();
            this.andRelationalExpression2ViewModel = new Mock <IRowViewModelBase <RelationalExpression> >();
            this.andRelationalExpression2ViewModel.SetupGet(x => x.ContainedRows).Returns(new DisposableReactiveList <IRowViewModelBase <Thing> >());
            this.andRelationalExpression2ViewModel.SetupGet(x => x.Thing).Returns(this.andRelationalExpression2);
            this.andRelationalExpression2ViewModel.SetupGet(x => x.ContainerViewModel).Returns(this.andExpressionViewModel.Object);

            this.andExpressionViewModel.SetupGet(x => x.ContainedRows).Returns(
                new DisposableReactiveList <IRowViewModelBase <Thing> >
            {
                this.andRelationalExpression1ViewModel.Object,
                this.andRelationalExpression2ViewModel.Object
            });

            this.orExpression = new OrExpression();
            this.SetClassKind(this.orExpression, ClassKind.OrExpression);
            this.orExpressionViewModel = new Mock <IRowViewModelBase <OrExpression> >();
            this.orExpressionViewModel.SetupGet(x => x.Thing).Returns(this.orExpression);

            this.orRelationalExpression1          = new RelationalExpression();
            this.orRelationalExpression1ViewModel = new Mock <IRowViewModelBase <RelationalExpression> >();
            this.orRelationalExpression1ViewModel.SetupGet(x => x.ContainedRows).Returns(new DisposableReactiveList <IRowViewModelBase <Thing> >());
            this.orRelationalExpression1ViewModel.SetupGet(x => x.Thing).Returns(this.orRelationalExpression1);
            this.orRelationalExpression1ViewModel.SetupGet(x => x.ContainerViewModel).Returns(this.orExpressionViewModel.Object);

            this.orRelationalExpression2          = new RelationalExpression();
            this.orRelationalExpression2ViewModel = new Mock <IRowViewModelBase <RelationalExpression> >();
            this.orRelationalExpression2ViewModel.SetupGet(x => x.ContainedRows).Returns(new DisposableReactiveList <IRowViewModelBase <Thing> >());
            this.orRelationalExpression2ViewModel.SetupGet(x => x.Thing).Returns(this.orRelationalExpression2);
            this.orRelationalExpression2ViewModel.SetupGet(x => x.ContainerViewModel).Returns(this.orExpressionViewModel.Object);

            this.orExpressionViewModel.SetupGet(x => x.ContainedRows).Returns(
                new DisposableReactiveList <IRowViewModelBase <Thing> >
            {
                this.orRelationalExpression1ViewModel.Object,
                this.orRelationalExpression2ViewModel.Object
            });

            this.exclusiveOrExpression = new ExclusiveOrExpression();
            this.SetClassKind(this.exclusiveOrExpression, ClassKind.ExclusiveOrExpression);
            this.exclusiveOrExpressionViewModel = new Mock <IRowViewModelBase <ExclusiveOrExpression> >();
            this.exclusiveOrExpressionViewModel.SetupGet(x => x.Thing).Returns(this.exclusiveOrExpression);

            this.exclusiveOrExpressionViewModel.SetupGet(x => x.ContainedRows).Returns(
                new DisposableReactiveList <IRowViewModelBase <Thing> >
            {
                this.orExpressionViewModel.Object,
                this.andExpressionViewModel.Object,
            });

            this.notExpression = new NotExpression();
            this.SetClassKind(this.notExpression, ClassKind.NotExpression);
            this.notExpressionViewModel = new Mock <IRowViewModelBase <NotExpression> >();
            this.notExpressionViewModel.SetupGet(x => x.Thing).Returns(this.notExpression);

            this.notExpressionViewModel.SetupGet(x => x.ContainedRows).Returns(
                new DisposableReactiveList <IRowViewModelBase <Thing> >
            {
                this.exclusiveOrExpressionViewModel.Object
            });

            this.freeRelationalExpression          = new RelationalExpression();
            this.freeRelationalExpressionViewModel = new Mock <IRowViewModelBase <RelationalExpression> >();
            this.freeRelationalExpressionViewModel.SetupGet(x => x.Thing).Returns(this.freeRelationalExpression);
            this.freeRelationalExpressionViewModel.SetupGet(x => x.ContainedRows).Returns(new DisposableReactiveList <IRowViewModelBase <Thing> >());

            this.FillRelationalExpression(this.andRelationalExpression1, "length", 180);
            this.FillRelationalExpression(this.andRelationalExpression2, "width", 40);
            this.FillRelationalExpression(this.orRelationalExpression1, "mass", 100);
            this.FillRelationalExpression(this.orRelationalExpression2, "accel", "pretty_fast");
            this.FillRelationalExpression(this.freeRelationalExpression, "comment", "lx_is_awesome");

            this.exclusiveOrExpressionViewModel.SetupGet(x => x.ContainerViewModel).Returns(this.notExpressionViewModel.Object);
            this.orExpressionViewModel.SetupGet(x => x.ContainerViewModel).Returns(this.exclusiveOrExpressionViewModel.Object);
            this.andExpressionViewModel.SetupGet(x => x.ContainerViewModel).Returns(this.exclusiveOrExpressionViewModel.Object);

            this.parametricConstraint = new ParametricConstraint();
            this.SetClassKind(this.notExpression, ClassKind.ParametricConstraint);

            this.parametricConstraintViewModel = new Mock <IRowViewModelBase <ParametricConstraint> >();
            this.parametricConstraintViewModel.SetupGet(x => x.Thing).Returns(this.parametricConstraint);

            this.parametricConstraintViewModel.SetupGet(x => x.ContainedRows).Returns(
                new DisposableReactiveList <IRowViewModelBase <Thing> >
            {
                this.notExpressionViewModel.Object,
                this.freeRelationalExpressionViewModel.Object
            });
        }
Пример #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ParametricConstraintRowViewModel"/> class
 /// </summary>
 /// <param name="req">The requirement</param>
 /// <param name="session">The Session</param>
 /// <param name="containerViewModel">The container <see cref="IViewModelBase{T}"/></param>
 public ParametricConstraintRowViewModel(ParametricConstraint req, ISession session, IViewModelBase <Thing> containerViewModel)
     : base(req, session, containerViewModel)
 {
     this.UpdateProperties();
 }
        /// <summary>
        /// Persist the <see cref="ParametricConstraint"/> containment tree to the ORM layer. Update if it already exists.
        /// This is typically used during the import of existing data to the Database.
        /// </summary>
        /// <param name="transaction">
        /// The current <see cref="NpgsqlTransaction"/> to the database.
        /// </param>
        /// <param name="partition">
        /// The database partition (schema) where the requested resource will be stored.
        /// </param>
        /// <param name="parametricConstraint">
        /// The <see cref="ParametricConstraint"/> instance to persist.
        /// </param>
        /// <returns>
        /// True if the persistence was successful.
        /// </returns>
        private bool UpsertContainment(NpgsqlTransaction transaction, string partition, ParametricConstraint parametricConstraint)
        {
            var results = new List <bool>();

            foreach (var expression in this.ResolveFromRequestCache(parametricConstraint.Expression))
            {
                results.Add(this.ExpressionService.UpsertConcept(transaction, partition, expression, parametricConstraint));
            }

            return(results.All(x => x));
        }
Пример #15
0
        public void SetUp()
        {
            this.parametricConstraint  = new ParametricConstraint(Guid.NewGuid(), null, null);
            this.orExpression          = new OrExpression(Guid.NewGuid(), null, null);
            this.andExpression         = new AndExpression(Guid.NewGuid(), null, null);
            this.exclusiveOrExpression = new ExclusiveOrExpression(Guid.NewGuid(), null, null);
            this.notExpression         = new NotExpression(Guid.NewGuid(), null, null);

            this.relationalExpression1 =
                new RelationalExpressionBuilder()
                .WithSimpleQuantityKindParameterType()
                .WithValue(OkValue)
                .Build();

            this.relationalExpression2 =
                new RelationalExpressionBuilder()
                .WithSimpleQuantityKindParameterType()
                .WithValue(OkValue)
                .Build();

            this.relationalExpression3 =
                new RelationalExpressionBuilder()
                .WithSimpleQuantityKindParameterType()
                .WithValue(OkValue)
                .Build();

            this.relationalExpression4 =
                new RelationalExpressionBuilder()
                .WithSimpleQuantityKindParameterType()
                .WithValue(OkValue)
                .Build();

            this.orExpression.Term.Add(this.relationalExpression1);
            this.orExpression.Term.Add(this.relationalExpression2);
            this.andExpression.Term.Add(this.relationalExpression3);
            this.andExpression.Term.Add(this.relationalExpression4);
            this.exclusiveOrExpression.Term.Add(this.relationalExpression3);
            this.exclusiveOrExpression.Term.Add(this.relationalExpression4);

            this.parametricConstraint.Expression.Add(this.andExpression);
            this.parametricConstraint.Expression.Add(this.orExpression);
            this.parametricConstraint.Expression.Add(this.exclusiveOrExpression);
            this.parametricConstraint.Expression.Add(this.notExpression);
            this.parametricConstraint.Expression.Add(this.relationalExpression1);
            this.parametricConstraint.Expression.Add(this.relationalExpression2);
            this.parametricConstraint.Expression.Add(this.relationalExpression3);
            this.parametricConstraint.Expression.Add(this.relationalExpression4);

            this.parametricConstraintVerifier = new ParametricConstraintVerifier(this.parametricConstraint);

            this.iteration = new Iteration(Guid.NewGuid(), null, null);

            this.option1 = new Option();
            this.option2 = new Option();
            this.iteration.Option.Add(this.option1);
            this.iteration.Option.Add(this.option2);

            this.elementDefinition = new ElementDefinition(Guid.NewGuid(), null, null);
            var elementUsage = new ElementUsage(Guid.NewGuid(), null, null)
            {
                ElementDefinition = this.elementDefinition
            };

            this.elementDefinition.ContainedElement.Add(elementUsage);

            this.parameter =
                new ParameterBuilder()
                .WithOption(this.option1)
                .WithSimpleQuantityKindParameterType()
                .WithValue(OkValue)
                .AddToElementDefinition(this.elementDefinition)
                .Build();

            this.iteration.Element.Add(this.elementDefinition);

            var parameterOverride = new ParameterOverride(Guid.NewGuid(), null, null)
            {
                Parameter = this.parameter
            };

            this.parameterOverrideValueSet = new ParameterOverrideValueSet {
                ValueSwitch = ParameterSwitchKind.MANUAL, Manual = new ValueArray <string>(new[] { OkValue })
            };
            parameterOverride.ValueSet.Add(this.parameterOverrideValueSet);
            elementUsage.ParameterOverride.Add(parameterOverride);

            this.RegisterBinaryRelationShip(this.parameter, this.relationalExpression1);
            this.RegisterBinaryRelationShip(parameterOverride, this.relationalExpression2);
        }
Пример #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ParametricConstraintRowViewModel"/> class
 /// </summary>
 /// <param name="req">The requirement</param>
 /// <param name="session">The Session</param>
 /// <param name="containerViewModel">The container <see cref="IViewModelBase{T}"/></param>
 public ParametricConstraintRowViewModel(ParametricConstraint req, ISession session, IViewModelBase <Thing> containerViewModel)
     : base(req, session, containerViewModel)
 {
     this.UpdateProperties();
     this.SetRequirementStateOfComplianceChangedEventSubscription(this.Thing, this.Disposables);
 }
Пример #17
0
        public void Setup()
        {
            this.npgsqlTransaction = null;
            this.securityContext   = new Mock <ISecurityContext>();

            ////                    AndA
            ////                   /    \
            ////                 NotA    OrA
            ////                 /       /  \
            ////              RelA    NotB  ExclusiveOrA
            ////             /          /      \
            ////           RelB       NotC      NotD
            ////                      /           \
            ////                    RelC          RelD will be updated with itself, NotE outside constraint, AndA, RelE
            this.relA = new RelationalExpression {
                Iid = Guid.NewGuid()
            };
            this.relB = new RelationalExpression {
                Iid = Guid.NewGuid()
            };
            this.relC = new RelationalExpression {
                Iid = Guid.NewGuid()
            };
            this.relD = new RelationalExpression {
                Iid = Guid.NewGuid()
            };
            this.relE = new RelationalExpression {
                Iid = Guid.NewGuid()
            };

            this.notA = new NotExpression {
                Iid = Guid.NewGuid(), Term = this.relA.Iid
            };
            this.notB = new NotExpression {
                Iid = Guid.NewGuid(), Term = this.relB.Iid
            };
            this.notC = new NotExpression {
                Iid = Guid.NewGuid(), Term = this.relC.Iid
            };
            this.notD = new NotExpression {
                Iid = Guid.NewGuid(), Term = this.relD.Iid
            };
            this.notE = new NotExpression {
                Iid = Guid.NewGuid()
            };                                                      // ouside constraint

            this.exclusiveOrA =
                new ExclusiveOrExpression
            {
                Iid  = Guid.NewGuid(),
                Term = new List <Guid> {
                    this.notC.Iid, this.notD.Iid
                }
            };

            this.orA = new OrExpression
            {
                Iid  = Guid.NewGuid(),
                Term = new List <Guid> {
                    this.notB.Iid, this.exclusiveOrA.Iid
                }
            };

            this.andA = new AndExpression
            {
                Iid  = Guid.NewGuid(),
                Term = new List <Guid> {
                    this.notA.Iid, this.orA.Iid
                }
            };

            this.constraintA = new ParametricConstraint
            {
                Iid        = Guid.NewGuid(),
                Expression =
                    new List <Guid>
                {
                    this.relA.Iid,
                    this.relB.Iid,
                    this.relC.Iid,
                    this.relD.Iid,
                    this.relE.Iid,
                    this.notA.Iid,
                    this.notB.Iid,
                    this.notC.Iid,
                    this.notD.Iid,
                    this.exclusiveOrA.Iid,
                    this.orA.Iid,
                    this.andA.Iid
                }
            };

            this.parametricConstraintService = new Mock <IParametricConstraintService>();
            this.parametricConstraintService
            .Setup(
                x => x.GetDeep(
                    this.npgsqlTransaction,
                    It.IsAny <string>(),
                    new List <Guid> {
                this.constraintA.Iid
            },
                    It.IsAny <ISecurityContext>())).Returns(
                new List <Thing>
            {
                this.relA,
                this.relB,
                this.relC,
                this.relD,
                this.relE,
                this.notA,
                this.notB,
                this.notC,
                this.notD,
                this.exclusiveOrA,
                this.orA,
                this.andA
            });

            this.sideEffect =
                new NotExpressionSideEffect {
                ParametricConstraintService = this.parametricConstraintService.Object
            };
        }
Пример #18
0
        /// <summary>
        /// Add a row representing a new <see cref="ParametricConstraint"/>
        /// </summary>
        /// <param name="constraint">The associated <see cref="ParametricConstraint"/></param>
        private void AddConstraint(ParametricConstraint constraint)
        {
            var row = new ParametricConstraintRowViewModel(constraint, this.Session, this);

            this.parametricConstraints.ContainedRows.Add(row);
        }
        public void Setup()
        {
            this.session                      = new Mock <ISession>();
            this.permissionService            = new Mock <IPermissionService>();
            this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>();
            this.cache = new ConcurrentDictionary <CacheKey, Lazy <Thing> >();

            this.siteDir = new SiteDirectory(Guid.NewGuid(), this.cache, this.uri);
            this.domain  = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri);
            this.siteDir.Domain.Add(this.domain);

            this.modelsetup = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri);
            this.modelsetup.ActiveDomain.Add(this.domain);
            this.iterationsetup = new IterationSetup(Guid.NewGuid(), this.cache, this.uri);
            this.srdl           = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri);
            this.mrdl           = new ModelReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri)
            {
                RequiredRdl = this.srdl
            };
            this.siteDir.Model.Add(this.modelsetup);
            this.modelsetup.IterationSetup.Add(this.iterationsetup);
            this.siteDir.SiteReferenceDataLibrary.Add(this.srdl);
            this.modelsetup.RequiredRdl.Add(this.mrdl);

            this.model = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri)
            {
                EngineeringModelSetup = this.modelsetup
            };
            this.iteration = new Iteration(Guid.NewGuid(), this.cache, this.uri)
            {
                IterationSetup = this.iterationsetup
            };
            this.requirement = new Requirement(Guid.NewGuid(), this.cache, this.uri);
            var paramValue = new SimpleParameterValue(Guid.NewGuid(), this.cache, this.uri)
            {
                Scale = new CyclicRatioScale {
                    Name = "s", ShortName = "s"
                },
                ParameterType = new BooleanParameterType {
                    Name = "a", ShortName = "a"
                }
            };

            paramValue.Value         = new ValueArray <string>();
            paramValue.ParameterType = new DateParameterType(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "testParameterType", ShortName = "tpt"
            };
            this.requirement.ParameterValue.Add(paramValue);
            var textParameterType    = new TextParameterType(Guid.NewGuid(), this.cache, this.uri);
            var parametricConstraint = new ParametricConstraint(Guid.NewGuid(), this.cache, this.uri);
            var relationalExpression = new RelationalExpression(Guid.NewGuid(), this.cache, this.uri)
            {
                ParameterType = textParameterType, RelationalOperator = RelationalOperatorKind.EQ, Value = new ValueArray <string>()
            };

            parametricConstraint.Expression.Add(relationalExpression);
            parametricConstraint.TopExpression = relationalExpression;
            this.requirement.ParametricConstraint.Add(parametricConstraint);
            this.reqSpec = new RequirementsSpecification(Guid.NewGuid(), this.cache, this.uri);
            this.reqSpec.Requirement.Add(this.requirement);
            this.grp = new RequirementsGroup(Guid.NewGuid(), this.cache, this.uri);
            this.reqSpec.Group.Add(this.grp);
            this.cache.TryAdd(new CacheKey(this.reqSpec.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.reqSpec));

            this.model.Iteration.Add(this.iteration);
            this.iteration.RequirementsSpecification.Add(this.reqSpec);

            this.cat1 = new Category(Guid.NewGuid(), this.cache, this.uri);
            this.cat1.PermissibleClass.Add(ClassKind.Requirement);
            this.srdl.DefinedCategory.Add(this.cat1);

            this.cat2 = new Category(Guid.NewGuid(), this.cache, this.uri);
            this.srdl.DefinedCategory.Add(this.cat2);

            var person = new Person(Guid.NewGuid(), null, this.uri);

            this.domainOfExpertise = new DomainOfExpertise(Guid.NewGuid(), null, this.uri)
            {
                Name = "test"
            };
            person.DefaultDomain = this.domainOfExpertise;

            this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.siteDir);
            this.session.Setup(x => x.ActivePerson).Returns(person);
            this.siteDir.Domain.Add(this.domainOfExpertise);

            this.modelsetup.ActiveDomain.Add(this.domainOfExpertise);

            this.clone = this.reqSpec.Clone(false);

            var transactionContext = TransactionContextResolver.ResolveContext(this.iteration);

            this.thingTransaction = new ThingTransaction(transactionContext, this.clone);

            this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object);

            var dal = new Mock <IDal>();

            this.session.Setup(x => x.DalVersion).Returns(new Version(1, 1, 0));
            this.session.Setup(x => x.Dal).Returns(dal.Object);
            dal.Setup(x => x.MetaDataProvider).Returns(new MetaDataProvider());

            var openIterations = new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> >();
            var participant    = new Participant(Guid.NewGuid(), this.cache, this.uri)
            {
                Person = person,
                Domain = new List <DomainOfExpertise>()
                {
                    this.domain
                },
                SelectedDomain = this.domain
            };

            openIterations.Add(this.iteration, new Tuple <DomainOfExpertise, Participant>(this.domain, participant));
            this.session.Setup(x => x.OpenIterations).Returns(openIterations);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ParametricConstraintDialogViewModel"/> class
 /// </summary>
 /// <param name="simpleParameterValue">
 /// The <see cref="ParametricConstraint"/> that is the subject of the current view-model. This is the object
 /// that will be either created, or edited.
 /// </param>
 /// <param name="transaction">
 /// The <see cref="ThingTransaction"/> that contains the log of recorded changes.
 /// </param>
 /// <param name="session">
 /// The <see cref="ISession"/> in which the current <see cref="Thing"/> is to be added or updated
 /// </param>
 /// <param name="isRoot">
 /// Assert if this <see cref="IThingDialogViewModel"/> is the root of all <see cref="IThingDialogViewModel"/>
 /// </param>
 /// <param name="dialogKind">
 /// The kind of operation this <see cref="IThingDialogViewModel"/> performs
 /// </param>
 /// <param name="thingDialogNavigationService">
 /// The <see cref="IThingDialogNavigationService"/> that is used to navigate to a dialog of a specific <see cref="Thing"/>.
 /// </param>
 /// <param name="container">
 /// The <see cref="Thing"/> that contains the created <see cref="Thing"/> in this Dialog
 /// </param>
 /// <param name="chainOfContainers">
 /// The optional chain of containers that contains the <paramref name="container"/> argument
 /// </param>
 public ParametricConstraintDialogViewModel(ParametricConstraint simpleParameterValue, IThingTransaction transaction, ISession session, bool isRoot, ThingDialogKind dialogKind, IThingDialogNavigationService thingDialogNavigationService, Thing container = null, IEnumerable <Thing> chainOfContainers = null)
     : base(simpleParameterValue, transaction, session, isRoot, dialogKind, thingDialogNavigationService, container, chainOfContainers)
 {
     this.PopulateCreateContextMenu();
     this.WhenAnyValue(vm => vm.SelectedTopExpression).Subscribe(_ => this.UpdateOkCanExecute());
 }
Пример #21
0
 /// <summary>
 /// Add an Parametric Constraint row view model to the list of <see cref="ParametricConstraint"/>
 /// </summary>
 /// <param name="parametricConstraint">
 /// The <see cref="ParametricConstraint"/> that is to be added
 /// </param>
 private ParametricConstraintRowViewModel AddParametricConstraintRowViewModel(ParametricConstraint parametricConstraint)
 {
     return(new ParametricConstraintRowViewModel(parametricConstraint, this.Session, this));
 }