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