public void Test_mapping_with_semisemantic_loss()
        {
            string mappingFile = TestUtils.PathToTestResource(@"XSDImporterTest\mapping\MappingImporterTests\mapping_with_semisemantic_loss\mapping.mfd");

            string[] schemaFiles = new[] { TestUtils.PathToTestResource(@"XSDImporterTest\mapping\MappingImporterTests\mapping_with_semisemantic_loss\source.xsd") };

            new MappingImporter(new[] { mappingFile }, schemaFiles, ccLibrary, bLibrary, DocLibraryName, BieLibraryName, BdtLibraryName, Qualifier, RootElementName, cctsRepository).ImportMapping();

            var         bieLibrary = ShouldContainBieLibrary(BieLibraryName);
            var         docLibrary = ShouldContainDocLibrary(DocLibraryName);
            IBdtLibrary bdtLibrary = ShouldContainBdtLibrary(BdtLibraryName);

            IBdt bdtText = ShouldContainBdt(bdtLibrary, "String_Text", "Text", null);

            Assert.That(bdtLibrary.Bdts.Count(), Is.EqualTo(1));

            IAbie bieAddress = ShouldContainAbie(bieLibrary, "AddressType_Address", "Address", new[] { new BbieDescriptor("StreetName_StreetName", bdtText.Id), new BbieDescriptor("Town_CityName", bdtText.Id) }, null);

            IAbie biePerson = ShouldContainAbie(bieLibrary, "PersonType_Party", "Party", new[] { new BbieDescriptor("FirstName_Name", bdtText.Id), new BbieDescriptor("LastName_Name", bdtText.Id) }, new[] { new AsbieDescriptor("HomeAddress_Residence", bieAddress.Id), new AsbieDescriptor("WorkAddress_Residence", bieAddress.Id) });

            ShouldContainMa(docLibrary, "test_Invoice", new[]
            {
                new AsmaDescriptor("Person", biePerson.Id),
            });
        }
