예제 #1
0
 public void StrictNullUsesException()
 {
     var compiler = new CSharpViewCompiler()
                    {
                        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);"));
 }
예제 #2
0
 public void LenientSilentNullDoesNotCauseWarningCS0168()
 {
     var compiler = new CSharpViewCompiler()
                    {
                        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)"));
 }