示例#1
0
 public void RegisterHelperSample()
 {
     var helperjs =
         @"function() {
     return new Handlebars.SafeString(""<a href='"" + this.url + ""'>"" + this.body + ""</a>"");
     }";
     var source = @"
     <ul>
     {{#posts}}
     <li>{{link_to}}</li>
     {{/posts}}
     </ul>";
     var context = new
     {
         posts = new[]
         {
             new
             {
                 url = "/hello-world",
                 body = "Hello World!"
             }
         }
     };
     using (var handleBars = new Handlebars())
     {
         handleBars.RegisterHelper("link_to", helperjs);
         handleBars.RegisterTemplate("myTemplate", source);
         Approvals.Verify(handleBars.Transform("myTemplate", context));
     }
 }
示例#2
0
 public void Setup()
 {
     Initialize();
     Instance.Navigate().GoToUrl(BaseAddress);
     Reporters.FixedRunTime = System.DateTime.MinValue;
     Reporters.Add(new JsonReporter());
     ApprovalTests.IntializeApprovalTests();
 }
		public void WritePropertiesToStringTest()
		{
			var anonymous = new
												{
													SomeString = "Hello",
													SomeInt = 10
												};
			Approvals.Verify(anonymous.WritePropertiesToString());
		}
        public void MsDosStyleCommand1()
        {
            var commands = new[]
            {
                @"export file.dat 2014-08-22 2014-08-26 /s:. /database:test /u:admin /p:adm1n",
                @"export file.dat 2014-08-22 2014-08-26 /filter:filter1 /f:filter2",
                @"import file.dat /server:server2 /database:test /u:admin /p:adm1n /filter:filter1 /f:filter2",
                @"import file.dat"
            };

            Approvals.Verify(CommandExecutorUtil.Do(_msDos, commands, 50));
        }
        public void PosixStyle()
        {
            var commands = new[]
            {
                @"export file.dat 2014-08-22 2014-08-26 -s. --database test -uadmin -padm1n",
                @"export file.dat 2014-08-22 2014-08-26 -ffilter1 -ffilter2",
                @"import file.dat --server server2 --database test -uadmin -padm1n",
                @"import file.dat --server server2 --database test -uadmin -padm1n -ffilter1 -ffilter2",
                @"import file.dat"
            };

            Approvals.Verify(CommandExecutorUtil.Do(_posix, commands, 50));
        }
        public void MsStdStyleCommand1()
        {
            var commands = new[]
            {
                @"export -to 2014-08-26 -from 2014-08-22 file.dat",
                @"export file.dat 2014-08-22 2014-08-26 -s . -database test -u admin -p adm1n",
                @"export file.dat 2014-08-22 2014-08-26 -filter filter1 -f filter2",
                @"import file.dat -server server2 -database test -u admin -p adm1n",
                @"import file.dat -server server2 -database test -u admin -p adm1n -filter filter1 -f filter2",
                @"import file.dat"
            };

            Approvals.Verify(CommandExecutorUtil.Do(_msStd, commands, 50));
        }
        public void MsDosStyleCommand1()
        {
            var commands = new[]
            {
                @"c1 file",
                @"c1 file /delete /A:location",
                @"c1 file /D /archive:location",
                @"c1",
                @"c1 /D /A:loc",
                @"c1 /A",
                @"c1 file /A:b,56",
                @"c2 name 5 /M:5",
                @"c2 name 5 /M:5,"
            };

            Approvals.Verify(CommandExecutorUtil.Do(_msDos, commands, 50));
        }
		public void TestJoinWithTransform()
		{
			var numbers = new[]
											{10,20,30,40,50,60,70,80,90,100,110,120};
			Approvals.Verify(numbers.JoinStringsWith(n => (n/10).ToString(), " - "));
		}
		public void TestJoinWith()
		{
			var numbers = new[]
											{"one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve"};
			Approvals.Verify(numbers.JoinWith(" - "));
		}
        public void PosixStyleCommand1()
        {
            var commands = new[]
            {
                @"c1 file",
                @"c1 file --delete -Alocation",
                @"c1 file -D --archive=location",
                @"c1",
                @"c1 -D -Aloc",
                @"c1 -A",
                @"c1 -Ab,56",
                @"c1 -- -Ab,56",
                @"bogus"
            };

            Approvals.Verify(CommandExecutorUtil.Do(_posix, commands, 50));
        }
        public void MsStdStyleCommand1()
        {
            var commands = new[]
            {
                @"c1 file",
                @"c1 file -delete -A:location",
                @"c1 file -delete -A location",
                @"c1 file -D -archive:location",
                @"c1 file -D -archive location",
                @"c1 file -D:false -A:loc",
                @"c1 file -D:true -A:loc",
                @"c1 file -delete:false -A:loc",
                @"c1 file -delete:true -A:loc",
                @"c1",
                @"c1 -D -A:loc",
                @"c1 -A",
                @"c1 file -A:b,56",
                @"c1 file -A b,56",
                @"c1 -- -A",
                @"c2 name 4 -maxSize:5",
                @"c3",
                @"c3 forty text 100",
                @"c3 40 text 100",
                @"c3 40 text 100 -kidding"
            };

            Approvals.Verify(CommandExecutorUtil.Do(_msStd, commands, 50));
        }
示例#12
0
    public void RegisterPartialsSample()
    {
        var partial = @"<a href=""/people/{{id}}"">{{name}}</a>";

        var source = @"
        <ul>
        {{#people}}
        <li>{{> link}}</li>
        {{/people}}
        </ul>";

        var context = new
        {
            people = new[]
            {
                new
                {
                    name = "Alan",
                    id = 1
                },
                new
                {
                    name = "Yehuda",
                    id = 2
                }
            }
        };
        using (var handleBars = new Handlebars())
        {
            handleBars.RegisterPartial("link", partial);
            handleBars.RegisterTemplate("myTemplate", source);
            Approvals.Verify(handleBars.Transform("myTemplate", context));
        }
    }
示例#13
0
    public void Sample()
    {
        var source = @"
        <p>Hello, my name is {{name}}. I am from {{hometown}}. I have {{kids.length}} kids:</p>
        <ul>
        {{#kids}}
        <li>{{name}} is {{age}}</li>
        {{/kids}}
        </ul>";

        var context = new
        {
            name = "Alan",
            hometown = "Somewhere, TX",
            kids = new[]
            {
                new
                {
                    name = "Sally",
                    age = "4"
                }
            }
        };

        using (var handleBars = new Handlebars())
        {
            handleBars.RegisterTemplate("Index", source);
            Approvals.Verify(handleBars.Transform("Index", context));
        }
    }
        public void ValidationIsRunOnParameters()
        {
            var commands = new[]
            {
                @"export file.dat 2014-08-22 2014-08-26 -s 123456789ABC -database test -u admin -p adm1n",
                @"export file*.dat 2014-08-22 2014-08-26 -filter filter1 -f filter2",
                @"import file:.dat -server server2 -database test -u admin -p adm1n",
                @"import file*.dat -server server2 -database test -u admin -p adm1n -filter filter1 -f filter2"
            };

            Approvals.Verify(CommandExecutorUtil.Do(_msStd, commands, 50));
        }