Esempio n. 1
0
        public void LenientOutputNullDoesNotCauseWarningCS0168()
        {
            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 = false
                }
            };

            compiler.CompileView(new[] { chunks }, new[] { chunks });
            Assert.That(compiler.SourceCode.Contains("catch(System.NullReferenceException)"));
        }
Esempio n. 2
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);"));
        }