Example #1
0
            public void Should_Throw_If_File_Path_Is_Null()
            {
                // Given
                var fixture        = new TextTransformationFixture();
                var transformation = fixture.CreateTextTransformation();

                // When
                var result = Record.Exception(() => transformation.Save(null));

                // Then
                AssertEx.IsArgumentNullException(result, "path");
            }
Example #2
0
            public void Should_Throw_If_Template_Is_Null()
            {
                // Given
                var fixture = new TextTransformationFixture();

                fixture.TransformationTemplate = null;

                // When
                var result = Record.Exception(() => fixture.CreateTextTransformation());

                // Then
                AssertEx.IsArgumentNullException(result, "template");
            }
Example #3
0
            public void Should_Render_The_Provided_Template()
            {
                // Given
                var fixture = new TextTransformationFixture();

                fixture.TransformationTemplate.Render().Returns("Hello World");
                var transformation = fixture.CreateTextTransformation();

                // When
                var result = transformation.ToString();

                // Then
                Assert.Equal("Hello World", result);
            }
            public void Should_Render_Content_To_File()
            {
                // Given
                var fixture = new TextTransformationFixture();

                fixture.TransformationTemplate.Render().Returns("Hello World");
                var transformation = fixture.CreateTextTransformation();

                // When
                transformation.Save("./output.txt");

                // Then
                Assert.Equal("Hello World", fixture.FileSystem.GetFile("/Working/output.txt").GetTextContent());
            }
Example #5
0
            public void Should_Render_Content_To_File_With_Specified_Encoding()
            {
                // Given
                var expectedContent = "Hello World";
                var fixture         = new TextTransformationFixture();

                fixture.TransformationTemplate.Render().Returns(expectedContent);
                var transformation = fixture.CreateTextTransformation();

                // When
                transformation.Save("./output.txt", Encoding.UTF8);

                // Then
                var outputFile = fixture.FileSystem.GetFile("/Working/output.txt");

                Assert.True(outputFile.HasUTF8BOM());
                Assert.Equal(expectedContent, outputFile.GetTextContent(Encoding.UTF8));
            }
Example #6
0
            public void Should_Render_Content_To_File()
            {
                // Given
                var expectedContent = "Hello World";
                var fixture         = new TextTransformationFixture();

                fixture.TransformationTemplate.Render().Returns(expectedContent);
                var transformation = fixture.CreateTextTransformation();

                // When
                transformation.Save("./output.txt");

                // Then
                var outputFile = fixture.FileSystem.GetFile("/Working/output.txt");

                Assert.Equal(expectedContent, outputFile.GetTextContent());
                Assert.Equal(expectedContent.Length, outputFile.Length);
            }