Beispiel #1
0
        private CompletionSet GetCompletionSetFor(Node node)
        {
            char currentCharacter = _textBuffer.CurrentSnapshot[_triggerPoint - 1];

            switch (currentCharacter)
            {
            case '<':
                return(SparkCompletionSetFactory.Create <SparkElementCompletionSet>(_viewExplorer, _trackingSpan));

            case '"':
                return(SparkCompletionSetFactory.Create <SparkAttributeCompletionSet>(_viewExplorer, _trackingSpan));

            default:
                break;
            }

            if (node is ElementNode)
            {
                return(SparkCompletionSetFactory.Create <SparkElementCompletionSet>(_viewExplorer, _trackingSpan));
            }
            if (node is AttributeNode)
            {
                return(SparkCompletionSetFactory.Create <SparkAttributeCompletionSet>(_viewExplorer, _trackingSpan));
            }
            return(null);
        }
        public void ShouldLookForRelatedPartials()
        {
            var mockViewExplorer = MockRepository.GenerateMock <IViewExplorer>();

            mockViewExplorer.Expect(x => x.GetRelatedPartials()).Return(new List <string> {
                "partial1", "partial2"
            });

            var tag     = SparkCompletionSetFactory.Create <SparkElementCompletionSet>(mockViewExplorer, null);
            var tagList = tag.Completions.ToList();

            Assert.That(tagList.Exists(c => c.DisplayText == "partial1"));
            Assert.That(tagList.Exists(c => c.DisplayText == "partial2"));

            mockViewExplorer.VerifyAllExpectations();
        }
        public void ShouldReturnSparkSpecialNodes()
        {
            var tag = SparkCompletionSetFactory.Create <SparkElementCompletionSet>(null, _stubTrackingSpan);
            List <Completion> tagList = tag.Completions.ToList();

            Assert.IsTrue(tagList.Exists(c => c.DisplayText == "var"));
            Assert.IsTrue(tagList.Exists(c => c.DisplayText == "def"));
            Assert.IsTrue(tagList.Exists(c => c.DisplayText == "default"));
            Assert.IsTrue(tagList.Exists(c => c.DisplayText == "global"));
            Assert.IsTrue(tagList.Exists(c => c.DisplayText == "viewdata"));
            Assert.IsTrue(tagList.Exists(c => c.DisplayText == "set"));
            Assert.IsTrue(tagList.Exists(c => c.DisplayText == "for"));
            Assert.IsTrue(tagList.Exists(c => c.DisplayText == "test"));
            Assert.IsTrue(tagList.Exists(c => c.DisplayText == "if"));
            Assert.IsTrue(tagList.Exists(c => c.DisplayText == "else"));
            Assert.IsTrue(tagList.Exists(c => c.DisplayText == "elseif"));
            Assert.IsTrue(tagList.Exists(c => c.DisplayText == "content"));
            Assert.IsTrue(tagList.Exists(c => c.DisplayText == "use"));
            Assert.IsTrue(tagList.Exists(c => c.DisplayText == "macro"));
            Assert.IsTrue(tagList.Exists(c => c.DisplayText == "render"));
            Assert.IsTrue(tagList.Exists(c => c.DisplayText == "section"));
            Assert.IsTrue(tagList.Exists(c => c.DisplayText == "cache"));
        }