Esempio n. 2
0
        private void buttonGenerateBDT_Click(object sender, EventArgs e)
        {
            GatherUserInput();

            if ((cache.PathIsValid(CacheConstants.PATH_CDTs, new[] { selectedCDTLName, selectedCDTName })) &&
                (cache.PathIsValid(CacheConstants.PATH_BDTLs, new[] { selectedBDTLName })))
            {
                ICdt        cdt  = repository.GetCdtById(cache.CDTLs[selectedCDTLName].CDTs[selectedCDTName].Id);
                IBdtLibrary bdtl = repository.GetBdtLibraryById(cache.BDTLs[selectedBDTLName].Id);

                BdtSpec bdtSpec = BdtSpec.CloneCdt(cdt, textBDTName.Text);

                var sups = new List <BdtSupSpec>(bdtSpec.Sups);
                foreach (cSUP sup in cache.CDTLs[selectedCDTLName].CDTs[selectedCDTName].SUPs.Values)
                {
                    if (sup.State == CheckState.Unchecked)
                    {
                        var name = sup.Name;
                        sups.RemoveAll(s => s.Name == name);
                    }
                }
                bdtSpec.Sups = sups;

                IBdt newBDT = bdtl.CreateBdt(bdtSpec);

                cache.BDTLs[selectedBDTLName].BDTs.Add(newBDT.Name, new cBDT(newBDT.Name, newBDT.Id, newBDT.BasedOn.Id, CheckState.Unchecked));

                textBDTName.Text = "";
                textBDTName.Text = newBDT.Name;
            }
        }
        public void Test_mapping_complex_type_with_one_attribute_to_single_acc()
        {
            string mappingFile = TestUtils.PathToTestResource(@"XSDImporterTest\mapping\MappingImporterTests\mapping_complex_type_with_one_attribute_to_single_acc\mapping.mfd");

            string[] schemaFiles = new[] { TestUtils.PathToTestResource(@"XSDImporterTest\mapping\MappingImporterTests\mapping_complex_type_with_one_attribute_to_single_acc\source.xsd") };

            new MappingImporter(new[] { mappingFile }, schemaFiles, ccLibrary, bLibrary, DocLibraryName, BieLibraryName, BdtLibraryName, Qualifier, RootElementName, cctsRepository).ImportMapping();

            var bieLibrary = ShouldContainBieLibrary(BieLibraryName);

            IBdtLibrary bdtLibrary = ShouldContainBdtLibrary(BdtLibraryName);

            IBdt bdtText = ShouldContainBdt(bdtLibrary, "String_Text", "Text", null);

            Assert.That(bdtLibrary.Bdts.Count(), Is.EqualTo(1));

            IAbie bieAddress = ShouldContainAbie(bieLibrary, "AddressType_Address", "Address", new[] { new BbieDescriptor("Town_CityName", bdtText.Id) }, null);

            var docLibrary = ShouldContainDocLibrary(DocLibraryName);

            ShouldContainMa(docLibrary, "test_Invoice", new[]
            {
                new AsmaDescriptor("Address", bieAddress.Id),
            });
        }
 public static BdtLibrarySpec CloneBdtLibrary(IBdtLibrary bdtLibrary)
 {
     return(new BdtLibrarySpec
     {
         Name = bdtLibrary.Name,
         BusinessTerms = new List <string>(bdtLibrary.BusinessTerms),
         Copyrights = new List <string>(bdtLibrary.Copyrights),
         Owners = new List <string>(bdtLibrary.Owners),
         References = new List <string>(bdtLibrary.References),
         Status = bdtLibrary.Status,
         VersionIdentifier = bdtLibrary.VersionIdentifier,
         BaseURN = bdtLibrary.BaseURN,
         NamespacePrefix = bdtLibrary.NamespacePrefix,
     });
 }
        /// <summary>
        /// Takes the names of the libraries to be created as well as a qualifier as input and creates the
        /// libraries.
        /// </summary>
        public void GenerateLibraries()
        {
            bdtLibrary = bLibrary.CreateBdtLibrary(new BdtLibrarySpec
            {
                Name = bdtLibraryName
            });
            bieLibrary = bLibrary.CreateBieLibrary(new BieLibrarySpec
            {
                Name = bieLibraryName
            });
            docLibrary = bLibrary.CreateDocLibrary(new DocLibrarySpec
            {
                Name = docLibraryName
            });
            GenerateBdtsAndAbiesAndMas();

            GenerateRootABIE();
        }
