示例#1
0
        public void ParseFile()
        {
            /* Parse C# file and make sure EmunModel array get filled correctly */
            string path       = @"..\..\T20\Input.cs";
            string sourceText = File.ReadAllText(path);

            ComposerStrings composer = new ComposerStrings(null);

            composer.Compose(sourceText);

            Assert.AreEqual(1, composer.EnumModels.Count);

            EnumModel model = composer.EnumModels[0];

            Assert.AreEqual("E2", model.Name);
            Assert.AreEqual("SELECT lkc__id, lkc_name FROM AcClaim.dbo.T_LookupCategories", model.SqlSelect);
            Assert.AreEqual(2, model.Values.Count);
            Assert.AreEqual("server1", model.SqlProvider);
            Assert.AreEqual("database2", model.SqlDatasource);

            EnumModelValue value = null;

            value = model.Values[0];
            Assert.AreEqual(344, value.Value);
            Assert.AreEqual("K2", value.NameCs);

            value = model.Values[1];
            Assert.AreEqual(534, value.Value);
            Assert.AreEqual("K5", value.NameCs);
        }
示例#2
0
        public void FakeBuildInDatabaseException()
        {
            string path       = @"..\..\T21\Input.cs";
            string sourceText = File.ReadAllText(path);

            sourceText = sourceText.Replace("T_Weekdays", "T_Wds");

            ComposerStrings composer = new ComposerStrings(new DbReader(null, null, null));

            /* Build-in Database response only to T_Weekdays table name */
            composer.Compose(sourceText);
        }
示例#3
0
        public void FakeBuildInDatabase()
        {
            string path       = @"..\..\T21\Input.cs";
            string sourceText = File.ReadAllText(path);

            ComposerStrings composer = new ComposerStrings(_dbReader);

            composer.Compose(sourceText);

            string txt = composer.GetResultFile();

            Assert.AreEqual(2, composer.EnumModels.Count, "File contains two enumerations.");
            Assert.AreEqual(7, composer.EnumModels[0].Values.Count, "First enumeration has 7 values.");
            Assert.AreEqual(null, composer.EnumModels[0].Values[3].Description, "First enumeration has no descriptions.");
            Assert.AreEqual(7, composer.EnumModels[1].Values.Count, "Second enumeration has 7 values");
            Assert.AreEqual(2, composer.EnumModels[1].Values.Where(e => e.IsActive).Count(), "Second enumeration has 2 active values.");
            Assert.AreNotEqual(null, composer.EnumModels[1].Values[3].Description, "Second enumeration descriptions are filled up.");
        }
示例#4
0
        public void ApplyComposer(TextDocument document, ComposerStrings composer)
        {
            /* get document bounds */
            EditPoint startEdit = document.CreateEditPoint(document.StartPoint);
            EditPoint endEdit   = document.EndPoint.CreateEditPoint();

            /* run composer */
            string text = startEdit.GetText(document.EndPoint);

            composer.Compose(text);
            if (composer.EnumModels != null && composer.EnumModels.Count > 0)
            {
                /* get new file*/
                text = composer.GetResultFile();

                /* delete and re-insert full document */
                startEdit.Delete(endEdit);
                startEdit.Insert(text);
            }
        }
示例#5
0
        private void RunComposerScan_Inner(IEnumLog log)
        {
            DTE2 applicationObject = (DTE2)Package.GetGlobalService(typeof(EnvDTE.DTE));

            TextDocument document = ObtainActiveDocument(applicationObject);

            if (document == null)
            {
                log.WriteLine("not a C# file.");
                return;
            }

            DbReader          dbReader        = new DbReader(null, null, log);
            IEnumConfigReader configReaderVsp = new ConfigReaderVsp(applicationObject.ActiveDocument.ProjectItem.ContainingProject);

            dbReader._configReader = configReaderVsp;

            ComposerStrings composer = new ComposerStrings(dbReader, log);

            ApplyComposer(document, composer);
        }