public void Setup() { 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); }
public void SetUp() { this.session = new Mock <ISession>(); this.binaryRelationship = new BinaryRelationship(Guid.NewGuid(), null, null); }
/// <summary> /// Adds a <see cref="BinaryRelationship"/> row view model to the tree. /// </summary> /// <param name="relationship">The <see cref="BinaryRelationship"/> that this row will belong to.</param> private void AddBinaryRelationshipRowViewModel(BinaryRelationship relationship) { var row = new BinaryRelationshipRowViewModel(relationship, this.Session, this); this.binaryRelationshipsFolder.ContainedRows.Add(row); }
/// <summary> /// Creates a <see cref="BinaryRelationship"/> /// </summary> /// <param name="connector">The drawn <see cref="DiagramConnector"/> that is used as a template.</param> private async void CreateBinaryRelationship(DiagramConnector connector) { var beginItemContent = ((DiagramContentItem)connector?.BeginItem)?.Content as NamedThingDiagramContentItem; var endItemContent = ((DiagramContentItem)connector?.EndItem)?.Content as NamedThingDiagramContentItem; if (beginItemContent == null || endItemContent == null) { // connector was drawn with either the source or target missing // remove the dummy connector this.Behavior.RemoveItem(connector); this.Behavior.ResetTool(); return; } // send off the relationship Tuple <DomainOfExpertise, Participant> tuple; this.Session.OpenIterations.TryGetValue(this.Thing, out tuple); var binaryRelationship = new BinaryRelationship(Guid.NewGuid(), null, null) { Owner = tuple.Item1 }; if (this.PendingBinaryRelationshipRule != null) { binaryRelationship.Category.Add(this.PendingBinaryRelationshipRule.RelationshipCategory); } var iteration = this.Thing.Clone(false); iteration.Relationship.Add(binaryRelationship); binaryRelationship.Container = iteration; binaryRelationship.Source = beginItemContent.Thing; binaryRelationship.Target = endItemContent.Thing; var transactionContext = TransactionContextResolver.ResolveContext(this.Thing); var containerTransaction = new ThingTransaction(transactionContext, iteration); containerTransaction.CreateOrUpdate(binaryRelationship); try { var operationContainer = containerTransaction.FinalizeTransaction(); await this.Session.Write(operationContainer); // at this point relationship has gone through. if (this.Thing.Relationship.FirstOrDefault(r => r.Iid == binaryRelationship.Iid) is BinaryRelationship returedRelationship) { this.CreateBinaryRelationshipDiagramConnector(returedRelationship, connector); } } catch (Exception ex) { MessageBox.Show($"Creation of Binary Relationship failed: {ex.Message}", "Creating Binary Relationship Failed", MessageBoxButton.OK, MessageBoxImage.Error); } finally { // remove the dummy connector this.Behavior.RemoveItem(connector); this.Behavior.ResetTool(); this.PendingBinaryRelationshipRule = null; } }
public void Setup() { this.session = new Mock <ISession>(); this.assembler = new Assembler(this.uri); this.permissionService = new Mock <IPermissionService>(); this.mockExtendedDiagramBehavior = new Mock <IExtendedDiagramOrgChartBehavior>(); this.mockDiagramBehavior = new Mock <ICdp4DiagramOrgChartBehavior>(MockBehavior.Strict); this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object); this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>(); this.panelNavigationService = new Mock <IPanelNavigationService>(); this.pluginSettingsService = new Mock <IPluginSettingsService>(); this.dropinfo = new Mock <IDiagramDropInfo>(); this.cache = this.assembler.Cache; this.sitedir = new SiteDirectory(Guid.NewGuid(), this.cache, this.uri); this.srdl = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri); this.modelsetup = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri) { Name = "model" }; this.iterationsetup = new IterationSetup(Guid.NewGuid(), this.cache, this.uri); this.person = new Person(Guid.NewGuid(), this.cache, this.uri); this.domain = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri) { Name = "domain" }; this.participant = new Participant(Guid.NewGuid(), this.cache, this.uri) { Person = this.person, SelectedDomain = this.domain }; this.diagram = new DiagramCanvas(Guid.NewGuid(), this.cache, this.uri) { Name = "model" }; this.sitedir.Model.Add(this.modelsetup); this.sitedir.SiteReferenceDataLibrary.Add(this.srdl); this.sitedir.Person.Add(this.person); this.sitedir.Domain.Add(this.domain); this.modelsetup.IterationSetup.Add(this.iterationsetup); this.modelsetup.Participant.Add(this.participant); 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.iteration.DiagramCanvas.Add(this.diagram); this.model.Iteration.Add(this.iteration); this.specCat = new Category(Guid.NewGuid(), this.cache, this.uri); this.relationshipCat = new Category(Guid.NewGuid(), this.cache, this.uri); this.spec1 = new RequirementsSpecification(Guid.NewGuid(), this.cache, this.uri); this.spec2 = new RequirementsSpecification(Guid.NewGuid(), this.cache, this.uri); this.spec3 = new RequirementsSpecification(Guid.NewGuid(), this.cache, this.uri); this.link1 = new BinaryRelationship(Guid.NewGuid(), this.cache, this.uri) { Source = this.spec1, Target = this.spec2 }; this.link1.Category.Add(this.relationshipCat); this.spec1.Category.Add(this.specCat); this.spec2.Category.Add(this.specCat); this.spec3.Category.Add(this.specCat); this.srdl.DefinedCategory.Add(this.specCat); this.srdl.DefinedCategory.Add(this.relationshipCat); this.iteration.RequirementsSpecification.Add(this.spec1); this.iteration.RequirementsSpecification.Add(this.spec2); this.iteration.RequirementsSpecification.Add(this.spec3); this.iteration.Relationship.Add(this.link1); var tuple = new Tuple <DomainOfExpertise, Participant>(this.domain, this.participant); var openedIterations = new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> > { { this.iteration, tuple } }; this.diagramObject1 = new DiagramObject(Guid.NewGuid(), this.cache, this.uri) { DepictedThing = this.spec1 }; this.diagramObject2 = new DiagramObject(Guid.NewGuid(), this.cache, this.uri) { DepictedThing = this.spec2 }; this.diagramObject3 = new DiagramObject(Guid.NewGuid(), this.cache, this.uri) { DepictedThing = this.spec3 }; this.connector = new DiagramEdge(Guid.NewGuid(), this.cache, this.uri) { Source = this.diagramObject1, Target = this.diagramObject2, DepictedThing = this.link1 }; this.elementDefinition = new ElementDefinition() { Name = "WhyNot", ShortName = "WhyNot" }; this.bound1 = new Bounds(Guid.NewGuid(), this.cache, this.uri) { X = 1, Y = 1, Height = 12, Width = 10 }; this.bound2 = new Bounds(Guid.NewGuid(), this.cache, this.uri) { X = 1, Y = 1, Height = 12, Width = 10 }; this.diagramObject1.Bounds.Add(this.bound1); this.diagramObject2.Bounds.Add(this.bound2); this.diagram.DiagramElement.Add(this.diagramObject1); this.diagram.DiagramElement.Add(this.diagramObject2); this.diagram.DiagramElement.Add(this.connector); this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.sitedir); this.session.Setup(x => x.ActivePerson).Returns(this.person); this.session.Setup(x => x.OpenIterations).Returns(openedIterations); this.session.Setup(x => x.Assembler).Returns(this.assembler); this.permissionService.Setup(x => x.CanWrite(It.IsAny <Thing>())).Returns(true); this.mockExtendedDiagramBehavior.Setup(x => x.GetDiagramPositionFromMousePosition(It.IsAny <Point>())).Returns(new Point()); this.mockDiagramBehavior.Setup(x => x.GetDiagramPositionFromMousePosition(It.IsAny <Point>())).Returns(new Point()); this.mockDiagramBehavior.Setup(x => x.ItemPositions).Returns(new Dictionary <object, Point>()); this.mockDiagramBehavior.Setup(x => x.ApplyChildLayout(It.IsAny <DiagramItem>())); this.cache.TryAdd(new CacheKey(this.iteration.Iid, null), new Lazy <Thing>(() => this.iteration)); }
public void Setup() { this.sitedir = new SiteDirectory(Guid.NewGuid(), this.cache, null); this.modelsetup = new EngineeringModelSetup(Guid.NewGuid(), this.cache, null); this.iterationsetup = new IterationSetup(Guid.NewGuid(), this.cache, null); this.srdl = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, null); this.mrdl = new ModelReferenceDataLibrary(Guid.NewGuid(), this.cache, null) { RequiredRdl = this.srdl }; this.parameterType = new BooleanParameterType(Guid.NewGuid(), this.cache, null) { Name = "boolean", ShortName = "bool" }; this.category = new Category(Guid.NewGuid(), this.cache, null) { Name = "cat", ShortName = "cat", }; this.rule = new ParameterizedCategoryRule(Guid.NewGuid(), this.cache, null) { Category = this.category, ShortName = "rule", Name = "rule" }; this.rule.ParameterType.Add(this.parameterType); this.sitedir.Model.Add(this.modelsetup); this.sitedir.SiteReferenceDataLibrary.Add(this.srdl); this.modelsetup.IterationSetup.Add(this.iterationsetup); this.modelsetup.RequiredRdl.Add(this.mrdl); this.srdl.ParameterType.Add(this.parameterType); this.srdl.DefinedCategory.Add(this.category); this.srdl.Rule.Add(this.rule); this.model = new EngineeringModel(Guid.NewGuid(), this.cache, null) { EngineeringModelSetup = this.modelsetup }; this.iteration = new Iteration(Guid.NewGuid(), this.cache, null) { IterationSetup = this.iterationsetup }; this.relation1 = new BinaryRelationship(Guid.NewGuid(), this.cache, null); this.relation2 = new BinaryRelationship(Guid.NewGuid(), this.cache, null); this.spec1 = new RequirementsSpecification(Guid.NewGuid(), this.cache, null) { Name = "spec1", ShortName = "spec1" }; this.spec2 = new RequirementsSpecification(Guid.NewGuid(), this.cache, null) { Name = "spec2", ShortName = "spec2" }; this.gr1 = new RequirementsGroup(Guid.NewGuid(), this.cache, null) { Name = "gr1", ShortName = "gr1" }; this.gr2 = new RequirementsGroup(Guid.NewGuid(), this.cache, null) { Name = "gr2", ShortName = "gr2" }; this.req1 = new Requirement(Guid.NewGuid(), this.cache, null) { Name = "r1", ShortName = "r1" }; this.req2 = new Requirement(Guid.NewGuid(), this.cache, null) { Name = "r2", ShortName = "r2" }; this.def1 = new ElementDefinition(Guid.NewGuid(), this.cache, null) { Name = "d1", ShortName = "d1" }; this.def2 = new ElementDefinition(Guid.NewGuid(), this.cache, null) { Name = "d2", ShortName = "d2" }; this.model.Iteration.Add(this.iteration); this.iteration.Relationship.Add(this.relation1); this.iteration.Relationship.Add(this.relation2); this.iteration.RequirementsSpecification.Add(this.spec1); this.iteration.RequirementsSpecification.Add(this.spec2); this.spec1.Group.Add(this.gr1); this.spec1.Group.Add(this.gr2); this.spec1.Requirement.Add(this.req1); this.spec1.Requirement.Add(this.req2); this.iteration.Element.Add(this.def1); this.iteration.Element.Add(this.def2); this.relation1.Category.Add(this.category); this.relation2.Category.Add(this.category); this.spec1.Category.Add(this.category); this.spec2.Category.Add(this.category); this.req1.Category.Add(this.category); this.req2.Category.Add(this.category); this.gr1.Category.Add(this.category); this.gr2.Category.Add(this.category); this.def1.Category.Add(this.category); this.def2.Category.Add(this.category); this.relation1.ParameterValue.Add(new RelationshipParameterValue(Guid.NewGuid(), this.cache, null) { ParameterType = this.parameterType }); this.spec1.ParameterValue.Add(new RequirementsContainerParameterValue(Guid.NewGuid(), this.cache, null) { ParameterType = this.parameterType }); this.req1.ParameterValue.Add(new SimpleParameterValue(Guid.NewGuid(), this.cache, null) { ParameterType = this.parameterType }); this.def1.Parameter.Add(new Parameter(Guid.NewGuid(), this.cache, null) { ParameterType = this.parameterType }); this.gr1.ParameterValue.Add(new RequirementsContainerParameterValue(Guid.NewGuid(), this.cache, null) { ParameterType = this.parameterType }); }