Exemple #1
0
        public void DeserializeSnippet()
        {
            const string snippet = @"""xUnit Fact"": {
		        ""prefix"": ""xu-fact"",
		        ""body"": [
			        ""[Fact]"",
			        ""public void ${1:TestName}()"",
			        ""{"",
			        ""\t$0"",
			        ""}""
		        ]
	        },"    ;

            var deserializer = new SnippetDeserializer();

            var snippetInput = deserializer.GetSnippetInput(snippet);

            Assert.Equal("xUnit Fact", snippetInput.Name);
            Assert.Equal("xu-fact", snippetInput.Prefix);
            Assert.Null(snippetInput.Description);
            Assert.False(snippetInput.HasDescription);
            Assert.True(snippetInput.ConvertToTabs);

            var lines = Regex.Split(snippetInput.Body, @"\r?\n");

            Assert.Equal("[Fact]", lines[0]);
            Assert.Equal("public void ${1:TestName}()", lines[1]);
            Assert.Equal("{", lines[2]);
            Assert.Equal("\t$0", lines[3]);
            Assert.Equal("}", lines[4]);
        }
Exemple #2
0
        public void DeserializeSingleLineSnippet()
        {
            const string snippet = @"""Property"": {
		        ""prefix"": ""prop"",
		        ""body"": ""public int MyProperty { get; set; }""
	        }"    ;

            var deserializer = new SnippetDeserializer();

            var snippetInput = deserializer.GetSnippetInput(snippet);

            Assert.Equal("Property", snippetInput.Name);
            Assert.Equal("prop", snippetInput.Prefix);
            Assert.Equal("public int MyProperty { get; set; }", snippetInput.Body);
        }
Exemple #3
0
 public IndexModel(SnippetGenerator snippetGenerator, SnippetDeserializer snippetDeserializer)
 {
     _snippetGenerator    = snippetGenerator;
     _snippetDeserializer = snippetDeserializer;
 }