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.relationalExpression.ParameterType = new BooleanParameterType();
            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);
        }
 public void Setup()
 {
     this.exclusiveOrExpression = new ExclusiveOrExpression();
 }
Beispiel #3
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
            };
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ExclusiveOrExpressionDialogViewModel"/> class
 /// </summary>
 /// <param name="andExpression">
 /// The <see cref="ExclusiveOrExpression"/> 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 ExclusiveOrExpressionDialogViewModel(ExclusiveOrExpression andExpression, IThingTransaction transaction, ISession session, bool isRoot, ThingDialogKind dialogKind, IThingDialogNavigationService thingDialogNavigationService, Thing container = null, IEnumerable <Thing> chainOfContainers = null)
     : base(andExpression, transaction, session, isRoot, dialogKind, thingDialogNavigationService, container, chainOfContainers)
 {
     this.WhenAnyValue(vm => vm.Term).Subscribe(_ => this.UpdateOkCanExecute());
 }
Beispiel #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ExclusiveOrExpressionRowViewModel"/> class
 /// </summary>
 /// <param name="notExpression">The <see cref="ExclusiveOrExpression"/> associated with this row</param>
 /// <param name="session">The session</param>
 /// <param name="containerViewModel">The <see cref="IViewModelBase{Thing}"/> that is the container of this <see cref="IRowViewModelBase{Thing}"/></param>
 public ExclusiveOrExpressionRowViewModel(ExclusiveOrExpression notExpression, ISession session, IViewModelBase <Thing> containerViewModel) : base(notExpression, session, containerViewModel)
 {
     this.UpdateProperties();
 }
Beispiel #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ExclusiveOrExpressionRowViewModel"/> class
 /// </summary>
 /// <param name="notExpression">The <see cref="ExclusiveOrExpression"/> associated with this row</param>
 /// <param name="session">The session</param>
 /// <param name="containerViewModel">The <see cref="IViewModelBase{T}"/> that is the container of this <see cref="IRowViewModelBase{Thing}"/></param>
 public ExclusiveOrExpressionRowViewModel(ExclusiveOrExpression notExpression, ISession session, IViewModelBase <Thing> containerViewModel) : base(notExpression, session, containerViewModel)
 {
     this.UpdateProperties();
     this.SetRequirementStateOfComplianceChangedEventSubscription(this.Thing, this.Disposables);
 }
Beispiel #7
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);
        }