public void VerifyThatIfElementDefinitionIsCategprizedAndParametersAreMissionAViolationIsReturned() { var rule = new ParameterizedCategoryRule(Guid.NewGuid(), this.cache, this.uri) { Category = this.productCategory }; rule.ParameterType.Add(this.textParameterType); rule.ParameterType.Add(this.simpleQuantityKind); var elementDefinition = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri) { Name = "Battery", ShortName = "BAT" }; elementDefinition.Category.Add(this.batteryCategory); this.iteration.Element.Add(elementDefinition); var violations = rule.Verify(this.iteration); Assert.IsNotEmpty(violations); var violation = violations.Single(); violation.ViolatingThing.Contains(elementDefinition.Iid); Assert.IsTrue(violation.Description.Contains("does not contain parameters that reference the following parameter types")); }
public void VerifyThatContainerIsSetForRuleUpdate() { var rule = new ParameterizedCategoryRule(Guid.NewGuid(), null, this.uri); var vm = new ParameterizedCategoryRuleDialogViewModel(rule, this.transaction, this.session.Object, true, ThingDialogKind.Create, this.dialogService.Object); Assert.AreEqual(2, vm.PossibleContainer.Count); }
public void VerifyThatAllPropertiesArePopulated() { var shortname = "shortname"; var name = "name"; var rule = new ParameterizedCategoryRule(Guid.NewGuid(), null, this.uri); rule.ShortName = shortname; rule.Name = name; rule.Category = this.cat; var pt = new TextParameterType(Guid.NewGuid(), null, this.uri); this.siteRdl.ParameterType.Add(pt); this.siteRdl.Rule.Add(rule); rule.ParameterType.Add(this.siteRdl.ParameterType.First()); var vm = new ParameterizedCategoryRuleDialogViewModel(rule, this.transaction, this.session.Object, true, ThingDialogKind.Inspect, this.dialogService.Object); Assert.AreEqual(shortname, vm.ShortName); Assert.AreEqual(name, vm.Name); Assert.AreEqual(1, vm.PossibleCategory.Count); Assert.AreEqual(this.cat, vm.PossibleCategory.First()); Assert.AreEqual(this.cat, vm.SelectedCategory); Assert.AreEqual(1, vm.PossibleParameterType.Count); Assert.AreEqual(pt, vm.PossibleParameterType.First()); Assert.AreEqual(1, vm.ParameterType.Count); Assert.AreEqual(pt, vm.ParameterType.First()); Assert.IsTrue(vm.OkCanExecute); }
public void VerifyDialogValidation() { var rule = new ParameterizedCategoryRule(Guid.NewGuid(), null, this.uri); var vm = new ParameterizedCategoryRuleDialogViewModel(rule, this.transaction, this.session.Object, true, ThingDialogKind.Inspect, this.dialogService.Object); Assert.IsFalse(vm.OkCanExecute); }
public void VerifyThatIfElementDefinitionContainsCorrectParametersNoViolationIsReturned() { var rule = new ParameterizedCategoryRule(Guid.NewGuid(), this.cache, this.uri) { Category = this.productCategory }; rule.ParameterType.Add(this.textParameterType); rule.ParameterType.Add(this.simpleQuantityKind); var elementDefinition = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri) { Name = "Battery", ShortName = "BAT" }; var textParameter = new Parameter(Guid.NewGuid(), this.cache, this.uri); textParameter.ParameterType = this.textParameterType; var simpleParameter = new Parameter(Guid.NewGuid(), this.cache, this.uri); simpleParameter.ParameterType = simpleQuantityKind; elementDefinition.Parameter.Add(textParameter); elementDefinition.Parameter.Add(simpleParameter); elementDefinition.Category.Add(this.batteryCategory); this.iteration.Element.Add(elementDefinition); var violations = rule.Verify(this.iteration); Assert.IsEmpty(violations); }
public void VerifyThatIfNoElementDefinitionsAreContainedByIterationNoViolationIsReturned() { var rule = new ParameterizedCategoryRule(Guid.NewGuid(), this.cache, this.uri) { Category = this.productCategory }; var violations = rule.Verify(this.iteration); Assert.IsEmpty(violations); }
public void SetUp() { this.siteReferenceDataLibrary = new SiteReferenceDataLibrary(); this.parameterizedCategoryRule = new ParameterizedCategoryRule { Iid = Guid.Parse("27fc9848-a2cd-4ecd-a4d0-dae1f87cb659"), ShortName = "RULE" }; this.siteReferenceDataLibrary.Rule.Add(this.parameterizedCategoryRule); this.parameterizedCategoryRuleRuleChecker = new ParameterizedCategoryRuleRuleChecker(); }
public void VerifyThatExistingMapIsApplied() { var category = new Category(Guid.NewGuid(), this.assembler.Cache, this.uri); var rule = new ParameterizedCategoryRule(Guid.NewGuid(), this.assembler.Cache, this.uri) { Category = category }; var binaryRelationshipRule = new BinaryRelationshipRule(Guid.NewGuid(), this.assembler.Cache, this.uri) { RelationshipCategory = category, TargetCategory = category, SourceCategory = category }; var categoryVm = new CategoryComboBoxItemViewModel(category, true); Dictionary <RelationGroupType, RelationGroupTypeMap> RelationGroupTypeMaps = null; var datatypeDefinitionMaps = new Dictionary <DatatypeDefinition, DatatypeDefinitionMap> { { this.stringDatadef, new DatatypeDefinitionMap(this.stringDatadef, this.pt, null) } }; var newDialog = new RelationGroupTypeMappingDialogViewModel(new List <RelationGroupType> { this.spectype }, RelationGroupTypeMaps, datatypeDefinitionMaps, this.iteration, this.session.Object, this.thingDialogNavigationService.Object, "en"); Assert.IsEmpty(newDialog.SpecTypes.SelectMany(x => x.SelectedCategories)); Assert.IsNull(newDialog.SpecTypes[0].SelectedRules); Assert.IsNull(newDialog.SpecTypes[0].SelectedBinaryRelationshipRules); var row = newDialog.SpecTypes.First(); row.PossibleBinaryRelationshipRules.Add(binaryRelationshipRule); row.PossibleCategories.Add(categoryVm); row.PossibleRules.Add(rule); RelationGroupTypeMaps = new Dictionary <RelationGroupType, RelationGroupTypeMap>() { { this.spectype, new RelationGroupTypeMap( this.spectype, new[] { rule }, new[] { category }, new List <AttributeDefinitionMap>() { new AttributeDefinitionMap(this.attribute, AttributeDefinitionMapKind.SHORTNAME) }, new[] { binaryRelationshipRule }) } }; newDialog.PopulateRelationGroupTypeMapProperties(RelationGroupTypeMaps); Assert.IsNotEmpty(newDialog.SpecTypes.SelectMany(x => x.SelectedCategories)); Assert.IsNotEmpty(newDialog.SpecTypes.SelectMany(x => x.SelectedRules)); Assert.IsNotEmpty(newDialog.SpecTypes.SelectMany(x => x.SelectedBinaryRelationshipRules)); }
/// <summary> /// Initializes a new instance of the <see cref="ParameterizedCategoryRuleDialogViewModel"/> class. /// </summary> /// <param name="parameterizedCategoryRule"> /// The <see cref="CDP4Common.SiteDirectoryData.ParameterizedCategoryRule"/> 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="CDP4Common.CommonData.Thing"/> is to be added or updated /// </param> /// <param name="isRoot"> /// Assert if this <see cref="ParameterizedCategoryRuleDialogViewModel"/> is the root of all <see cref="IThingDialogViewModel"/> /// </param> /// <param name="dialogKind"> /// The kind of operation this <see cref="ParameterizedCategoryRuleDialogViewModel"/> 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 Container <see cref="CDP4Common.CommonData.Thing"/> of the created <see cref="CDP4Common.SiteDirectoryData.ParameterizedCategoryRule"/> /// </param> /// <param name="chainOfContainers"> /// The optional chain of containers that contains the <paramref name="container"/> argument /// </param> public ParameterizedCategoryRuleDialogViewModel(ParameterizedCategoryRule parameterizedCategoryRule, IThingTransaction transaction, ISession session, bool isRoot, ThingDialogKind dialogKind, IThingDialogNavigationService thingDialogNavigationService, Thing container = null, IEnumerable <Thing> chainOfContainers = null) : base(parameterizedCategoryRule, transaction, session, isRoot, dialogKind, thingDialogNavigationService, container, chainOfContainers) { this.WhenAnyValue(vm => vm.Container).Subscribe(_ => { this.PopulatePossibleCategory(); this.PopulatePossibleParameterTypes(); this.UpdateOkCanExecute(); }); this.WhenAnyValue(vm => vm.ParameterType.Count).Subscribe(_ => this.UpdateOkCanExecute()); }
public void VerifyThatContainerIsSetForRuleInspect() { var expectedContainers = new List <ReferenceDataLibrary> { this.siteRdl }; var rule = new ParameterizedCategoryRule(Guid.NewGuid(), null, this.uri); this.siteRdl.Rule.Add(rule); var vm = new ParameterizedCategoryRuleDialogViewModel(rule, this.transaction, this.session.Object, true, ThingDialogKind.Inspect, this.dialogService.Object); CollectionAssert.AreEquivalent(expectedContainers, vm.PossibleContainer); }
public void VerifyUpdateOkCanExecute() { var rule = new ParameterizedCategoryRule(Guid.NewGuid(), null, this.uri); var vm = new ParameterizedCategoryRuleDialogViewModel(rule, this.transaction, this.session.Object, true, ThingDialogKind.Create, this.dialogService.Object); Assert.IsFalse(vm.OkCanExecute); vm.Container = this.siteRdl; Assert.IsFalse(vm.OkCanExecute); vm.SelectedCategory = this.cat; Assert.IsFalse(vm.OkCanExecute); var pt = new TextParameterType(Guid.NewGuid(), null, this.uri); vm.ParameterType.Add(pt); Assert.IsTrue(vm.OkCanExecute); }
public void VerifyThatIfNoParameterTypesSpecifiedNoViolationIsReturned() { var rule = new ParameterizedCategoryRule(Guid.NewGuid(), this.cache, this.uri) { Category = this.productCategory }; var elementDefinition = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri) { Name = "Battery", ShortName = "BAT" }; elementDefinition.Category.Add(this.batteryCategory); this.iteration.Element.Add(elementDefinition); var violations = rule.Verify(this.iteration); Assert.IsEmpty(violations); }
/// <summary> /// Serialize the <see cref="ParameterizedCategoryRule"/> /// </summary> /// <param name="parameterizedCategoryRule">The <see cref="ParameterizedCategoryRule"/> to serialize</param> /// <returns>The <see cref="JObject"/></returns> private JObject Serialize(ParameterizedCategoryRule parameterizedCategoryRule) { var jsonObject = new JObject(); jsonObject.Add("alias", this.PropertySerializerMap["alias"](parameterizedCategoryRule.Alias.OrderBy(x => x, this.guidComparer))); jsonObject.Add("category", this.PropertySerializerMap["category"](parameterizedCategoryRule.Category)); jsonObject.Add("classKind", this.PropertySerializerMap["classKind"](Enum.GetName(typeof(CDP4Common.CommonData.ClassKind), parameterizedCategoryRule.ClassKind))); jsonObject.Add("definition", this.PropertySerializerMap["definition"](parameterizedCategoryRule.Definition.OrderBy(x => x, this.guidComparer))); jsonObject.Add("excludedDomain", this.PropertySerializerMap["excludedDomain"](parameterizedCategoryRule.ExcludedDomain.OrderBy(x => x, this.guidComparer))); jsonObject.Add("excludedPerson", this.PropertySerializerMap["excludedPerson"](parameterizedCategoryRule.ExcludedPerson.OrderBy(x => x, this.guidComparer))); jsonObject.Add("hyperLink", this.PropertySerializerMap["hyperLink"](parameterizedCategoryRule.HyperLink.OrderBy(x => x, this.guidComparer))); jsonObject.Add("iid", this.PropertySerializerMap["iid"](parameterizedCategoryRule.Iid)); jsonObject.Add("isDeprecated", this.PropertySerializerMap["isDeprecated"](parameterizedCategoryRule.IsDeprecated)); jsonObject.Add("modifiedOn", this.PropertySerializerMap["modifiedOn"](parameterizedCategoryRule.ModifiedOn)); jsonObject.Add("name", this.PropertySerializerMap["name"](parameterizedCategoryRule.Name)); jsonObject.Add("parameterType", this.PropertySerializerMap["parameterType"](parameterizedCategoryRule.ParameterType.OrderBy(x => x, this.guidComparer))); jsonObject.Add("revisionNumber", this.PropertySerializerMap["revisionNumber"](parameterizedCategoryRule.RevisionNumber)); jsonObject.Add("shortName", this.PropertySerializerMap["shortName"](parameterizedCategoryRule.ShortName)); jsonObject.Add("thingPreference", this.PropertySerializerMap["thingPreference"](parameterizedCategoryRule.ThingPreference)); return(jsonObject); }
public void VerifyThatPropertiesAreSetAndContainRowsArePopulated() { var ruleVerificationList = new RuleVerificationList(Guid.NewGuid(), this.cache, this.uri) { Owner = this.domain }; this.iteration.RuleVerificationList.Add(ruleVerificationList); var listRowViewModel = new RuleVerificationListRowViewModel(ruleVerificationList, this.session.Object, null); Assert.IsEmpty(listRowViewModel.ContainedRows); // add a rule verification var builtInRuleVerification = new BuiltInRuleVerification(Guid.NewGuid(), this.cache, this.uri) { Name = "BuiltIn", Status = RuleVerificationStatusKind.INCONCLUSIVE, IsActive = true }; ruleVerificationList.RuleVerification.Add(builtInRuleVerification); this.revision.SetValue(ruleVerificationList, 2); CDPMessageBus.Current.SendObjectChangeEvent(ruleVerificationList, EventKind.Updated); var builtInRuleVerificationRow = listRowViewModel.ContainedRows.Single(x => x.Thing == builtInRuleVerification); Assert.AreEqual(builtInRuleVerification, builtInRuleVerificationRow.Thing); Assert.AreEqual("BuiltIn", ((RuleVerification)builtInRuleVerificationRow.Thing).Name); // add a rule verification var parameterizedCategoryRule = new ParameterizedCategoryRule(Guid.NewGuid(), this.cache, this.uri) { Name = "Parameterized Category Rule" }; var userRuleVerification = new UserRuleVerification(Guid.NewGuid(), this.cache, this.uri) { Status = RuleVerificationStatusKind.INCONCLUSIVE, IsActive = true, Rule = parameterizedCategoryRule }; ruleVerificationList.RuleVerification.Add(userRuleVerification); this.revision.SetValue(ruleVerificationList, 3); CDPMessageBus.Current.SendObjectChangeEvent(ruleVerificationList, EventKind.Updated); var userRuleVerificationRow = listRowViewModel.ContainedRows.Single(x => x.Thing == userRuleVerification); Assert.AreEqual(userRuleVerification, userRuleVerificationRow.Thing); Assert.AreEqual("Parameterized Category Rule", ((RuleVerification)userRuleVerificationRow.Thing).Name); // Remove a rule verification ruleVerificationList.RuleVerification.Remove(builtInRuleVerification); this.revision.SetValue(ruleVerificationList, 4); CDPMessageBus.Current.SendObjectChangeEvent(ruleVerificationList, EventKind.Updated); Assert.AreEqual(1, listRowViewModel.ContainedRows.Count); // Remove a rule verification ruleVerificationList.RuleVerification.Remove(userRuleVerification); this.revision.SetValue(ruleVerificationList, 5); CDPMessageBus.Current.SendObjectChangeEvent(ruleVerificationList, EventKind.Updated); Assert.AreEqual(0, listRowViewModel.ContainedRows.Count); }
public void VerifyThatInvalidContainerThrowsException() { var rule = new ParameterizedCategoryRule(Guid.NewGuid(), null, this.uri); Assert.Throws <ArgumentException>(() => new ParameterizedCategoryRuleDialogViewModel(rule, this.transaction, this.session.Object, true, ThingDialogKind.Inspect, this.dialogService.Object, this.siteDir)); }
public void VerifyThatIfCategoryNotSetOnRuleInvalidOperationIsThrown() { var rule = new ParameterizedCategoryRule(Guid.NewGuid(), this.cache, this.uri); Assert.Throws<InvalidOperationException>(() => rule.Verify(this.iteration)); }
private void SetupThings() { this.sitedir = new SiteDirectory(Guid.NewGuid(), this.assembler.Cache, this.uri); this.modelsetup = new EngineeringModelSetup(Guid.NewGuid(), this.assembler.Cache, this.uri); this.iterationSetup = new IterationSetup(Guid.NewGuid(), this.assembler.Cache, this.uri); this.domain = new DomainOfExpertise(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.sitedir.SiteReferenceDataLibrary.Add(this.srdl); this.modelsetup.RequiredRdl.Add(this.mrdl); 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.sitedir.Model.Add(this.modelsetup); this.modelsetup.IterationSetup.Add(this.iterationSetup); this.sitedir.Domain.Add(this.domain); this.model.Iteration.Add(this.iteration); this.person = new Person(Guid.NewGuid(), this.assembler.Cache, this.uri); this.participant = new Participant(Guid.NewGuid(), this.assembler.Cache, this.uri) { Person = this.person }; this.sitedir.Person.Add(this.person); this.modelsetup.Participant.Add(this.participant); this.pt = new BooleanParameterType(Guid.NewGuid(), this.assembler.Cache, this.uri); this.srdl.ParameterType.Add(this.pt); this.specCategory = new Category(Guid.NewGuid(), this.assembler.Cache, this.uri); this.specCategory.PermissibleClass.Add(ClassKind.RequirementsSpecification); this.reqCateory = new Category(Guid.NewGuid(), this.assembler.Cache, this.uri); this.reqCateory.PermissibleClass.Add(ClassKind.Requirement); this.specRelationCategory = new Category(Guid.NewGuid(), this.assembler.Cache, this.uri); this.specRelationCategory.PermissibleClass.Add(ClassKind.BinaryRelationship); this.relationGroupCategory = new Category(Guid.NewGuid(), this.assembler.Cache, this.uri); this.relationGroupCategory.PermissibleClass.Add(ClassKind.BinaryRelationship); this.specLinkCategory = new Category(Guid.NewGuid(), this.assembler.Cache, this.uri); this.specLinkCategory.PermissibleClass.Add(ClassKind.BinaryRelationship); this.reqLinkCategory = new Category(Guid.NewGuid(), this.assembler.Cache, this.uri); this.reqLinkCategory.PermissibleClass.Add(ClassKind.BinaryRelationship); this.srdl.DefinedCategory.Add(this.specCategory); this.srdl.DefinedCategory.Add(this.reqCateory); this.srdl.DefinedCategory.Add(this.specRelationCategory); this.srdl.DefinedCategory.Add(this.relationGroupCategory); this.specRule = new BinaryRelationshipRule(Guid.NewGuid(), this.assembler.Cache, this.uri); this.specRule.SourceCategory = this.specCategory; this.specRule.TargetCategory = this.specCategory; this.specRule.RelationshipCategory = this.specLinkCategory; this.reqRule = new BinaryRelationshipRule(Guid.NewGuid(), this.assembler.Cache, this.uri); this.srdl.Rule.Add(this.specRule); this.srdl.Rule.Add(this.reqRule); this.reqRule.RelationshipCategory = this.reqLinkCategory; this.parameterRule = new ParameterizedCategoryRule(Guid.NewGuid(), this.assembler.Cache, this.uri); this.parameterRule.ParameterType.Add(this.pt); this.parameterRule.Category = this.specRelationCategory; this.srdl.Rule.Add(this.parameterRule); }
/// <summary> /// Persist the <see cref="ParameterizedCategoryRule"/> containment tree to the ORM layer. Update if it already exists. /// This is typically used during the import of existing data to the Database. /// </summary> /// <param name="transaction"> /// The current <see cref="NpgsqlTransaction"/> to the database. /// </param> /// <param name="partition"> /// The database partition (schema) where the requested resource will be stored. /// </param> /// <param name="parameterizedCategoryRule"> /// The <see cref="ParameterizedCategoryRule"/> instance to persist. /// </param> /// <returns> /// True if the persistence was successful. /// </returns> private bool UpsertContainment(NpgsqlTransaction transaction, string partition, ParameterizedCategoryRule parameterizedCategoryRule) { var results = new List <bool>(); foreach (var alias in this.ResolveFromRequestCache(parameterizedCategoryRule.Alias)) { results.Add(this.AliasService.UpsertConcept(transaction, partition, alias, parameterizedCategoryRule)); } foreach (var definition in this.ResolveFromRequestCache(parameterizedCategoryRule.Definition)) { results.Add(this.DefinitionService.UpsertConcept(transaction, partition, definition, parameterizedCategoryRule)); } foreach (var hyperLink in this.ResolveFromRequestCache(parameterizedCategoryRule.HyperLink)) { results.Add(this.HyperLinkService.UpsertConcept(transaction, partition, hyperLink, parameterizedCategoryRule)); } return(results.All(x => x)); }
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); }
public void VerifyThatNullIterationThrowsArgumentException() { var rule = new ParameterizedCategoryRule(Guid.NewGuid(), this.cache, this.uri); Assert.Throws<ArgumentNullException>(() => rule.Verify(null)); }
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 }); }
private void SetupData() { var datatypeDefinition0 = new DatatypeDefinitionString() { Identifier = this.reqIf.CoreContent?.DataTypes[0].Identifier }; var datatypeDefinition1 = new DatatypeDefinitionString() { Identifier = this.reqIf.CoreContent?.DataTypes[1].Identifier }; var specObjectType0 = new SpecObjectType() { Identifier = this.reqIf.CoreContent?.SpecTypes.OfType <SpecObjectType>().ToList()[0].Identifier }; var specObjectType1 = new SpecObjectType() { Identifier = this.reqIf.CoreContent?.SpecTypes.OfType <SpecObjectType>().ToList()[1].Identifier }; var specRelationType0 = new SpecRelationType() { Identifier = this.reqIf.CoreContent?.SpecTypes.OfType <SpecRelationType>().ToList()[0].Identifier }; this.rule0 = new ParameterizedCategoryRule(Guid.NewGuid(), this.session.Assembler.Cache, new Uri(this.uri)); this.rule1 = new ParameterizedCategoryRule(Guid.NewGuid(), this.session.Assembler.Cache, new Uri(this.uri)); this.session.Assembler.Cache.TryAdd(new CacheKey(this.rule0.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.rule0)); this.session.Assembler.Cache.TryAdd(new CacheKey(this.rule1.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.rule1)); this.category0 = new Category(Guid.NewGuid(), this.session.Assembler.Cache, new Uri(this.uri)); this.category1 = new Category(Guid.NewGuid(), this.session.Assembler.Cache, new Uri(this.uri)); this.session.Assembler.Cache.TryAdd(new CacheKey(this.category0.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.category0)); this.session.Assembler.Cache.TryAdd(new CacheKey(this.category1.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.category1)); var specObjectTypeMap0 = new SpecObjectTypeMap(specObjectType0, new[] { this.rule0, this.rule1 }, new[] { this.category0, this.category1 }, new[] { new AttributeDefinitionMap(new AttributeDefinitionString() { Identifier = this.reqIf.CoreContent?.SpecTypes[0].SpecAttributes[0].Identifier }, AttributeDefinitionMapKind.NAME), new AttributeDefinitionMap(new AttributeDefinitionString() { Identifier = this.reqIf.CoreContent?.SpecTypes[0].SpecAttributes[1].Identifier }, AttributeDefinitionMapKind.SHORTNAME) }, true); var specObjectTypeMap1 = new SpecObjectTypeMap(specObjectType1, new[] { this.rule0, this.rule1 }, new[] { this.category0, this.category1 }, new[] { new AttributeDefinitionMap(new AttributeDefinitionString() { Identifier = this.reqIf.CoreContent?.SpecTypes[0].SpecAttributes[0].Identifier }, AttributeDefinitionMapKind.NAME), new AttributeDefinitionMap(new AttributeDefinitionString() { Identifier = this.reqIf.CoreContent?.SpecTypes[0].SpecAttributes[1].Identifier }, AttributeDefinitionMapKind.SHORTNAME) }, true); this.binaryRelationshipRule0 = new BinaryRelationshipRule(Guid.NewGuid(), this.session.Assembler.Cache, new Uri(this.uri)); this.binaryRelationshipRule1 = new BinaryRelationshipRule(Guid.NewGuid(), this.session.Assembler.Cache, new Uri(this.uri)); this.session.Assembler.Cache.TryAdd(new CacheKey(this.binaryRelationshipRule0.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.binaryRelationshipRule0)); this.session.Assembler.Cache.TryAdd(new CacheKey(this.binaryRelationshipRule1.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.binaryRelationshipRule1)); var specRelationTypeMap0 = new SpecRelationTypeMap(specRelationType0, new[] { this.rule0, this.rule1 }, new[] { this.category0, this.category1 }, new[] { new AttributeDefinitionMap(new AttributeDefinitionString() { Identifier = this.reqIf.CoreContent?.SpecTypes[0].SpecAttributes[0].Identifier }, AttributeDefinitionMapKind.NAME), new AttributeDefinitionMap(new AttributeDefinitionString() { Identifier = this.reqIf.CoreContent?.SpecTypes[0].SpecAttributes[1].Identifier }, AttributeDefinitionMapKind.SHORTNAME) }, new[] { this.binaryRelationshipRule0, this.binaryRelationshipRule1 }); var relationGroupType0 = new RelationGroupType() { Identifier = this.reqIf.CoreContent?.SpecTypes.OfType <SpecRelationType>().ToList()[0].Identifier }; var relationGroupTypeMap0 = new RelationGroupTypeMap(relationGroupType0, new[] { this.rule0, this.rule1 }, new[] { this.category0, this.category1 }, new[] { new AttributeDefinitionMap(new AttributeDefinitionString() { Identifier = this.reqIf.CoreContent?.SpecTypes[0].SpecAttributes[0].Identifier }, AttributeDefinitionMapKind.NAME), new AttributeDefinitionMap(new AttributeDefinitionString() { Identifier = this.reqIf.CoreContent?.SpecTypes[0].SpecAttributes[1].Identifier }, AttributeDefinitionMapKind.SHORTNAME) }, new[] { this.binaryRelationshipRule0, this.binaryRelationshipRule1 }); var specificationType0 = this.reqIf.CoreContent?.SpecTypes.OfType <SpecificationType>().First(); var specificationTypeMap0 = new SpecTypeMap(specificationType0, new[] { this.rule0, this.rule1 }, new[] { this.category0, this.category1 }, new[] { new AttributeDefinitionMap(new AttributeDefinitionString() { Identifier = this.reqIf.CoreContent?.SpecTypes[0].SpecAttributes[0].Identifier }, AttributeDefinitionMapKind.NAME), new AttributeDefinitionMap(new AttributeDefinitionString() { Identifier = this.reqIf.CoreContent?.SpecTypes[0].SpecAttributes[1].Identifier }, AttributeDefinitionMapKind.SHORTNAME) }); this.parameterType0 = new TextParameterType(Guid.NewGuid(), this.session.Assembler.Cache, new Uri(this.uri)); this.parameterType1 = new TextParameterType(Guid.NewGuid(), this.session.Assembler.Cache, new Uri(this.uri)); this.session.Assembler.Cache.TryAdd(new CacheKey(this.parameterType0.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.parameterType0)); this.session.Assembler.Cache.TryAdd(new CacheKey(this.parameterType1.Iid, this.iteration.Iid), new Lazy <Thing>(() => this.parameterType1)); this.mappingConfiguration = new ImportMappingConfiguration() { Name = "TestName", Description = "TestDescription", DatatypeDefinitionMap = { { datatypeDefinition0, new DatatypeDefinitionMap(datatypeDefinition0, this.parameterType0, new Dictionary <EnumValue, EnumerationValueDefinition>() { { new EnumValue(), new EnumerationValueDefinition() } }) }, { datatypeDefinition1, new DatatypeDefinitionMap(datatypeDefinition1, this.parameterType1, new Dictionary <EnumValue, EnumerationValueDefinition>() { { new EnumValue(), new EnumerationValueDefinition() } }) } }, SpecObjectTypeMap = { { specObjectType0, specObjectTypeMap0 }, { specObjectType1, specObjectTypeMap1 } }, SpecRelationTypeMap = { { specRelationType0, specRelationTypeMap0 } }, RelationGroupTypeMap = { { relationGroupType0, relationGroupTypeMap0 } }, SpecificationTypeMap = { { specificationType0, specificationTypeMap0 } } }; this.settings = new RequirementsModuleSettings() { SavedConfigurations = { this.mappingConfiguration } }; }