Exemplo n.º 1
0
 public void StrictNullUsesException()
 {
     var compiler = new DefaultViewCompiler()
     {
         BaseClass = "Spark.Tests.Stubs.StubSparkView",
         NullBehaviour = NullBehaviour.Strict
     };
     var chunks = new Chunk[]
                      {
                          new ViewDataChunk { Name="comment", Type="Spark.Tests.Models.Comment"},
                          new SendExpressionChunk {Code = "comment.Text", SilentNulls = false}
                      };
     compiler.CompileView(new[] { chunks }, new[] { chunks });
     Assert.That(compiler.SourceCode.Contains("catch(System.NullReferenceException ex)"));
     Assert.That(compiler.SourceCode.Contains("ArgumentNullException("));
     Assert.That(compiler.SourceCode.Contains(", ex);"));
 }
Exemplo n.º 2
0
 private static void DoCompileView(DefaultViewCompiler compiler, IList<Chunk> chunks)
 {
     compiler.CompileView(new[] { chunks }, new[] { chunks });
 }
Exemplo n.º 3
0
 public void LenientSilentNullDoesNotCauseWarningCS0168()
 {
     var compiler = new DefaultViewCompiler()
     {
         BaseClass = "Spark.Tests.Stubs.StubSparkView",
         NullBehaviour = NullBehaviour.Lenient
     };
     var chunks = new Chunk[]
                      {
                          new ViewDataChunk { Name="comment", Type="Spark.Tests.Models.Comment"},
                          new SendExpressionChunk {Code = "comment.Text", SilentNulls = true}
                      };
     compiler.CompileView(new[] { chunks }, new[] { chunks });
     Assert.That(compiler.SourceCode.Contains("catch(System.NullReferenceException)"));
 }