예제 #1
0
        /// <summary>
        /// Query the <see cref="SimpleParameterValue"/> if it exists or create a new one
        /// </summary>
        /// <param name="req">The <see cref="Requirement"/> container</param>
        /// <param name="simpleParameterValue">The queried <see cref="SimpleParameterValue"/></param>
        /// <returns>A value indicating if the <see cref="SimpleParameterValue"/> existed</returns>
        private bool TryQueryOrderParameterOrCreate(Requirement req, out SimpleParameterValue simpleParameterValue)
        {
            var parameterValue = this.QueryOrderParameter(req);

            if (parameterValue != null)
            {
                simpleParameterValue = parameterValue;
                return(true);
            }

            var iteration = req.GetContainerOfType <Iteration>();
            Tuple <DomainOfExpertise, Participant> domainTuple;

            if (!this.session.OpenIterations.TryGetValue(iteration, out domainTuple) || domainTuple.Item1 == null)
            {
                throw new InvalidOperationException("The domain is null.");
            }

            simpleParameterValue = new SimpleParameterValue(Guid.NewGuid(), null, null)
            {
                ParameterType = this.reqOrderParameterType,
                Value         = new ValueArray <string>(new [] { int.MaxValue.ToString() }),
            };

            return(false);
        }
예제 #2
0
        public void VerifyThatPopulateValuesForCompoundParameterTypesWorks()
        {
            this.parameterValue = new SimpleParameterValue(Guid.NewGuid(), this.cache, this.uri)
            {
                ParameterType = null
            };
            this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.siteDir);
            this.session.Setup(x => x.ActivePerson).Returns(new Person(Guid.NewGuid(), null, this.uri));

            var valueClone = this.parameterValue.Clone(false);

            this.requirementClone.ParameterValue.Add(valueClone);

            var vm = new SimpleParameterValueDialogViewModel(valueClone, this.thingTransaction, this.session.Object, true, ThingDialogKind.Update, this.thingDialogNavigationService.Object, this.requirementClone);
            var selectedParameter = new CompoundParameterType();

            var parameterTypeComponent  = new ParameterTypeComponent();
            var selectedSimpleParameter = new SimpleQuantityKind();

            parameterTypeComponent.ParameterType = selectedSimpleParameter;
            selectedParameter.Component.Add(parameterTypeComponent);
            vm.SelectedParameterType = selectedParameter;
            Assert.AreEqual(vm.Values.Count, 1);
            Assert.AreSame(vm.Values.First().ParameterType, selectedParameter);
        }
예제 #3
0
        public void Setup()
        {
            this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>();
            this.permissionService            = new Mock <IPermissionService>();
            this.session = new Mock <ISession>();

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

            this.simpleParameterValue = new SimpleParameterValue(Guid.NewGuid(), null, null)
            {
                Scale = new CyclicRatioScale {
                    Name = "a", ShortName = "e"
                },
                ParameterType = new BooleanParameterType {
                    Name = "a", ShortName = "a"
                }
            };

            this.testParameterType = new DateParameterType(Guid.NewGuid(), null, null)
            {
                Name = "testPT", ShortName = "tpt"
            };
            this.simpleParameterValue.ParameterType = this.testParameterType;
            var values = new List <string> {
                "1", "2"
            };

            this.simpleParameterValue.Value = new ValueArray <string>(values);

            this.requirement.ParameterValue.Add(this.simpleParameterValue);

            this.permissionService.Setup(x => x.CanWrite(ClassKind.Term, It.IsAny <Thing>())).Returns(true);
            this.session.Setup(x => x.DataSourceUri).Returns(this.uri.ToString);
        }
예제 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SimpleParameterValueDialogViewModel"/> class
 /// </summary>
 /// <param name="simpleParameterValue">
 /// The <see cref="SimpleParameterValue"/> 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 SimpleParameterValueDialogViewModel(SimpleParameterValue 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.WhenAnyValue(vm => vm.SelectedScale).Subscribe(_ => this.UpdateOkCanExecute());
     this.WhenAnyValue(vm => vm.SelectedParameterType).Subscribe(_ => this.PopulateValues());
     this.Values.CountChanged.Subscribe(_ => this.UpdateOkCanExecute());
 }
예제 #5
0
        public void TestGetOwnerThrowEx()
        {
            var simpleParameterValue = new SimpleParameterValue();

            Assert.Throws <ContainmentException>(() =>
            {
                Console.WriteLine(simpleParameterValue.Owner);
            });
        }
