Ejemplo n.º 1
0
 public void RenderReportsTemplateValidationErrorsToTransformation()
 {
     using (var template = new FakeTemplate())
     {
         template.Validated = () => template.Error(TestMessage);
         template.Render();
         AssertSingleError(this.transformation.Errors, TestMessage);
     }
 }
Ejemplo n.º 2
0
 public void RenderReportsTransformationExceptionsAsErrors()
 {
     using (var template = new FakeTemplate())
     {
         template.Validated = () => { throw new TransformationException(TestMessage); };
         template.Render();
         AssertSingleError(template.Errors, TestMessage);
     }
 }
Ejemplo n.º 3
0
 public void RenderRaisesRenderingEvent()
 {
     using (var template = new FakeTemplate())
     {
         bool eventRaised = false;
         template.Rendering += delegate { eventRaised = true; };
         template.Render();
         Assert.AreEqual(true, eventRaised);
     }
 }
Ejemplo n.º 4
0
 public void RenderDoesNotTransformTemplateWhenEnabledIsFalse()
 {
     using (var template = new FakeTemplate())
     {
         template.Enabled = false;
         bool transformed = false;
         template.TransformedText = () => transformed = true;
         template.Render();
         Assert.IsFalse(transformed);
     }
 }
Ejemplo n.º 5
0
 public void RenderTransformsTemplateWhenEnabledIsSetByRenderingEventHandler()
 {
     using (var template = new FakeTemplate())
     {
         template.Enabled = false;
         bool transformed = false;
         template.Rendering      += delegate { template.Enabled = true; };
         template.TransformedText = () => transformed = true;
         template.Render();
         Assert.IsTrue(transformed);
     }
 }
Ejemplo n.º 6
0
        public void RenderReportsTemplateFileInErrorsOfTemplateFileBasedTransformation()
        {
            this.transformation.Host.TemplateFile = "Template.tt";

            using (var template = new FakeTemplate())
            {
                template.Validated = () => template.Error(TestMessage);
                template.Render();
            }

            var error = this.transformation.Errors.Cast <CompilerError>().Single();

            Assert.AreEqual("Template.tt", error.FileName);
        }
Ejemplo n.º 7
0
        public void RenderReportsInputFileInErrorsOfInputFileBasedTransformation()
        {
            this.transformation.Session[TransformationContext.InputFileNameKey] = "Input.cs";

            using (var template = new FakeTemplate())
            {
                template.Validated = () => template.Error(TestMessage);
                template.Render();
            }

            var error = this.transformation.Errors.Cast <CompilerError>().Single();

            Assert.AreEqual("Input.cs", error.FileName);
        }
Ejemplo n.º 8
0
        public void RenderReportsInputFileInErrorsOfInputFileBasedTransformation()
        {
            this.transformation.Session[TransformationContext.InputFileNameKey] = "Input.cs";

            using (var template = new FakeTemplate())
            {
                template.Validated = () => template.Error(TestMessage);
                template.Render();
            }

            var error = this.transformation.Errors.Cast<CompilerError>().Single();
            Assert.AreEqual("Input.cs", error.FileName);
        }
Ejemplo n.º 9
0
        public void RenderReportsTemplateFileInErrorsOfTemplateFileBasedTransformation()
        {
            this.transformation.Host.TemplateFile = "Template.tt";

            using (var template = new FakeTemplate())
            {
                template.Validated = () => template.Error(TestMessage);
                template.Render();
            }

            var error = this.transformation.Errors.Cast<CompilerError>().Single();
            Assert.AreEqual("Template.tt", error.FileName);            
        }
Ejemplo n.º 10
0
 public void RenderReportsTemplateValidationErrorsToTransformation()
 {
     using (var template = new FakeTemplate())
     {
         template.Validated = () => template.Error(TestMessage);
         template.Render();
         AssertSingleError(this.transformation.Errors, TestMessage);
     }
 }
Ejemplo n.º 11
0
 public void RenderReportsTransformationExceptionsAsErrors()
 {
     using (var template = new FakeTemplate())
     {
         template.Validated = () => { throw new TransformationException(TestMessage); };
         template.Render();
         AssertSingleError(template.Errors, TestMessage);
     }
 }
Ejemplo n.º 12
0
 public void RenderTransformsTemplateWhenEnabledIsSetByRenderingEventHandler()
 {
     using (var template = new FakeTemplate())
     {
         template.Enabled = false;
         bool transformed = false;
         template.Rendering += delegate { template.Enabled = true; };
         template.TransformedText = () => transformed = true;
         template.Render();
         Assert.IsTrue(transformed);
     }            
 }
Ejemplo n.º 13
0
 public void RenderRaisesRenderingEvent()
 {
     using (var template = new FakeTemplate())
     {
         bool eventRaised = false;
         template.Rendering += delegate { eventRaised = true; };
         template.Render();
         Assert.AreEqual(true, eventRaised);                
     }
 }
Ejemplo n.º 14
0
 public void RenderDoesNotTransformTemplateWhenEnabledIsFalse()
 {
     using (var template = new FakeTemplate())
     {
         template.Enabled = false;
         bool transformed = false;
         template.TransformedText = () => transformed = true;
         template.Render();
         Assert.IsFalse(transformed);
     }
 }