public void SetUp() { this.fileDialogService = new Mock <IOpenSaveFileDialogService>(); this.possibleIterations = new List <Iteration>(); var engineeringModelSetup = new EngineeringModelSetup() { ShortName = "TESTEM" }; var iterationSetup = new IterationSetup() { IterationNumber = 1 }; this.engineeringModel = new EngineeringModel { EngineeringModelSetup = engineeringModelSetup }; this.iteration = new Iteration { IterationSetup = iterationSetup }; this.engineeringModel.Iteration.Add(this.iteration); this.requirementsSpecification = new RequirementsSpecification { ShortName = "REQSPEC" }; this.iteration.RequirementsSpecification.Add(this.requirementsSpecification); this.possibleIterations.Add(this.iteration); }
/// <summary> /// Build the <see cref="SpecHierarchy"/> object for a <see cref="RequirementsGroup"/> /// </summary> /// <param name="reqSpec">The <see cref="RequirementsSpecification"/> containing the <see cref="Requirement"/>s</param> /// <param name="requirementGroup">The <see cref="RequirementsGroup"/> associated with the <see cref="SpecHierarchy"/> to build</param> /// <returns>The <see cref="SpecHierarchy"/></returns> private SpecHierarchy BuildGroupHierarchy(RequirementsSpecification reqSpec, RequirementsGroup requirementGroup) { var specHierarchy = new SpecHierarchy { Identifier = Guid.NewGuid().ToString(), LastChange = DateTime.UtcNow, Object = this.requirementsGroupMap[requirementGroup] }; foreach (var group in requirementGroup.Group) { var child = this.BuildGroupHierarchy(reqSpec, group); specHierarchy.Children.Add(child); } foreach (var requirement in reqSpec.Requirement.Where(x => x.Group == requirementGroup)) { var child = new SpecHierarchy { Identifier = Guid.NewGuid().ToString(), LastChange = DateTime.UtcNow, Object = this.requirementMap[requirement] }; specHierarchy.Children.Add(child); } return(specHierarchy); }
/// <summary> /// Verify the <see cref="RequirementsGroup"/> against this <see cref="ParameterizedCategoryRule"/> /// </summary> /// <param name="specification">The <see cref="RequirementsSpecification"/> container to check</param> /// <param name="violations">The collection of <see cref="RuleViolation"/> to update</param> private void VerifyRequirement(RequirementsSpecification specification, List <RuleViolation> violations) { foreach (var requirement in specification.Requirement) { if (requirement.IsMemberOfCategory(this.Category)) { var missingParameterTypes = new List <ParameterType>(); foreach (var parameterType in this.ParameterType) { var parameter = requirement.ParameterValue.SingleOrDefault(p => p.ParameterType == parameterType); if (parameter == null) { missingParameterTypes.Add(parameterType); } } if (missingParameterTypes.Count > 0) { var iids = string.Join(",", missingParameterTypes.Select(x => x.Iid)); var shortnames = string.Join(",", missingParameterTypes.Select(x => x.ShortName)); var violation = new RuleViolation(Guid.NewGuid(), this.Cache, this.IDalUri); violation.RuleViolatedClassKind.Add(requirement.ClassKind); violation.ViolatingThing.Add(requirement.Iid); violation.Description = $"The Requirement {requirement.Name} does not contain parameters that reference the following parameter types {iids} with shortnames: {shortnames}"; violations.Add(violation); } } } }
public void VerifyThatPathReturnsTheExpectedResultWithDefaultDelimiter() { var iteration = new Iteration(); var spec = new RequirementsSpecification() { ShortName = "spec" }; var group_a = new RequirementsGroup() { ShortName = "a" }; var group_a_a = new RequirementsGroup() { ShortName = "a_a" }; var group_a_a_a = new RequirementsGroup() { ShortName = "a_a_a" }; iteration.RequirementsSpecification.Add(spec); Assert.AreEqual("a", group_a.Path()); Assert.AreEqual("a_a", group_a_a.Path()); Assert.AreEqual("a_a_a", group_a_a_a.Path()); group_a_a.Group.Add(group_a_a_a); Assert.AreEqual("a_a.a_a_a", group_a_a_a.Path()); group_a.Group.Add(group_a_a); Assert.AreEqual("a.a_a.a_a_a", group_a_a_a.Path()); spec.Group.Add(group_a); Assert.AreEqual("spec.a.a_a.a_a_a", group_a_a_a.Path()); }
public void VerifyThatComparerWorks() { var spec = new RequirementsSpecification(); var grp = new RequirementsGroup() { ShortName = "a" }; var req1 = new Requirement { ShortName = "a" }; var req2 = new Requirement { ShortName = "b" }; var req3 = new Requirement { ShortName = "x" }; spec.Requirement.Add(req1); spec.Requirement.Add(req2); spec.Requirement.Add(req3); var specRow = new RequirementsSpecificationRowViewModel(spec, this.session.Object, null); var grprow = new RequirementsGroupRowViewModel(grp, this.session.Object, null, specRow); var reqrow = new RequirementRowViewModel(req1, this.session.Object, specRow); var reqrow2 = new RequirementRowViewModel(req2, this.session.Object, specRow); var reqrow3 = new RequirementRowViewModel(req3, this.session.Object, specRow); Assert.AreEqual(-1, comparer.Compare(reqrow, reqrow2)); Assert.AreEqual(-1, comparer.Compare(reqrow, grprow)); Assert.AreEqual(1, comparer.Compare(grprow, reqrow)); Assert.AreEqual(-1, comparer.Compare(reqrow3, grprow)); Assert.AreEqual(1, comparer.Compare(grprow, reqrow3)); }
public void SetUp() { this.permissionService = new Mock <IPermissionService>(); this.session = new Mock <ISession>(); this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object); this.domainOfExpertise = new DomainOfExpertise { ShortName = "SYS", Name = "System" }; this.category_1 = new Category { ShortName = "REQ", Name = "Requirements" }; this.category_2 = new Category { ShortName = "FUNC", Name = "Functions" }; this.requirementsSpecification = new RequirementsSpecification { ShortName = "MRD", Name = "Mission Requirements Document" }; this.requirement = new Requirement { ShortName = "REQ_1", Name = "Requirement 1", Owner = this.domainOfExpertise }; this.requirementsSpecification.Requirement.Add(this.requirement); }
public void Setup() { this.npgsqlTransaction = null; this.securityContext = new Mock <ISecurityContext>(); // There is a chain d -> e -> f this.requirementsGroupA = new RequirementsGroup { Iid = Guid.NewGuid() }; this.requirementsGroupB = new RequirementsGroup { Iid = Guid.NewGuid() }; this.requirementsGroupC = new RequirementsGroup { Iid = Guid.NewGuid() }; this.requirementsGroupF = new RequirementsGroup { Iid = Guid.NewGuid() }; this.requirementsGroupE = new RequirementsGroup { Iid = Guid.NewGuid(), Group = { this.requirementsGroupF.Iid } }; this.requirementsGroupD = new RequirementsGroup { Iid = Guid.NewGuid(), Group = { this.requirementsGroupE.Iid } }; this.requirementsSpecification = new RequirementsSpecification { Iid = Guid.NewGuid(), Group = { this.requirementsGroupA.Iid, this.requirementsGroupB.Iid, this.requirementsGroupC.Iid, this.requirementsGroupD.Iid, this.requirementsGroupE.Iid, this.requirementsGroupF.Iid } }; this.requirementsSpecificationService = new Mock <IRequirementsSpecificationService>(); this.requirementsSpecificationService .Setup( x => x.GetDeep( this.npgsqlTransaction, It.IsAny <string>(), null, It.IsAny <ISecurityContext>())).Returns( new List <RequirementsGroup> { this.requirementsGroupA, this.requirementsGroupB, this.requirementsGroupC, this.requirementsGroupD, this.requirementsGroupE, this.requirementsGroupF }); }
/// <summary> /// Returns the <see cref="Specification"/> representation of a <see cref="RequirementsSpecification"/> /// </summary> /// <param name="requirementsSpecification">The <see cref="RequirementsSpecification"/></param> /// <param name="specificationType">The associated <see cref="SpecificationType"/></param> /// <returns>The <see cref="Specification"/></returns> public Specification ToReqIfSpecification(RequirementsSpecification requirementsSpecification, SpecificationType specificationType) { if (requirementsSpecification == null) { throw new ArgumentNullException("requirementsSpecification"); } var specification = new Specification(); this.SetIdentifiableProperties(specification, requirementsSpecification); specification.Type = specificationType; this.SetCommonAttributeValues(specification, requirementsSpecification); foreach (var parameterValue in requirementsSpecification.ParameterValue) { var attributeDef = specificationType.SpecAttributes.Single(x => x.DatatypeDefinition.Identifier == parameterValue.ParameterType.Iid.ToString()); var value = this.ToReqIfAttributeValue(parameterValue.ParameterType, attributeDef, parameterValue.Value, parameterValue.Scale); specification.Values.Add(value); } // Add extra AttributeValue corresponding to the isDeprecated property var isDeprecatedType = (AttributeDefinitionBoolean)specificationType.SpecAttributes.Single(def => def.DatatypeDefinition == this.BooleanDatatypeDefinition && def.LongName == IsDeprecatedAttributeDefName); var isDeprecated = new AttributeValueBoolean { TheValue = requirementsSpecification.IsDeprecated, Definition = isDeprecatedType }; specification.Values.Add(isDeprecated); return(specification); }
public void VerifyThatGroupPathReturnsExpectedResultWhenGroupedAndNonDefaultDelimiterIsUsed() { var requirementsSpecification = new RequirementsSpecification() { ShortName = "spec" }; var requirement = new Requirement() { ShortName = "req" }; requirementsSpecification.Requirement.Add(requirement); var requirementsGroupA = new RequirementsGroup() { ShortName = "a" }; var requirementsGroupAA = new RequirementsGroup() { ShortName = "a_a" }; requirementsGroupA.Group.Add(requirementsGroupAA); requirementsSpecification.Group.Add(requirementsGroupA); requirement.Group = requirementsGroupAA; Assert.AreEqual("spec;a;a_a;req", requirement.GroupPath(';')); }
/// <summary> /// Add a row representing a <see cref="RequirementsSpecification"/> /// </summary> /// <param name="spec">The <see cref="RequirementsSpecification"/></param> private void AddSpecificationRow(RequirementsSpecification spec) { if (!this.ReqSpecificationRows.Select(x => x.Thing).Contains(spec)) { var row = new RequirementsSpecificationRowViewModel(spec, this.Session, this); this.ReqSpecificationRows.Add(row); } }
public void Setup() { RxApp.MainThreadScheduler = Scheduler.CurrentThread; this.session = new Mock <ISession>(); this.assembler = new Assembler(this.uri); this.cache = this.assembler.Cache; this.permissionService = new Mock <IPermissionService>(); this.permissionService.Setup(x => x.CanRead(It.IsAny <Thing>())).Returns(true); this.permissionService.Setup(x => x.CanWrite(It.IsAny <Thing>())).Returns(true); this.permissionService.Setup(x => x.CanWrite(It.IsAny <ClassKind>(), It.IsAny <Thing>())).Returns(true); this.session = new Mock <ISession>(); this.person = new Person(Guid.NewGuid(), this.cache, this.uri) { ShortName = "test" }; this.participant = new Participant(Guid.NewGuid(), this.cache, this.uri) { SelectedDomain = null, Person = this.person }; this.model = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri); this.modelSetup = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri) { Name = "model" }; this.iteration = new Iteration(Guid.NewGuid(), this.cache, this.uri); this.iterationSetup = new IterationSetup(Guid.NewGuid(), this.cache, this.uri); this.reqSpec = new RequirementsSpecification(Guid.NewGuid(), this.cache, this.uri); this.reqGroup = new RequirementsGroup(Guid.NewGuid(), this.cache, this.uri); this.modelSetup.IterationSetup.Add(this.iterationSetup); this.modelSetup.Participant.Add(this.participant); this.panelNavigation = new Mock <IPanelNavigationService>(); this.dialogNavigation = new Mock <IThingDialogNavigationService>(); this.domain = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri) { Name = "test" }; this.reqSpec.Owner = this.domain; this.iteration.RequirementsSpecification.Add(this.reqSpec); this.iteration.IterationSetup = this.iterationSetup; this.model.EngineeringModelSetup = this.modelSetup; this.model.Iteration.Add(this.iteration); this.reqSpec.Group.Add(this.reqGroup); this.session.Setup(x => x.DataSourceUri).Returns(this.uri.ToString()); this.session.Setup(x => x.ActivePerson).Returns(this.person); this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object); this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> > { { this.iteration, new Tuple <DomainOfExpertise, Participant>(null, this.participant) } }); }
public void Setup() { this.session = new Mock <ISession>(); this.permissionService = new Mock <IPermissionService>(); this.uri = new Uri("http://test.com"); this.siteDir = new SiteDirectory(Guid.NewGuid(), null, this.uri); this.domain = new DomainOfExpertise(Guid.NewGuid(), null, this.uri); this.siteDir.Domain.Add(this.domain); this.modelsetup = new EngineeringModelSetup(Guid.NewGuid(), null, this.uri); this.modelsetup.ActiveDomain.Add(this.domain); this.reqSpec = new RequirementsSpecification(Guid.NewGuid(), null, this.uri); this.reqGroup = new RequirementsGroup(Guid.NewGuid(), null, this.uri); this.engineeringModel = new EngineeringModel(Guid.NewGuid(), null, this.uri) { EngineeringModelSetup = this.modelsetup }; this.iteration = new Iteration(Guid.NewGuid(), null, this.uri); this.requirementsSpecification = new RequirementsSpecification(Guid.NewGuid(), null, this.uri); this.engineeringModelSetup = new EngineeringModelSetup(Guid.NewGuid(), null, this.uri); this.iterationSetup = new IterationSetup(Guid.NewGuid(), null, this.uri); this.iteration.IterationSetup = this.iterationSetup; 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.engineeringModelSetup.ActiveDomain.Add(this.domainOfExpertise); this.engineeringModelSetup.IterationSetup.Add(this.iterationSetup); this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.siteDir); this.session.Setup(x => x.ActivePerson).Returns(person); this.siteDir.Domain.Add(this.domainOfExpertise); this.engineeringModel.Iteration.Add(this.iteration); this.iteration.RequirementsSpecification.Add(this.requirementsSpecification); this.iteration.RequirementsSpecification.Add(this.reqSpec); this.requirementsSpecification.Group.Add(this.reqGroup); this.engineeringModel.EngineeringModelSetup = this.engineeringModelSetup; var transactionContext = TransactionContextResolver.ResolveContext(this.engineeringModel); this.thingTransaction = new ThingTransaction(transactionContext, null); 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()); }
/// <summary> /// Compute all requirement related <see cref="Thing"/> from the <see cref="ReqIF"/> data /// </summary> /// <param name="reqIfData">The <see cref="ReqIF"/> data</param> public void ComputeRequirementThings(ReqIF reqIfData) { foreach (var specification in reqIfData.CoreContent.First().Specifications) { var reqSpec = this.CreateRequirementSpecification(specification); foreach (SpecHierarchy child in specification.Children) { this.ComputeRequirementFromSpecHierarchy(child, reqSpec); } this.Iteration.RequirementsSpecification.Add(reqSpec); } // if any spec-object representing requirement left, create another RequirementSpec to contain them var specObjectLeft = reqIfData.CoreContent.First().SpecObjects.Except(this.specObjectMap.Keys).ToArray(); var uncontainedReq = new List <Requirement>(); foreach (var specObject in specObjectLeft) { var req = this.CreateRequirement(specObject); if (req != null) { uncontainedReq.Add(req); } } if (uncontainedReq.Count != 0) { var spec = new RequirementsSpecification { Owner = this.Owner, ShortName = unresolvedSpec, Name = unresolvedSpec }; foreach (var requirement in uncontainedReq) { spec.Requirement.Add(requirement); } this.specificationMap.Add(new Specification(), spec); this.Iteration.RequirementsSpecification.Add(spec); } foreach (var specRelation in reqIfData.CoreContent.First().SpecRelations) { var relationship = this.CreateBinaryRelationship(specRelation); this.Iteration.Relationship.Add(relationship); } foreach (var relationGroup in reqIfData.CoreContent.First().SpecRelationGroups) { var relationship = this.CreateBinaryRelationship(relationGroup); this.Iteration.Relationship.Add(relationship); } }
/// <summary> /// Removes a row representing a <see cref="RequirementsSpecification"/> /// </summary> /// <param name="spec">The <see cref="RequirementsSpecification"/></param> private void RemoveSpecificationRow(RequirementsSpecification spec) { var row = this.ReqSpecificationRows.SingleOrDefault(x => x.Thing == spec); if (row != null) { this.ReqSpecificationRows.Remove(row); row.Dispose(); } }
public void SetUp() { this.iteration = new Iteration(); this.requirementsSpecification = new RequirementsSpecification() { ShortName = "URD" }; this.iteration.RequirementsSpecification.Add(this.requirementsSpecification); }
public void Verify_that_when_a_RequirementsContainer_has_an_valid_shortname_null_is_returned() { var requirementsSpecification = new RequirementsSpecification(); requirementsSpecification.ShortName = "MRD"; var result = this.shortNamedThingChecker.CheckWhetherTheShortNameIsAValidShortName(requirementsSpecification); Assert.That(result, Is.Empty); }
public void Setup() { this.session = new Mock <ISession>(); this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>(); this.cache = new ConcurrentDictionary <CacheKey, Lazy <Thing> >(); var dal = new Mock <IDal>(); dal.Setup(x => x.MetaDataProvider).Returns(new MetaDataProvider()); this.session.Setup(x => x.DalVersion).Returns(new Version(1, 1, 0)); this.session.Setup(x => x.Dal).Returns(dal.Object); this.siteDir = new SiteDirectory(Guid.NewGuid(), this.cache, this.uri); this.modelsetup = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri); this.iterationsetup = new IterationSetup(Guid.NewGuid(), this.cache, this.uri); this.srdl = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri); this.mrdl = new ModelReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri) { RequiredRdl = this.srdl }; this.siteDir.Model.Add(this.modelsetup); this.modelsetup.IterationSetup.Add(this.iterationsetup); this.siteDir.SiteReferenceDataLibrary.Add(this.srdl); this.modelsetup.RequiredRdl.Add(this.mrdl); this.model = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri) { EngineeringModelSetup = this.modelsetup }; this.iteration = new Iteration(Guid.NewGuid(), this.cache, this.uri) { IterationSetup = this.iterationsetup }; this.requirement = new Requirement(Guid.NewGuid(), this.cache, this.uri); this.relationalExpression = new RelationalExpression(Guid.NewGuid(), this.cache, this.uri); this.parametricConstraint = new ParametricConstraint(Guid.NewGuid(), this.cache, this.uri); this.requirement.ParametricConstraint.Add(this.parametricConstraint); this.parametricConstraint.Expression.Add(this.relationalExpression); this.reqSpec = new RequirementsSpecification(Guid.NewGuid(), this.cache, this.uri); this.reqSpec.Requirement.Add(this.requirement); this.grp = new RequirementsGroup(Guid.NewGuid(), this.cache, this.uri); this.reqSpec.Group.Add(this.grp); this.cache.TryAdd(new CacheKey(this.reqSpec.Iid, null), new Lazy <Thing>(() => this.reqSpec)); this.model.Iteration.Add(this.iteration); this.iteration.RequirementsSpecification.Add(this.reqSpec); this.clone = this.parametricConstraint.Clone(false); var transactionContext = TransactionContextResolver.ResolveContext(this.iteration); this.thingTransaction = new ThingTransaction(transactionContext, this.clone); this.dateRelationalExpression = new RelationalExpression(Guid.NewGuid(), this.cache, this.uri); this.dateRelationalExpression.ParameterType = new DateParameterType(); this.dateRelationalExpression.Value = new ValueArray <string>(new[] { "2019-12-31" }); }
public void Setup() { this.assembler = new Assembler(this.uri); RxApp.MainThreadScheduler = Scheduler.CurrentThread; this.session = new Mock <ISession>(); this.permissionService = new Mock <IPermissionService>(); this.permissionService.Setup(x => x.CanRead(It.IsAny <Thing>())).Returns(true); this.permissionService.Setup(x => x.CanWrite(It.IsAny <Thing>())).Returns(true); this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object); this.session.Setup(x => x.DataSourceUri).Returns(this.uri.ToString); this.model = new EngineeringModel(Guid.NewGuid(), this.assembler.Cache, this.uri); this.modelSetup = new EngineeringModelSetup(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "model" }; this.iteration = new Iteration(Guid.NewGuid(), this.assembler.Cache, this.uri); this.iterationSetup = new IterationSetup(Guid.NewGuid(), this.assembler.Cache, this.uri); this.reqSpec = new RequirementsSpecification(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "rs1", ShortName = "1" }; this.domain = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "test" }; this.reqSpec.Owner = this.domain; this.iteration.RequirementsSpecification.Add(this.reqSpec); this.iteration.IterationSetup = this.iterationSetup; this.model.EngineeringModelSetup = this.modelSetup; this.model.Iteration.Add(this.iteration); this.grp1 = new RequirementsGroup(Guid.NewGuid(), this.assembler.Cache, this.uri); this.grp11 = new RequirementsGroup(Guid.NewGuid(), this.assembler.Cache, this.uri); this.grp2 = new RequirementsGroup(Guid.NewGuid(), this.assembler.Cache, this.uri); this.reqSpec.Group.Add(this.grp1); this.reqSpec.Group.Add(this.grp2); this.grp1.Group.Add(this.grp11); this.req = new Requirement(Guid.NewGuid(), this.assembler.Cache, this.uri) { Name = "requirement1", ShortName = "r1", Owner = this.domain }; this.def = new Definition(Guid.NewGuid(), this.assembler.Cache, this.uri) { Content = "def" }; this.reqSpec.Requirement.Add(this.req); this.req.Definition.Add(this.def); }
public void VerifyThatCloneListIsDifferent2() { var testThing = new RequirementsSpecification(Guid.NewGuid(), null, null); var req = new Requirement(Guid.NewGuid(), null, null); testThing.Requirement.Add(req); var clone = testThing.Clone(false); Assert.AreNotSame(testThing.Group, clone.Group); Assert.AreEqual(testThing.Group.Count, clone.Group.Count); }
public void Verify_that_when_a_RequirementsContainer_has_an_invalid_shortname_a_result_is_returned() { var requirementsSpecification = new RequirementsSpecification(); requirementsSpecification.ShortName = "123 we"; var result = this.shortNamedThingChecker.CheckWhetherTheShortNameIsAValidShortName(requirementsSpecification).Single(); Assert.That(result.Id, Is.EqualTo("MA-0010")); Assert.That(result.Thing, Is.EqualTo(requirementsSpecification)); Assert.That(result.Description, Is.EqualTo("The ShortName: 123 we is invalid. The ShortName must start with a letter and not contain any spaces or non alphanumeric characters.")); }
public void VerifyThatPathReturnsShortNameOfSpec() { var iteration = new Iteration(); var spec = new RequirementsSpecification() { ShortName = "spec" }; iteration.RequirementsSpecification.Add(spec); Assert.AreEqual("spec", spec.Path()); }
public void SetUp() { this.parametricConstraint = new ParametricConstraint(Guid.NewGuid(), null, null); this.relationalExpression = new RelationalExpressionBuilder() .WithSimpleQuantityKindParameterType() .WithValue("10") .Build(); this.parametricConstraint.Expression.Add(this.relationalExpression); this.requirement1 = new Requirement(Guid.NewGuid(), null, null); this.requirement1.ParametricConstraint.Add(this.parametricConstraint); this.requirementsSpecification = new RequirementsSpecification(Guid.NewGuid(), null, null); this.requirementsSpecification.Requirement.Add(this.requirement1); this.requirementsGroup1 = new RequirementsGroup(Guid.NewGuid(), null, null); this.requirementsGroup2 = new RequirementsGroup(Guid.NewGuid(), null, null); this.requirementsSpecification.Group.Add(this.requirementsGroup1); this.requirementsGroup1.Group.Add(this.requirementsGroup2); this.requirement1.Group = this.requirementsGroup1; this.requirementsContainerVerifier = new RequirementsContainerVerifier(this.requirementsSpecification); this.requirementsGroupVerifier1 = new RequirementsContainerVerifier(this.requirementsGroup1); this.requirementsGroupVerifier2 = new RequirementsContainerVerifier(this.requirementsGroup2); this.iteration = new Iteration(Guid.NewGuid(), null, null); this.elementDefinition = new ElementDefinition(Guid.NewGuid(), null, null); var elementUsage = new ElementUsage(Guid.NewGuid(), null, null) { ElementDefinition = this.elementDefinition }; this.elementDefinition.ContainedElement.Add(elementUsage); var parameter = new ParameterBuilder() .WithSimpleQuantityKindParameterType() .WithValue("10") .AddToElementDefinition(this.elementDefinition) .Build(); this.iteration.Element.Add(this.elementDefinition); this.RegisterBinaryRelationShip(parameter, this.relationalExpression); }
/// <summary> /// Create 10-25 <see cref="Thing"/>s from the <see cref="SpecHierarchy"/> /// </summary> /// <param name="specHierarchy">The <see cref="SpecHierarchy"/></param> /// <param name="reqContainer">The <see cref="RequirementsContainer"/> representing the current level of requirement</param> private void ComputeRequirementFromSpecHierarchy(SpecHierarchy specHierarchy, RequirementsContainer reqContainer) { // create a group if the specHierarchy has children if (specHierarchy.Children.Any()) { var group = this.CreateRequirementGroup(specHierarchy.Object); reqContainer.Group.Add(group); foreach (var hierarchy in specHierarchy.Children) { this.ComputeRequirementFromSpecHierarchy(hierarchy, group); } } SpecTypeMap specTypeMapping; if (!this.typeMap.TryGetValue(specHierarchy.Object.Type, out specTypeMapping)) { // The instance of this type shall not be generated return; } var specObjectTypeMap = (SpecObjectTypeMap)specTypeMapping; if (!specObjectTypeMap.IsRequirement) { var group = this.CreateRequirementGroup(specHierarchy.Object); reqContainer.Group.Add(group); return; } var requirement = this.CreateRequirement(specHierarchy.Object); if (requirement != null) { var group = reqContainer as RequirementsGroup; if (group != null) { requirement.Group = group; } RequirementsSpecification container = null; var specification = reqContainer as RequirementsSpecification; container = specification ?? reqContainer.GetContainerOfType <RequirementsSpecification>(); if (container == null) { throw new InvalidOperationException("The RequirementsSpecication container is null."); } container.Requirement.Add(requirement); } }
public void VerifyThatGroupPathReturnsExpectedResultWhenNotGroupedAndNonDefaultDelimiterIsUsed() { var requirementsSpecification = new RequirementsSpecification() { ShortName = "spec" }; var requirement = new Requirement() { ShortName = "req" }; requirementsSpecification.Requirement.Add(requirement); Assert.AreEqual("spec,req", requirement.GroupPath(',')); }
/// <summary> /// Creates a <see cref="List{Thing}"/> that contains <see cref="RequirementsSpecification"/> and its containing /// <see cref="RequirementsGroup"/> and <see cref="Requirement"/> /// </summary> /// <param name="requirementsSpecification"></param> /// <returns> /// A <see cref="List{Thing}"/> ordered by <see cref="IBreadCrumb"/> /// </returns> private IEnumerable <Thing> CreateSortedContent(RequirementsSpecification requirementsSpecification) { var things = new List <Thing>(); things.Add(requirementsSpecification); var allGroups = requirementsSpecification.GetAllContainedGroups(); things.AddRange(allGroups); things.AddRange(requirementsSpecification.Requirement); var contentComparer = new RequirementsSpecificationContentComparer(); things.Sort(contentComparer); return(things); }
/// <summary> /// Renders a <see cref="RequirementsSpecification"/> as HTML report /// </summary> /// <returns> /// an HTML string that represents the <see cref="RequirementsSpecification"/> in HTML /// </returns> public string Render(RequirementsSpecification requirementsSpecification) { if (requirementsSpecification == null) { throw new ArgumentNullException("requirementsSpecification", "The RequirementsSpecification may not be null"); } var htmlTemplate = this.ReadEmbeddedTemplate(); var template = Template.Parse(htmlTemplate); var sortedContent = this.CreateSortedContent(requirementsSpecification); var htmlReport = template.Render(DotLiquid.Hash.FromAnonymousObject(new { content = sortedContent })); return(htmlReport); }
/// <summary> /// Create a <see cref="RequirementsSpecification"/> from a <see cref="Specification"/> /// </summary> /// <param name="specification">The <see cref="Specification"/></param> /// <returns>The created <see cref="RequirementsSpecification"/></returns> private RequirementsSpecification CreateRequirementSpecification(Specification specification) { var type = this.typeMap[specification.Type]; var number = this.specificationMap.Count + 1; var spec = new RequirementsSpecification { Owner = this.Owner, ShortName = SpecPrefix + number.ToString("0000"), Name = string.IsNullOrWhiteSpace(specification.LongName) ? SpecPrefix + number.ToString("0000") : specification.LongName }; spec.Category.AddRange(type.Categories); foreach (var value in specification.Values) { var attributeMap = type.AttributeDefinitionMap.SingleOrDefault(x => x.AttributeDefinition == value.AttributeDefinition); if (attributeMap == null || attributeMap.MapKind == AttributeDefinitionMapKind.NONE) { continue; } string theValue; switch (attributeMap.MapKind) { case AttributeDefinitionMapKind.FIRST_DEFINITION: this.SetDefinition(spec, value); break; case AttributeDefinitionMapKind.NAME: theValue = this.GetAttributeValue(value); spec.Name = theValue; break; case AttributeDefinitionMapKind.SHORTNAME: theValue = this.GetAttributeValue(value); spec.ShortName = theValue; break; case AttributeDefinitionMapKind.PARAMETER_VALUE: this.SetParameterValue(spec, value); break; } } this.specificationMap.Add(specification, spec); return(spec); }
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); }
public void SetUp() { this.requirementRuleChecker = new RequirementRuleChecker(); this.requirementsSpecification = new RequirementsSpecification(); this.requirement_1 = new Requirement { Iid = Guid.Parse("0816f4b2-7715-47be-88c1-514530bca0c2") }; this.requirement_2 = new Requirement { Iid = Guid.Parse("998f7f11-0153-4331-b7ee-33e36b278d3a") }; this.requirement_3 = new Requirement { Iid = Guid.Parse("ca3a7e32-4862-42c9-8435-b4f7dbdfac83") }; this.requirementsSpecification.Requirement.Add(this.requirement_1); this.requirementsSpecification.Requirement.Add(this.requirement_2); this.requirementsSpecification.Requirement.Add(this.requirement_3); }
public void VerifyThatRequirementSpecificationMayBeAddedOrRemoved() { var revision = typeof(Thing).GetProperty("RevisionNumber"); var vm = new RequirementsBrowserViewModel(this.iteration, this.session.Object, this.dialogNavigation.Object, this.panelNavigation.Object, null, null); Assert.AreEqual(1, vm.ReqSpecificationRows.Count); var reqspec2 = new RequirementsSpecification(Guid.NewGuid(), this.cache, this.uri); this.iteration.RequirementsSpecification.Add(reqspec2); revision.SetValue(this.iteration, 2); CDPMessageBus.Current.SendObjectChangeEvent(this.iteration, EventKind.Updated); Assert.AreEqual(2, vm.ReqSpecificationRows.Count); this.iteration.RequirementsSpecification.Remove(reqspec2); revision.SetValue(this.iteration, 3); CDPMessageBus.Current.SendObjectChangeEvent(this.iteration, EventKind.Updated); Assert.AreEqual(1, vm.ReqSpecificationRows.Count); }