public void SetUp()
        {
            cctsRepository = CctsRepositoryFactory.CreateCctsRepository(new EARepositoryBdtEditor());
            target         = new TemporaryBdtModel(cctsRepository);
            var candidateCdtLibraryIndex = 0;

            target.mCandidateCdtLibraries[candidateCdtLibraryIndex].mCandidateCdts = new List <CandidateCdt>();
            target.CandidateCdtNames = new List <string>();
            target.CandidateConItems = new List <CheckableItem>();
            target.CandidateSupItems = new List <CheckableItem>();
            foreach (ICdt cdt in cctsRepository.GetCdtLibraryByPath((Path)"test model" / "blib1" / "cdtlib1").Cdts)
            {
                var candidateCdt = new CandidateCdt(cdt);
                target.mCandidateCdtLibraries[candidateCdtLibraryIndex].mCandidateCdts.Add(candidateCdt);
                target.CandidateCdtNames.Add(cdt.Name);

                int candidateCdtIndex =
                    target.mCandidateCdtLibraries[candidateCdtLibraryIndex].mCandidateCdts.IndexOf(candidateCdt);
                target.mCandidateCdtLibraries[candidateCdtLibraryIndex].mCandidateCdts[candidateCdtIndex].
                mPotentialCon.OriginalCdtCon = cdt.Con;
                target.CandidateConItems.Add(new CheckableItem(false, cdt.Con.Name, false, false, Cursors.Arrow));
                target.mCandidateCdtLibraries[candidateCdtLibraryIndex].CandidateCdts[candidateCdtIndex].mPotentialSups = new List <PotentialSup>();
                foreach (ICdtSup cdtSup in cdt.Sups)
                {
                    target.mCandidateCdtLibraries[candidateCdtLibraryIndex].mCandidateCdts[candidateCdtIndex].mPotentialSups.Add(new PotentialSup(cdtSup));
                    target.CandidateSupItems.Add(new CheckableItem(false, cdtSup.Name, false, false, Cursors.Arrow));
                }
            }
        }
示例#2
0
        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"));
        }
示例#3
0
        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"));
        }
示例#4
0
        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));
        }
示例#7
0
        private static IImporterContext CreateContext(string testCase)
        {
            XmlSchema bdtSchema = XmlSchema.Read(XmlReader.Create(TestUtils.RelativePathToTestResource(typeof(BDTXsdImporterTests), string.Format(@"BDTImporterTestResources\BusinessDataType_{0}.xsd", testCase))), null);

            var eaRepository = new EARepository();

            eaRepository.AddModel("Model", m => m.AddPackage("bLibrary", bLibrary =>
            {
                bLibrary.Element.Stereotype = Stereotype.bLibrary;
                bLibrary.AddPackage("PRIMLibrary", primLib =>
                {
                    primLib.Element.Stereotype = Stereotype.PRIMLibrary;
                    primLib.AddPRIM("String");
                    primLib.AddPRIM("Decimal");
                    primLib.AddPRIM("Date");
                });
                bLibrary.AddPackage("CDTLibrary", cdtLib =>
                {
                    cdtLib.Element.Stereotype = Stereotype.CDTLibrary;
                    cdtLib.AddCDT("Text");
                });
                bLibrary.AddPackage("BDTLibrary", bdtLib => { bdtLib.Element.Stereotype = Stereotype.BDTLibrary; });
            }));
            ICctsRepository cctsRepository = CctsRepositoryFactory.CreateCctsRepository(eaRepository);
            var             primLibrary    = cctsRepository.GetPrimLibraryByPath((Path)"Model" / "bLibrary" / "PRIMLibrary");
            var             bdtLibrary     = cctsRepository.GetBdtLibraryByPath((Path)"Model" / "bLibrary" / "BDTLibrary");
            var             cdtLibrary     = cctsRepository.GetCdtLibraryByPath((Path)"Model" / "bLibrary" / "CDTLibrary");

            var contextMock = new Mock <IImporterContext>();

            contextMock.SetupGet(c => c.PRIMLibrary).Returns(primLibrary);
            contextMock.SetupGet(c => c.CDTLibrary).Returns(cdtLibrary);
            contextMock.SetupGet(c => c.BDTLibrary).Returns(bdtLibrary);
            contextMock.SetupGet(c => c.BDTSchema).Returns(bdtSchema);

            return(contextMock.Object);
        }