示例#1
0
        public void CanCallWith1ParamAndReturnValue()
        {
            var context = new MethodCallTestsContext();

            AssertTemplate.Equal(
                @"Hello #Foo#!",
                @"Hello @Wrap(""Foo"")!",
                context);
        }
 public void SingleLineCodeBlock()
 {
     AssertTemplate.Equal(
         @"Bar, Baz",
         @"@{ var namesForDisplay = string.Join("", "", Names.Where(x => x.StartsWith(""B""))); }@namesForDisplay",
         new CodeBlockTestsContext()
     {
         Names = new string[] { "Foo", "Bar", "Baz" }
     });
 }
示例#3
0
 public void GetStringProperty()
 {
     AssertTemplate.Equal(
         "Hello FooBar!",
         "Hello @Name1!",
         new GetTestsContext()
     {
         Name1 = "FooBar",
     });
 }
 public void ExpressionsCanBeginWithParen()
 {
     AssertTemplate.Equal(
         "Hello #FooBar#!",
         "Hello @(Wrap(Name))!",
         new ExpressionTestsContext()
     {
         Name = "FooBar",
     });
 }
示例#5
0
 public void InlineIfIsIncluded()
 {
     AssertTemplate.Equal(
         @"You are not ready!",
         @"You are @if(DoIt) {not }ready!",
         new IfTestsContext()
     {
         DoIt = true
     });
 }
示例#6
0
 public void SingleForEachLoopProducesSingleLine()
 {
     AssertTemplate.Equal(
         @"Hello Foo! Hello Bar! Hello Baz! ",
         @"@foreach (var name in Names) {Hello @name! }",
         new ForEachTestsContext()
     {
         Names = new string[] { "Foo", "Bar", "Baz" },
     });
 }
示例#7
0
        public void CanCallVoidMethod()
        {
            var context = new MethodCallTestsContext();

            AssertTemplate.Equal(
                @"Hello!",
                @"@{ VoidMethod(); }Hello!",
                context);

            Assert.Equal(1, context.VoidMethodCallCount);
        }
示例#8
0
 public void GetMultipleStringProperties()
 {
     AssertTemplate.Equal(
         "Hello Foo and Bar!",
         "Hello @Name1 and @Name2!",
         new GetTestsContext()
     {
         Name1 = "Foo",
         Name2 = "Bar"
     });
 }
示例#9
0
        public void BlockIfIsExcluded()
        {
            AssertTemplate.Equal(
                @"You
are
ready!",
                @"You
are
@if(DoIt)
{
not
}ready!",
                new IfTestsContext()
            {
                DoIt = false
            });
        }