Esempio n. 6
0
        public void ShouldGetAndCacheBdtLibraryByName()
        {
            // Setup
            var bdtLibraryMock = new Mock <IBdtLibrary>();

            bdtLibraryMock.SetupGet(l => l.Name).Returns("bdtlib1");
            var cctsRepositoryMock = new Mock <ICctsRepository>();

            cctsRepositoryMock.Setup(r => r.GetAllLibraries()).Returns(new[] { bdtLibraryMock.Object });

            // Events
            CcCache     ccCache    = CcCache.GetInstance(cctsRepositoryMock.Object);
            IBdtLibrary bdtLibrary = ccCache.GetBdtLibraryByName("bdtlib1");

            ccCache.GetBdtLibraryByName("bdtlib1");

            // Assertion and Verification
            Assert.That(bdtLibrary, Is.SameAs(bdtLibraryMock.Object));
            cctsRepositoryMock.Verify(r => r.GetAllLibraries(), Times.Exactly(1));
        }
        private static IBdt ShouldContainBdt(IBdtLibrary bdtLibrary, string name, string cdtName, string[] generatedSups)
        {
            IBdt bdt = bdtLibrary.GetBdtByName(name);

            Assert.IsNotNull(bdt, "BDT '" + name + "' not generated");

            Assert.That(bdt.BasedOn, Is.Not.Null, "BasedOn reference not specified");
            Assert.AreEqual(cdtName, bdt.BasedOn.Name, "BasedOn wrong CDT");

            if (generatedSups == null || generatedSups.Length == 0)
            {
                Assert.That(SupNames(bdt), Is.Empty);
            }
            else
            {
                Assert.That(SupNames(bdt), Is.EquivalentTo(generatedSups));
            }

            return(bdt);
        }
        public void Test_mapping_single_simple_typed_element_to_bcc()
        {
            string mappingFile = TestUtils.PathToTestResource(@"XSDImporterTest\mapping\MappingImporterTests\mapping_single_simple_typed_element_to_bcc\mapping.mfd");

            string[] schemaFiles = new[] { TestUtils.PathToTestResource(@"XSDImporterTest\mapping\MappingImporterTests\mapping_single_simple_typed_element_to_bcc\source.xsd") };

            new MappingImporter(new[] { mappingFile }, schemaFiles, ccLibrary, bLibrary, DocLibraryName, BieLibraryName, BdtLibraryName, Qualifier, RootElementName, cctsRepository).ImportMapping();

            var bieLibrary = ShouldContainBieLibrary(BieLibraryName);
            var docLibrary = ShouldContainDocLibrary(DocLibraryName);

            IBdtLibrary bdtLibrary = ShouldContainBdtLibrary(BdtLibraryName);

            IBdt bdtText = ShouldContainBdt(bdtLibrary, "String_Text", "Text", null);

            Assert.That(bdtLibrary.Bdts.Count(), Is.EqualTo(1));

            IAbie bieParty = ShouldContainAbie(bieLibrary, "test_Party", "Party", new[] { new BbieDescriptor("PersonName_Name", bdtText.Id), }, null);

            ShouldContainMa(docLibrary, "test_Invoice", new[]
            {
                new AsmaDescriptor("test_Party", bieParty.Id),
            });
        }
 internal CacheItemBdtLibrary(IBdtLibrary library)
 {
     BdtLibrary = library;
 }
 public static void InitLibraries(ImporterContext context)
 {
     ExistingAccs = context.CCLibrary;
     ExistingBdts = context.BDTLibrary;
     BieLibrary   = context.BIELibrary;
 }
Esempio n. 11
0
 public void RemoveBdtLibrary(IBdtLibrary bdtLibrary)
 {
     throw new NotImplementedException();
 }
Esempio n. 12
0
 public IBdtLibrary UpdateBdtLibrary(IBdtLibrary bdtLibrary, BdtLibrarySpec specification)
 {
     throw new NotImplementedException();
 }
 public CandidateBdtLibrary(IBdtLibrary bdtLibrary)
 {
     mOriginalBdtLibrary = bdtLibrary;
     mSelected           = false;
 }
 /// <summary>
 /// Removes a BdtLibrary from this bLibrary.
 /// <param name="bdtLibrary">A BdtLibrary.</param>
 /// </summary>
 public void RemoveBdtLibrary(IBdtLibrary bdtLibrary)
 {
     UmlPackage.RemovePackage(((UpccBdtLibrary)bdtLibrary).UmlPackage);
 }
 /// <summary>
 /// Updates a BDTLibrary to match the given <paramref name="specification"/>.
 /// <param name="bdtLibrary">A BDTLibrary.</param>
 /// <param name="specification">A new specification for the given BDTLibrary.</param>
 /// <returns>The updated BDTLibrary. Depending on the implementation, this might be the same updated instance or a new instance!</returns>
 /// </summary>
 public IBdtLibrary UpdateBdtLibrary(IBdtLibrary bdtLibrary, BdtLibrarySpec specification)
 {
     return(new UpccBdtLibrary(UmlPackage.UpdatePackage(((UpccBdtLibrary)bdtLibrary).UmlPackage, BdtLibrarySpecConverter.Convert(specification))));
 }