internal static UmlClassSpec Convert(CdtSpec cdtSpec) { var umlClassSpec = new UmlClassSpec { Stereotype = "CDT", Name = cdtSpec.Name, TaggedValues = new[] { new UmlTaggedValueSpec("businessTerm", cdtSpec.BusinessTerms), new UmlTaggedValueSpec("definition", cdtSpec.Definition), new UmlTaggedValueSpec("dictionaryEntryName", cdtSpec.DictionaryEntryName) { DefaultValue = GenerateDictionaryEntryNameDefaultValue(cdtSpec) }, new UmlTaggedValueSpec("languageCode", cdtSpec.LanguageCode), new UmlTaggedValueSpec("uniqueIdentifier", cdtSpec.UniqueIdentifier) { DefaultValue = GenerateUniqueIdentifierDefaultValue(cdtSpec) }, new UmlTaggedValueSpec("versionIdentifier", cdtSpec.VersionIdentifier), new UmlTaggedValueSpec("usageRule", cdtSpec.UsageRules), }, }; var dependencySpecs = new List <UmlDependencySpec>(); if (cdtSpec.IsEquivalentTo != null) { dependencySpecs.Add(new UmlDependencySpec { Stereotype = "isEquivalentTo", Target = ((UpccCdt)cdtSpec.IsEquivalentTo).UmlClass, LowerBound = "0", UpperBound = "1", }); } umlClassSpec.Dependencies = dependencySpecs; var attributeSpecs = new List <UmlAttributeSpec>(); if (cdtSpec.Con != null) { attributeSpecs.Add(CdtConSpecConverter.Convert(cdtSpec.Con, cdtSpec.Name)); } if (cdtSpec.Sups != null) { foreach (var cdtSupSpec in cdtSpec.Sups) { attributeSpecs.Add(CdtSupSpecConverter.Convert(cdtSupSpec, cdtSpec.Name)); } } umlClassSpec.Attributes = MakeAttributeNamesUnique(attributeSpecs); return(umlClassSpec); }
public void ShouldOnlyAutoGenerateUnspecifiedTaggedValues() { ICctsRepository ccRepository = CctsRepositoryFactory.CreateCctsRepository(new CdtLibraryTestRepository()); ICdtLibrary cdtLibrary = ccRepository.GetCdtLibraryByPath(CdtLibraryTestRepository.PathToCdtLibrary()); CdtSpec cdtSpec = new CdtSpec { Name = "cdt1", UniqueIdentifier = "{x-123-456-789-x}", DictionaryEntryName = "shouldNotBeReplaced" }; ICdt cdt = cdtLibrary.CreateCdt(cdtSpec); Assert.That(cdt.UniqueIdentifier, Is.EqualTo("{x-123-456-789-x}")); Assert.That(cdt.DictionaryEntryName, Is.EqualTo("shouldNotBeReplaced")); }
public void ShouldAutoGenerateTaggedValues() { ICctsRepository ccRepository = CctsRepositoryFactory.CreateCctsRepository(new CdtLibraryTestRepository()); ICdtLibrary cdtLibrary = ccRepository.GetCdtLibraryByPath(CdtLibraryTestRepository.PathToCdtLibrary()); CdtSpec cdtSpec = new CdtSpec { Name = "cdt1" }; ICdt cdt = cdtLibrary.CreateCdt(cdtSpec); Assert.That(cdt.UniqueIdentifier, Is.Not.Null); Assert.That(cdt.UniqueIdentifier, Is.Not.Empty); Assert.That(cdt.DictionaryEntryName, Is.EqualTo("cdt1. Type")); }
public void ShouldNotAutoGenerateSpecifiedTaggedValues() { ICctsRepository ccRepository = CctsRepositoryFactory.CreateCctsRepository(new CdtLibraryTestRepository()); ICdtLibrary cdtLibrary = ccRepository.GetCdtLibraryByPath(CdtLibraryTestRepository.PathToCdtLibrary()); ICdt cdtText = ccRepository.GetCdtByPath(CdtLibraryTestRepository.PathToCdtText()); CdtSpec cdtSpec = CdtSpec.CloneCdt(cdtText); cdtSpec.DictionaryEntryName = "cdt1"; cdtSpec.UniqueIdentifier = "{1-2-3}"; ICdt updatedCdt = cdtLibrary.UpdateCdt(cdtText, cdtSpec); Assert.That(updatedCdt.UniqueIdentifier, Is.EqualTo("{1-2-3}")); Assert.That(updatedCdt.DictionaryEntryName, Is.EqualTo("cdt1")); }
public void ShouldAutoGenerateClonedTaggedValues() { ICctsRepository ccRepository = CreateRepository(); ICdtLibrary cdtLibrary = ccRepository.GetCdtLibraryByPath(CdtLibraryTestRepository.PathToCdtLibrary()); ICdt cdtText = ccRepository.GetCdtByPath(CdtLibraryTestRepository.PathToCdtText()); CdtSpec cdtSpec = CdtSpec.CloneCdt(cdtText); cdtSpec.Name = "cdt1"; ICdt cdt = cdtLibrary.CreateCdt(cdtSpec); Assert.That(cdt.UniqueIdentifier, Is.Not.Null); Assert.That(cdt.UniqueIdentifier, Is.Not.Empty); Assert.That(cdt.UniqueIdentifier, Is.Not.EqualTo(cdtText.UniqueIdentifier)); Assert.That(cdt.DictionaryEntryName, Is.EqualTo("cdt1. Type")); }
public void ShouldNotUpdateAutoGeneratedTaggedValues() { ICctsRepository ccRepository = CreateRepository(); ICdtLibrary cdtLibrary = ccRepository.GetCdtLibraryByPath(CdtLibraryTestRepository.PathToCdtLibrary()); ICdt cdtText = ccRepository.GetCdtByPath(CdtLibraryTestRepository.PathToCdtText()); string cdtTextUniqueIdentifier = cdtText.UniqueIdentifier; string cdtTextDictionaryEntryName = cdtText.DictionaryEntryName; CdtSpec cdtSpec = CdtSpec.CloneCdt(cdtText); cdtSpec.Name = "cdt1"; ICdt updatedCdt = cdtLibrary.UpdateCdt(cdtText, cdtSpec); Assert.That(updatedCdt.UniqueIdentifier, Is.EqualTo(cdtTextUniqueIdentifier)); Assert.That(updatedCdt.DictionaryEntryName, Is.EqualTo(cdtTextDictionaryEntryName)); }
public ICdt UpdateCdt(ICdt element, CdtSpec spec) { throw new NotImplementedException(); }
public ICdt CreateCdt(CdtSpec spec) { throw new NotImplementedException(); }
/// <summary> /// Updates a CDT to match the given <paramref name="specification"/>. /// <param name="cdt">A CDT.</param> /// <param name="specification">A new specification for the given CDT.</param> /// <returns>The updated CDT. Depending on the implementation, this might be the same updated instance or a new instance!</returns> /// </summary> public ICdt UpdateCdt(ICdt cdt, CdtSpec specification) { return(new UpccCdt(UmlPackage.UpdateClass(((UpccCdt)cdt).UmlClass, CdtSpecConverter.Convert(specification)))); }
/// <summary> /// Creates a CDT based on the given <paramref name="specification"/>. /// <param name="specification">A specification for a CDT.</param> /// <returns>The newly created CDT.</returns> /// </summary> public ICdt CreateCdt(CdtSpec specification) { return(new UpccCdt(UmlPackage.CreateClass(CdtSpecConverter.Convert(specification)))); }
private static string GenerateDictionaryEntryNameDefaultValue(CdtSpec cdtSpec) { return(cdtSpec.Name + ". Type"); }
private static string GenerateUniqueIdentifierDefaultValue(CdtSpec cdtSpec) { return(Guid.NewGuid().ToString()); }