예제 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SimpleParameterValueRowViewModel"/> class
 /// </summary>
 /// <param name="simpleParameterValue">The <see cref="SimpleParameterValue"/> associated with this row </param>
 /// <param name="session">The session</param>
 /// <param name="containerViewModel">The container <see cref="IViewModelBase{T}"/></param>
 /// <param name="valueIndex">The value index</param>
 /// <param name="isReadOnly">Indicates whether the row is read-only</param>
 public SimpleParameterValueRowViewModel(SimpleParameterValue simpleParameterValue, ISession session, IViewModelBase <Thing> containerViewModel, int valueIndex, bool isReadOnly)
     : base(simpleParameterValue, session, containerViewModel)
 {
     this.valueIndex    = valueIndex;
     this.IsReadOnly    = isReadOnly;
     this.PossibleScale = new ReactiveList <MeasurementScale>();
     this.SetValues();
     this.PopulatePossibleScale();
 }
예제 #7
0
        public void TestGetOwner()
        {
            var simpleParameterValue = new SimpleParameterValue();
            var requirement          = new Requirement();

            requirement.Owner = new DomainOfExpertise();
            requirement.ParameterValue.Add(simpleParameterValue);

            Assert.IsTrue(ReferenceEquals(requirement.Owner, simpleParameterValue.Owner));
        }
예제 #8
0
        /// <summary>
        /// Query the sorting key from the <paramref name="simpleParameterValue"/>
        /// </summary>
        /// <param name="simpleParameterValue">The <see cref="SimpleParameterValue"/></param>
        /// <returns>The key or max int value if the key could not be parsed</returns>
        private int getOrderKey(SimpleParameterValue simpleParameterValue)
        {
            int key;

            if (int.TryParse(simpleParameterValue.Value.FirstOrDefault(), out key))
            {
                return(key);
            }

            return(int.MaxValue);
        }
예제 #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SimpleParameterValueRowViewModel"/> class
 /// </summary>
 /// <param name="simpleParameterValue">The <see cref="SimpleParameterValue"/> associated with this row </param>
 /// <param name="session">The session</param>
 /// <param name="containerViewModel">The container <see cref="IViewModelBase{T}"/></param>
 public SimpleParameterValueRowViewModel(SimpleParameterValue simpleParameterValue, ISession session, IViewModelBase <Thing> containerViewModel)
     : base(simpleParameterValue, session, containerViewModel)
 {
     this.PossibleScales = new ReactiveList <MeasurementScale>();
     this.UpdateProperties();
     this.WhenAnyValue(x => x.Scale).Where(x => x != null).Subscribe(
         x =>
     {
         if (!this.Thing.IsCached())
         {
             this.Thing.Scale = x;
         }
     });
 }
예제 #10
0
        /// <summary>
        /// Removes a value row
        /// </summary>
        /// <param name="value">The associated <see cref="SimpleParameterValue"/> to remove</param>
        private void RemoveValue(SimpleParameterValue value)
        {
            var row = this.simpleParameters.ContainedRows.SingleOrDefault(x => x.Thing == value);

            if (row != null)
            {
                this.simpleParameters.ContainedRows.Remove(row);
                row.Dispose();
            }

            if (this.definitionSubscription != null)
            {
                this.definitionSubscription.Dispose();
            }
        }
