Exemplo n.º 1
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);
        }