예제 #11
0
        /// <summary>
        /// Serialize the <see cref="SimpleParameterValue"/>
        /// </summary>
        /// <param name="simpleParameterValue">The <see cref="SimpleParameterValue"/> to serialize</param>
        /// <returns>The <see cref="JObject"/></returns>
        private JObject Serialize(SimpleParameterValue simpleParameterValue)
        {
            var jsonObject = new JObject();

            jsonObject.Add("classKind", this.PropertySerializerMap["classKind"](Enum.GetName(typeof(CDP4Common.CommonData.ClassKind), simpleParameterValue.ClassKind)));
            jsonObject.Add("excludedDomain", this.PropertySerializerMap["excludedDomain"](simpleParameterValue.ExcludedDomain.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("excludedPerson", this.PropertySerializerMap["excludedPerson"](simpleParameterValue.ExcludedPerson.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("iid", this.PropertySerializerMap["iid"](simpleParameterValue.Iid));
            jsonObject.Add("modifiedOn", this.PropertySerializerMap["modifiedOn"](simpleParameterValue.ModifiedOn));
            jsonObject.Add("parameterType", this.PropertySerializerMap["parameterType"](simpleParameterValue.ParameterType));
            jsonObject.Add("revisionNumber", this.PropertySerializerMap["revisionNumber"](simpleParameterValue.RevisionNumber));
            jsonObject.Add("scale", this.PropertySerializerMap["scale"](simpleParameterValue.Scale));
            jsonObject.Add("thingPreference", this.PropertySerializerMap["thingPreference"](simpleParameterValue.ThingPreference));
            jsonObject.Add("value", this.PropertySerializerMap["value"](simpleParameterValue.Value));
            return(jsonObject);
        }
예제 #12
0
        public void VerifyThatWhenANewSimpleParameterValueIsCreatedAndRequiredRdlIsNullThePossibleParameterTypesAreLoaded()
        {
            this.mrdl.RequiredRdl = null;

            this.parameterValue = new SimpleParameterValue(Guid.NewGuid(), this.cache, this.uri)
            {
                ParameterType = null
            };
            this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.siteDir);
            this.session.Setup(x => x.ActivePerson).Returns(new Person(Guid.NewGuid(), null, this.uri));

            var vm = new SimpleParameterValueDialogViewModel(this.parameterValue.Clone(false), this.thingTransaction, this.session.Object, true, ThingDialogKind.Update, this.thingDialogNavigationService.Object, this.requirementClone);

            var parametertypes = new ReactiveList <ParameterType>();

            CollectionAssert.AreEquivalent(parametertypes, vm.PossibleParameterType);
        }
예제 #13
0
        public void SetUp()
        {
            this.simpleParameterValueRuleChecker = new SimpleParameterValueRuleChecker();

            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.simpleParameterValue = new SimpleParameterValue();

            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.ParameterValue.Add(this.simpleParameterValue);
        }
예제 #14
0
        /// <summary>
        /// Add a <see cref="SimpleParameterValue"/> to a <see cref="Requirement"/>
        /// </summary>
        /// <param name="requirement">The <see cref="Requirement"/></param>
        /// <param name="value">The <see cref="AttributeValue"/></param>
        private void SetParameterValue(Requirement requirement, AttributeValue value)
        {
            if (this.datatypeDefMap[value.AttributeDefinition.DatatypeDefinition].ParameterType == null)
            {
                throw new InvalidOperationException("The datatype-definition of an AttributeValue that is mapped to a Parameter-Value shall be mapped to a ParameterType.");
            }

            var theValue   = this.GetAttributeValue(value);
            var valueArray = new string[] { theValue };

            // TODO get mapped scale
            var simpleParameter = new SimpleParameterValue
            {
                ParameterType = this.datatypeDefMap[value.AttributeDefinition.DatatypeDefinition].ParameterType
            };

            simpleParameter.Value = new ValueArray <string>(valueArray);
            requirement.ParameterValue.Add(simpleParameter);
        }
예제 #15
0
        /// <summary>
        /// Handles the drop action of a <see cref="Tuple{ParameterType, MeasurementScale}"/>
        /// </summary>
        /// <param name="tuple">The <see cref="Tuple{ParameterType, MeasurementScale}"/></param>
        private async Task Drop(Tuple <ParameterType, MeasurementScale> tuple)
        {
            var clone = this.Thing.Clone(false);

            var parameterValue = new SimpleParameterValue();

            parameterValue.ParameterType = tuple.Item1;
            parameterValue.Scale         = tuple.Item2;
            parameterValue.Value         = new ValueArray <string>(new [] { "-" });

            clone.ParameterValue.Add(parameterValue);

            var transaction = new ThingTransaction(TransactionContextResolver.ResolveContext(this.Thing));

            transaction.Create(parameterValue);
            transaction.CreateOrUpdate(clone);

            await this.DalWrite(transaction);
        }
        public void Verify_that_RequirementArray_is_populated_as_expected()
        {
            var launchDate = new SimpleParameterValue {
                ParameterType = this.dateParameterType, Scale = null, Value = new ValueArray <string>(new List <string> {
                    "2050-12-12"
                })
            };
            var launchMass = new SimpleParameterValue {
                ParameterType = this.simpleQuantityKind, Scale = this.ratioScale, Value = new ValueArray <string>(new List <string> {
                    "100000000"
                })
            };
            var MR_1_compliance = new SimpleParameterValue {
                ParameterType = this.booleanParameterType, Scale = null, Value = new ValueArray <string>(new List <string> {
                    "True"
                })
            };
            var MR_2_compliance = new SimpleParameterValue {
                ParameterType = this.booleanParameterType, Scale = null, Value = new ValueArray <string>(new List <string> {
                    "False"
                })
            };
            var SR_1_compliance = new SimpleParameterValue {
                ParameterType = this.booleanParameterType, Scale = null, Value = new ValueArray <string>(new List <string> {
                    "True"
                })
            };

            var requirementsSpecification_MRD = new RequirementsSpecification
            {
                ShortName = "MRD",
                Name      = "Mission Requirements Document",
                Owner     = this.domainOfExpertise
            };

            var MR_1 = new Requirement
            {
                ShortName = "MR-001",
                Name      = "Launch Date",
                Owner     = this.domainOfExpertise
            };

            MR_1.Definition.Add(new Definition
            {
                LanguageCode = "en-GB",
                Content      = "The Launch Date shall be in the future"
            });

            MR_1.ParameterValue.Add(launchDate);
            MR_1.ParameterValue.Add(MR_1_compliance);

            var MR_2 = new Requirement
            {
                ShortName = "MR-002",
                Name      = "Launch Mass",
                Owner     = this.domainOfExpertise
            };

            MR_2.Definition.Add(new Definition
            {
                LanguageCode = "en-GB",
                Content      = "The Launch Mass shall be a lot"
            });

            MR_2.ParameterValue.Add(launchMass);
            MR_2.ParameterValue.Add(MR_2_compliance);

            requirementsSpecification_MRD.Requirement.Add(MR_1);
            requirementsSpecification_MRD.Requirement.Add(MR_2);

            var requirementsSpecification_SRD = new RequirementsSpecification
            {
                ShortName = "SRD",
                Name      = "System Requirements Document",
                Owner     = this.domainOfExpertise
            };

            var SR_1 = new Requirement
            {
                ShortName = "SR-001",
                Name      = "Awesomeness",
                Owner     = this.domainOfExpertise
            };

            SR_1.Definition.Add(new Definition
            {
                LanguageCode = "en-GB",
                Content      = "The System shall be awesome"
            });

            SR_1.ParameterValue.Add(SR_1_compliance);

            requirementsSpecification_SRD.Requirement.Add(SR_1);

            this.iteration.RequirementsSpecification.Add(requirementsSpecification_MRD);
            this.iteration.RequirementsSpecification.Add(requirementsSpecification_SRD);

            var requirements = iteration.RequirementsSpecification.SelectMany(x => x.Requirement);;
            var requirementArrayAssembler = new RequirementArrayAssembler(requirements);

            Assert.That(requirementArrayAssembler.ContentArray[0, 0], Is.EqualTo("Specification"));
            Assert.That(requirementArrayAssembler.ContentArray[0, 1], Is.EqualTo("Group"));
            Assert.That(requirementArrayAssembler.ContentArray[0, 2], Is.EqualTo("Short Name"));
            Assert.That(requirementArrayAssembler.ContentArray[0, 3], Is.EqualTo("Name"));
            Assert.That(requirementArrayAssembler.ContentArray[0, 4], Is.EqualTo("Definition"));
            Assert.That(requirementArrayAssembler.ContentArray[0, 5], Is.EqualTo("Owner"));
            Assert.That(requirementArrayAssembler.ContentArray[0, 6], Is.EqualTo("Category"));
            Assert.That(requirementArrayAssembler.ContentArray[0, 7], Is.EqualTo("C"));
            Assert.That(requirementArrayAssembler.ContentArray[0, 8], Is.EqualTo("LD"));
            Assert.That(requirementArrayAssembler.ContentArray[0, 9], Is.EqualTo("m [kg]"));

            Assert.That(requirementArrayAssembler.ContentArray[1, 0], Is.EqualTo("Mission Requirements Document [MRD]"));
            Assert.That(requirementArrayAssembler.ContentArray[2, 0], Is.EqualTo("Mission Requirements Document [MRD]"));
            Assert.That(requirementArrayAssembler.ContentArray[3, 0], Is.EqualTo("System Requirements Document [SRD]"));

            Assert.That(requirementArrayAssembler.ContentArray[1, 1], Is.EqualTo("-"));
            Assert.That(requirementArrayAssembler.ContentArray[2, 1], Is.EqualTo("-"));
            Assert.That(requirementArrayAssembler.ContentArray[3, 1], Is.EqualTo("-"));

            Assert.That(requirementArrayAssembler.ContentArray[1, 2], Is.EqualTo("MR-001"));
            Assert.That(requirementArrayAssembler.ContentArray[2, 2], Is.EqualTo("MR-002"));
            Assert.That(requirementArrayAssembler.ContentArray[3, 2], Is.EqualTo("SR-001"));

            Assert.That(requirementArrayAssembler.ContentArray[1, 3], Is.EqualTo("Launch Date"));
            Assert.That(requirementArrayAssembler.ContentArray[2, 3], Is.EqualTo("Launch Mass"));
            Assert.That(requirementArrayAssembler.ContentArray[3, 3], Is.EqualTo("Awesomeness"));

            Assert.That(requirementArrayAssembler.ContentArray[1, 4], Is.EqualTo("The Launch Date shall be in the future"));
            Assert.That(requirementArrayAssembler.ContentArray[2, 4], Is.EqualTo("The Launch Mass shall be a lot"));
            Assert.That(requirementArrayAssembler.ContentArray[3, 4], Is.EqualTo("The System shall be awesome"));

            Assert.That(requirementArrayAssembler.ContentArray[1, 5], Is.EqualTo("SYS"));
            Assert.That(requirementArrayAssembler.ContentArray[2, 5], Is.EqualTo("SYS"));
            Assert.That(requirementArrayAssembler.ContentArray[3, 5], Is.EqualTo("SYS"));

            Assert.That(requirementArrayAssembler.ContentArray[1, 6], Is.EqualTo(""));
            Assert.That(requirementArrayAssembler.ContentArray[2, 6], Is.EqualTo(""));
            Assert.That(requirementArrayAssembler.ContentArray[3, 6], Is.EqualTo(""));

            Assert.That(requirementArrayAssembler.ContentArray[1, 7], Is.EqualTo("True"));
            Assert.That(requirementArrayAssembler.ContentArray[2, 7], Is.EqualTo("False"));
            Assert.That(requirementArrayAssembler.ContentArray[3, 7], Is.EqualTo("True"));

            Assert.That(requirementArrayAssembler.ContentArray[1, 8], Is.EqualTo("2050-12-12"));
            Assert.That(requirementArrayAssembler.ContentArray[2, 8], Is.Null);
            Assert.That(requirementArrayAssembler.ContentArray[3, 8], Is.Null);

            Assert.That(requirementArrayAssembler.ContentArray[1, 9], Is.Null);
            Assert.That(requirementArrayAssembler.ContentArray[3, 9], Is.Null);
            Assert.That(requirementArrayAssembler.ContentArray[3, 9], Is.Null);
        }
예제 #17
0
 /// <summary>
 /// Add an Parameter Value row view model to the list of <see cref="ParameterValue"/>
 /// </summary>
 /// <param name="parameterValue">
 /// The <see cref="ParameterValue"/> that is to be added
 /// </param>
 private SimpleParameterValueRowViewModel AddParameterValueRowViewModel(SimpleParameterValue parameterValue)
 {
     return(new SimpleParameterValueRowViewModel(parameterValue, this.Session, this));
 }
예제 #18
0
        /// <summary>
        /// Add a row representing a new <see cref="SimpleParameterValue"/>
        /// </summary>
        /// <param name="value">The associated <see cref="SimpleParameterValue"/></param>
        private void AddValue(SimpleParameterValue value)
        {
            var row = new SimpleParameterValueRowViewModel(value, this.Session, this);

            this.simpleParameters.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);
        }
예제 #20
0
        public virtual void Setup()
        {
            this.panelNavigationService       = new Mock <IPanelNavigationService>();
            this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>();
            this.dialogNavigationService      = new Mock <IDialogNavigationService>();
            this.permissionService            = new Mock <IPermissionService>();
            this.pluginService = new Mock <IPluginSettingsService>();
            this.session       = new Mock <ISession>();
            this.assembler     = new Assembler(this.uri);

            this.sitedir = new SiteDirectory(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.engineeringModelSetup = new EngineeringModelSetup(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.iterationSetup        = new IterationSetup(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.srdl = new SiteReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.mrdl = new ModelReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                RequiredRdl = this.srdl
            };
            this.person = new Person(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.domain = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "domain", ShortName = "domain"
            };
            this.participant = new Participant(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Person = this.person
            };

            this.orderType = new TextParameterType(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "orderPt", ShortName = "orderPt"
            };

            this.catEd1 = new Category(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "cat1", ShortName = "cat1"
            };
            this.catEd2 = new Category(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "cat2", ShortName = "cat2"
            };
            this.catRel = new Category(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "catrel", ShortName = "catrel"
            };

            this.catEd1.PermissibleClass.Add(ClassKind.ElementDefinition);
            this.catEd2.PermissibleClass.Add(ClassKind.ElementDefinition);
            this.catRel.PermissibleClass.Add(ClassKind.BinaryRelationship);

            this.rule = new BinaryRelationshipRule(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                SourceCategory = this.catEd1, TargetCategory = this.catEd2, RelationshipCategory = this.catRel, Name = "rel", ShortName = "rel"
            };

            this.sitedir.Model.Add(this.engineeringModelSetup);
            this.sitedir.SiteReferenceDataLibrary.Add(this.srdl);
            this.sitedir.Person.Add(this.person);
            this.sitedir.Domain.Add(this.domain);
            this.engineeringModelSetup.IterationSetup.Add(this.iterationSetup);
            this.engineeringModelSetup.RequiredRdl.Add(this.mrdl);
            this.engineeringModelSetup.Participant.Add(this.participant);

            this.srdl.DefinedCategory.Add(this.catEd1);
            this.srdl.DefinedCategory.Add(this.catEd2);
            this.srdl.DefinedCategory.Add(this.catRel);
            this.srdl.Rule.Add(this.rule);
            this.srdl.ParameterType.Add(this.orderType);

            this.model = new EngineeringModel(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                EngineeringModelSetup = this.engineeringModelSetup
            };
            this.iteration = new Iteration(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                IterationSetup = this.iterationSetup
            };
            this.spec1 = new RequirementsSpecification(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "spec1", ShortName = "spec1", Owner = this.domain
            };
            this.spec2 = new RequirementsSpecification(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "spec2", ShortName = "spec2"
            };
            this.spec3 = new RequirementsSpecification(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "spec3", ShortName = "spec3"
            };

            this.grp1 = new RequirementsGroup(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "gr1", ShortName = "gr1", Owner = this.domain
            };
            this.grp2 = new RequirementsGroup(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "gr2", ShortName = "gr2"
            };
            this.grp3 = new RequirementsGroup(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "gr3", ShortName = "gr3"
            };
            this.grp4 = new RequirementsGroup(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "gr4", ShortName = "gr4"
            };

            this.req1 = new Requirement(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "req1", ShortName = "req1"
            };
            this.req2 = new Requirement(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "req2", ShortName = "req2"
            };
            this.req3 = new Requirement(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "req3", ShortName = "req3"
            };
            this.req4 = new Requirement(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "req4", ShortName = "req4"
            };
            this.req21 = new Requirement(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "req21", ShortName = "req21", Group = this.grp1
            };
            this.req22 = new Requirement(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "req22", ShortName = "req22", Group = this.grp1
            };
            this.req23 = new Requirement(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "req23", ShortName = "req23", Group = this.grp1
            };

            this.value1 = new SimpleParameterValue(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                ParameterType = this.orderType, Value = new ValueArray <string>(new [] { "10000" })
            };
            this.value2 = new SimpleParameterValue(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                ParameterType = this.orderType, Value = new ValueArray <string>(new [] { "20000" })
            };
            this.value3 = new SimpleParameterValue(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                ParameterType = this.orderType, Value = new ValueArray <string>(new [] { "30000" })
            };
            this.value4 = new SimpleParameterValue(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                ParameterType = this.orderType, Value = new ValueArray <string>(new [] { "40000" })
            };

            this.model.Iteration.Add(this.iteration);
            this.iteration.RequirementsSpecification.Add(this.spec1);
            this.iteration.RequirementsSpecification.Add(this.spec2);
            this.iteration.RequirementsSpecification.Add(this.spec3);
            this.spec1.Requirement.Add(this.req1);
            this.spec1.Requirement.Add(this.req2);
            this.spec1.Requirement.Add(this.req3);
            this.spec1.Requirement.Add(this.req4);

            this.spec2.Requirement.Add(this.req21);
            this.spec2.Requirement.Add(this.req22);
            this.spec2.Requirement.Add(this.req23);

            this.spec2.Group.Add(this.grp1);
            this.spec2.Group.Add(this.grp2);
            this.spec2.Group.Add(this.grp3);
            this.grp1.Group.Add(this.grp4);

            this.req1.ParameterValue.Add(this.value1);
            this.req2.ParameterValue.Add(this.value2);
            this.req3.ParameterValue.Add(this.value3);
            this.req4.ParameterValue.Add(this.value4);

            this.assembler.Cache.TryAdd(new CacheKey(this.sitedir.Iid, null), new Lazy <Thing>(() => this.sitedir));
            this.assembler.Cache.TryAdd(new CacheKey(this.engineeringModelSetup.Iid, null), new Lazy <Thing>(() => this.engineeringModelSetup));
            this.assembler.Cache.TryAdd(new CacheKey(this.srdl.Iid, null), new Lazy <Thing>(() => this.srdl));
            this.assembler.Cache.TryAdd(new CacheKey(this.iterationSetup.Iid, null), new Lazy <Thing>(() => this.iterationSetup));
            this.assembler.Cache.TryAdd(new CacheKey(this.mrdl.Iid, null), new Lazy <Thing>(() => this.mrdl));
            this.assembler.Cache.TryAdd(new CacheKey(this.person.Iid, null), new Lazy <Thing>(() => this.person));
            this.assembler.Cache.TryAdd(new CacheKey(this.domain.Iid, null), new Lazy <Thing>(() => this.domain));
            this.assembler.Cache.TryAdd(new CacheKey(this.participant.Iid, null), new Lazy <Thing>(() => this.participant));
            this.assembler.Cache.TryAdd(new CacheKey(this.catEd1.Iid, null), new Lazy <Thing>(() => this.catEd1));
            this.assembler.Cache.TryAdd(new CacheKey(this.catEd2.Iid, null), new Lazy <Thing>(() => this.catEd2));
            this.assembler.Cache.TryAdd(new CacheKey(this.catRel.Iid, null), new Lazy <Thing>(() => this.catRel));
            this.assembler.Cache.TryAdd(new CacheKey(this.rule.Iid, null), new Lazy <Thing>(() => this.rule));

            this.assembler.Cache.TryAdd(new CacheKey(this.model.Iid, null), new Lazy <Thing>(() => this.model));
            this.assembler.Cache.TryAdd(new CacheKey(this.iteration.Iid, null), new Lazy <Thing>(() => this.iteration));
            this.assembler.Cache.TryAdd(new CacheKey(this.spec1.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.spec1));
            this.assembler.Cache.TryAdd(new CacheKey(this.spec2.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.spec2));
            this.assembler.Cache.TryAdd(new CacheKey(this.spec3.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.spec3));
            this.assembler.Cache.TryAdd(new CacheKey(this.grp1.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.grp1));
            this.assembler.Cache.TryAdd(new CacheKey(this.grp2.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.grp2));
            this.assembler.Cache.TryAdd(new CacheKey(this.grp3.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.grp3));
            this.assembler.Cache.TryAdd(new CacheKey(this.grp4.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.grp4));
            this.assembler.Cache.TryAdd(new CacheKey(this.req1.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.req1));
            this.assembler.Cache.TryAdd(new CacheKey(this.req2.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.req2));
            this.assembler.Cache.TryAdd(new CacheKey(this.req3.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.req3));
            this.assembler.Cache.TryAdd(new CacheKey(this.req4.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.req4));
            this.assembler.Cache.TryAdd(new CacheKey(this.req21.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.req21));
            this.assembler.Cache.TryAdd(new CacheKey(this.req22.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.req22));
            this.assembler.Cache.TryAdd(new CacheKey(this.req23.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.req23));
            this.assembler.Cache.TryAdd(new CacheKey(this.value1.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.value1));
            this.assembler.Cache.TryAdd(new CacheKey(this.value2.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.value2));
            this.assembler.Cache.TryAdd(new CacheKey(this.value3.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.value3));
            this.assembler.Cache.TryAdd(new CacheKey(this.value4.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.value4));

            this.permissionService.Setup(x => x.CanWrite(It.IsAny <Thing>())).Returns(true);
            this.permissionService.Setup(x => x.CanWrite(It.IsAny <ClassKind>(), It.IsAny <Thing>())).Returns(true);
            this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object);
            this.session.Setup(x => x.Assembler).Returns(this.assembler);
            this.session.Setup(x => x.ActivePerson).Returns(this.person);
            this.session.Setup(x => x.OpenIterations).Returns(
                new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> > {
                { this.iteration, new Tuple <DomainOfExpertise, Participant>(this.domain, this.participant) }
            });

            RequirementsModule.PluginSettings = new RequirementsModuleSettings();
            RequirementsModule.PluginSettings.OrderSettings = new OrderSettings();
            RequirementsModule.PluginSettings.OrderSettings.ParameterType = this.orderType.Iid;
        }
예제 #21
0
        public void Setup()
        {
            this.serviceLocator    = new Mock <IServiceLocator>();
            this.messageBoxService = new Mock <IMessageBoxService>();

            ServiceLocator.SetLocatorProvider(() => this.serviceLocator.Object);
            this.serviceLocator.Setup(x => x.GetInstance <IMessageBoxService>()).Returns(this.messageBoxService.Object);

            this.session    = new Mock <ISession>();
            this.assembler  = new Assembler(this.uri);
            this.sitedir    = new SiteDirectory(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.modelsetup = new EngineeringModelSetup(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.sitedir.Model.Add(this.modelsetup);
            this.iterationsetup = new IterationSetup(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.modelsetup.IterationSetup.Add(this.iterationsetup);
            this.srdl = new SiteReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.sitedir.SiteReferenceDataLibrary.Add(this.srdl);
            this.mrdl = new ModelReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                RequiredRdl = this.srdl
            };
            this.modelsetup.RequiredRdl.Add(this.mrdl);
            this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.sitedir);
            this.session.Setup(x => x.Assembler).Returns(this.assembler);

            this.model = new EngineeringModel(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                EngineeringModelSetup = this.modelsetup
            };
            this.iteration = new Iteration(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                IterationSetup = this.iterationsetup
            };
            this.model.Iteration.Add(this.iteration);

            this.reqSpec  = new RequirementsSpecification(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.reqSpec2 = new RequirementsSpecification(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.iteration.RequirementsSpecification.Add(this.reqSpec);
            this.iteration.RequirementsSpecification.Add(this.reqSpec2);

            this.deprecatedRequirementsSpecification = new RequirementsSpecification(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.deprecatedRequirementsSpecification.IsDeprecated = true;
            this.iteration.RequirementsSpecification.Add(this.deprecatedRequirementsSpecification);

            this.deprecatedRequirement = new Requirement(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.deprecatedRequirement.IsDeprecated = true;
            this.deprecatedRequirementsSpecification.Requirement.Add(this.deprecatedRequirement);

            this.group1 = new RequirementsGroup(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.reqSpec.Group.Add(this.group1);
            this.group11 = new RequirementsGroup(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.group1.Group.Add(this.group11);

            this.req = new Requirement(Guid.NewGuid(), this.assembler.Cache, this.uri);
            var definition = new Definition(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Content = "def0"
            };

            this.req.Definition.Add(definition);

            this.req1 = new Requirement(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Group = this.group1
            };
            var definition1 = new Definition(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Content = "def1"
            };

            this.req1.Definition.Add(definition1);

            this.req11 = new Requirement(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Group = this.group11
            };
            var definition11 = new Definition(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Content = "def11"
            };

            this.req11.Definition.Add(definition11);

            this.req2 = new Requirement(Guid.NewGuid(), this.assembler.Cache, this.uri);
            var definition2 = new Definition(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Content = "def2"
            };

            this.req2.Definition.Add(definition2);

            this.reqSpec.Requirement.Add(this.req);
            this.reqSpec.Requirement.Add(this.req1);
            this.reqSpec.Requirement.Add(this.req11);

            this.reqSpec2.Requirement.Add(this.req2);

            this.booleanParameterType = new BooleanParameterType(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "bool", ShortName = "bool"
            };
            this.srdl.ParameterType.Add(this.booleanParameterType);

            this.functionalReq = new Category(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "Functional", ShortName = "Func"
            };

            this.deriveCat = new Category(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "Derive Category", ShortName = "Derive"
            };

            this.reqCategory = new Category(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "req cat", ShortName = "reqcat"
            };
            this.specCategory = new Category(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "spec cat", ShortName = "speccat"
            };

            this.specRelationRuleCategory = new Category(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "Spec Link", ShortName = "SpecLink"
            };

            this.srdl.DefinedCategory.Add(this.functionalReq);
            this.srdl.DefinedCategory.Add(this.deriveCat);
            this.srdl.DefinedCategory.Add(this.reqCategory);
            this.srdl.DefinedCategory.Add(this.specCategory);

            this.reqCategory.SuperCategory.Add(this.functionalReq);

            this.specRuleType = new BinaryRelationshipRule(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "Spec Link", ShortName = "SpecLink"
            };
            this.specRuleType.SourceCategory       = this.specCategory;
            this.specRuleType.TargetCategory       = this.specCategory;
            this.specRuleType.RelationshipCategory = this.specRelationRuleCategory;

            this.derivedRule = new BinaryRelationshipRule(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "Derive", ShortName = "Derive"
            };
            this.derivedRule.SourceCategory       = this.reqCategory;
            this.derivedRule.TargetCategory       = this.reqCategory;
            this.derivedRule.RelationshipCategory = this.deriveCat;

            this.parameRule = new ParameterizedCategoryRule(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "param Rule", ShortName = "ParamRule"
            };
            this.parameRule.ParameterType.Add(this.booleanParameterType);
            this.parameRule.Category = this.functionalReq;

            this.srdl.Rule.Add(this.specRuleType);
            this.srdl.Rule.Add(this.derivedRule);
            this.srdl.Rule.Add(this.parameRule);

            this.reqSpec.Category.Add(this.specCategory);
            this.reqSpec2.Category.Add(this.specCategory);
            this.deprecatedRequirementsSpecification.Category.Add(this.specCategory);

            this.req.Category.Add(this.reqCategory);
            this.req1.Category.Add(this.reqCategory);
            this.req11.Category.Add(this.reqCategory);
            this.req2.Category.Add(this.reqCategory);
            this.deprecatedRequirement.Category.Add(this.reqCategory);

            this.deriveRelationship1 = new BinaryRelationship(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Source = this.req,
                Target = this.req2
            };

            this.deriveRelationship2 = new BinaryRelationship(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Source = this.req1,
                Target = this.req
            };

            this.deriveRelationship3 = new BinaryRelationship(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Source = this.req11,
                Target = this.req1
            };

            this.deriveRelationship1.Category.Add(this.deriveCat);
            this.deriveRelationship2.Category.Add(this.deriveCat);
            this.deriveRelationship3.Category.Add(this.deriveCat);

            this.specDeriveRelationship = new BinaryRelationship(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Source = this.reqSpec,
                Target = this.reqSpec2
            };

            this.specDeriveRelationship.Category.Add(this.specRelationRuleCategory);

            this.iteration.Relationship.Add(this.deriveRelationship1);
            this.iteration.Relationship.Add(this.deriveRelationship2);
            this.iteration.Relationship.Add(this.deriveRelationship3);
            this.iteration.Relationship.Add(this.specDeriveRelationship);

            this.reqValue = new SimpleParameterValue(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                ParameterType = this.booleanParameterType,
                Value         = new ValueArray <string>(new[] { "true" })
            };

            this.reqValue1 = new SimpleParameterValue(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                ParameterType = this.booleanParameterType,
                Value         = new ValueArray <string>(new[] { "true" })
            };

            this.reqValue11 = new SimpleParameterValue(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                ParameterType = this.booleanParameterType,
                Value         = new ValueArray <string>(new[] { "true" })
            };

            this.reqValue2 = new SimpleParameterValue(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                ParameterType = this.booleanParameterType,
                Value         = new ValueArray <string>(new[] { "true" })
            };

            this.req.ParameterValue.Add(this.reqValue);
            this.req1.ParameterValue.Add(this.reqValue1);
            this.req11.ParameterValue.Add(this.reqValue11);
            this.req2.ParameterValue.Add(this.reqValue2);
        }
예제 #22
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> >();

            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.pt = new BooleanParameterType(Guid.NewGuid(), this.cache, this.uri);
            this.srdl.ParameterType.Add(this.pt);

            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.parameterValue = new SimpleParameterValue(Guid.NewGuid(), this.cache, this.uri)
            {
                ParameterType = this.pt
            };
            this.reqSpec = new RequirementsSpecification(Guid.NewGuid(), this.cache, this.uri);
            this.reqSpec.Requirement.Add(this.requirement);
            this.requirement.ParameterValue.Add(this.parameterValue);
            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.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);

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

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

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

            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());

            this.cache.TryAdd(new CacheKey(this.parameterValue.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.parameterValue));
        }