Exemplo n.º 1
0
            public void FileNameIsConvertedCorrectly(string input, string output)
            {
                // Given
                Engine engine = new Engine();
                Pipeline pipeline = new Pipeline("Pipeline", null);
                IExecutionContext context = new ExecutionContext(engine, pipeline);
                IDocument[] inputs = { context.GetDocument(new MetadataItems
                {
                    new MetadataItem(Keys.SourceFileName, input)
                }) };
                FileName fileName = new FileName();

                // When
                IEnumerable<IDocument> documents = fileName.Execute(inputs, context);

                // Then
                Assert.AreEqual(output, documents.First().FilePath(Keys.WriteFileName).FullPath);
            }
Exemplo n.º 2
0
        public void FileNameIsConvertedCorrectly(string input, string output)
        {
            // Given
            Engine engine = new Engine();
            engine.Trace.AddListener(new TestTraceListener());
            Pipeline pipeline = new Pipeline("Pipeline", engine, null);
            IExecutionContext context = new ExecutionContext(engine, pipeline);
            IDocument[] inputs = { new Document(engine, pipeline).Clone(new []
            {
                new MetadataItem(Keys.SourceFileName, input)
            }) };
            FileName fileName = new FileName();

            // When
            IEnumerable<IDocument> documents = fileName.Execute(inputs, context);

            // Then
            Assert.AreEqual(output, documents.First()[Keys.WriteFileName]);
        }
Exemplo n.º 3
0
            public void FileNameIsConvertedCorrectlyWithReservedChar(string character)
            {
                // Given
                Engine engine = new Engine();
                Pipeline pipeline = new Pipeline("Pipeline", null);
                IExecutionContext context = new ExecutionContext(engine, pipeline);
                string manyCharactersWow = new String(character[0], 10);
                IDocument[] inputs = { context.GetDocument(new MetadataItems
                {
                    new MetadataItem(Keys.SourceFileName,
                        string.Format("testing {0} some of {0} these {0}", manyCharactersWow))
                }) };
                FileName fileName = new FileName();

                // When
                IEnumerable<IDocument> documents = fileName.Execute(inputs, context);

                // Then
                Assert.AreEqual("testing-some-of-these-", documents.First()[Keys.WriteFileName]);
            }
Exemplo n.º 4
0
		    public void FileNameShouldBeLowercase()
		    {
			    // Given
			    string input = "FileName With MiXeD CapS";
			    string output = "filename-with-mixed-caps";

                Engine engine = new Engine();
			    Pipeline pipeline = new Pipeline("Pipeline", null);
			    IExecutionContext context = new ExecutionContext(engine, pipeline);
			    IDocument[] inputs = { context.GetDocument(new MetadataItems
			    {
                    new MetadataItem(Keys.SourceFileName, new FilePath(input))
			    }) };
			    FileName fileName = new FileName();

			    // When
			    IEnumerable<IDocument> documents = fileName.Execute(inputs, context);

			    // Then
			    Assert.AreEqual(output, documents.First().FilePath(Keys.WriteFileName).FullPath);
		    }
Exemplo n.º 5
0
		public void FileNameShouldBeLowercase()
		{
			// Given
			string input = "FileName With MiXeD CapS";
			string output = "filename-with-mixed-caps";

            Engine engine = new Engine();
			engine.Trace.AddListener(new TestTraceListener());
			Pipeline pipeline = new Pipeline("Pipeline", engine, null);
			IExecutionContext context = new ExecutionContext(engine, pipeline);
			IDocument[] inputs = { new Document(engine, pipeline).Clone(new []
			{
                new MetadataItem(Keys.SourceFileName, input)
			}) };
			FileName fileName = new FileName();

			// When
			IEnumerable<IDocument> documents = fileName.Execute(inputs, context);

			// Then
			Assert.AreEqual(output, documents.First()[Keys.WriteFileName]);
		}
Exemplo n.º 6
0
		public void WithAllowedCharactersDoesNotReplaceProvidedCharacters()
		{
			// Given
			string input = "this-is-a-.net-tag";
			string output = "this-is-a-.net-tag";

			Engine engine = new Engine();
			engine.Trace.AddListener(new TestTraceListener());
			Pipeline pipeline = new Pipeline("Pipeline", engine, null);
			IExecutionContext context = new ExecutionContext(engine, pipeline);
			IDocument[] inputs = { new Document(engine, pipeline).Clone(new []
			{
                new MetadataItem(Keys.SourceFileName, input)
			}) };
			FileName fileName = new FileName();

			// When
			fileName = fileName.WithAllowedCharacters(new string[] { "-" });
			IEnumerable<IDocument> documents = fileName.Execute(inputs, context);

			// Then
			Assert.AreEqual(output, documents.First()[Keys.WriteFileName]);
        }
Exemplo n.º 7
0
            public void WithAllowedCharactersDoesNotReplaceDotAtEnd()
            {
                // Given
                string input = "this-is-a-.";
                string output = "thisisa.";

                Engine engine = new Engine();
                Pipeline pipeline = new Pipeline("Pipeline", null);
                IExecutionContext context = new ExecutionContext(engine, pipeline);
                IDocument[] inputs = { context.GetDocument(new MetadataItems
                {
                    new MetadataItem(Keys.SourceFileName, new FilePath(input))
                }) };
                FileName fileName = new FileName();

                // When
                fileName = fileName.WithAllowedCharacters(new string[] { "." });
                IEnumerable<IDocument> documents = fileName.Execute(inputs, context);

                // Then
                Assert.AreEqual(output, documents.First().FilePath(Keys.WriteFileName).FullPath);
            }
Exemplo n.º 8
0
            public void TrimWhitespace()
            {
                // Given
                string input = "   myfile.html   ";
                string output = "myfile.html";

                Engine engine = new Engine();
                Pipeline pipeline = new Pipeline("Pipeline", null);
                IExecutionContext context = new ExecutionContext(engine, pipeline);
                IDocument[] inputs =
                {
                    context.GetDocument(new MetadataItems
                    {
                        new MetadataItem("MyKey", input)
                    })
                };
                FileName fileName = new FileName("MyKey");

                // When
                IEnumerable<IDocument> documents = fileName.Execute(inputs, context);

                // Then
                Assert.AreEqual(output, documents.First().FilePath(Keys.WriteFileName).FullPath);
            }
Exemplo n.º 9
0
            public void IgnoresNullOrWhiteSpaceStrings(string input)
            {
                // Given
                Engine engine = new Engine();
                Pipeline pipeline = new Pipeline("Pipeline", null);
                IExecutionContext context = new ExecutionContext(engine, pipeline);
                IDocument[] inputs = { context.GetDocument(new MetadataItems
                {
                    new MetadataItem(Keys.SourceFileName, input)
                }) };
                FileName fileName = new FileName();

                // When
                IEnumerable<IDocument> documents = fileName.Execute(inputs, context);

                // Then
                Assert.IsFalse(documents.First().ContainsKey(Keys.WriteFileName));
            }
Exemplo n.º 10
0
        public void TrimWhitespace()
        {
            // Given
            string input = "   myfile.html   ";
            string output = "myfile.html";

            Engine engine = new Engine();
            engine.Trace.AddListener(new TestTraceListener());
            Pipeline pipeline = new Pipeline("Pipeline", engine, null);
            IExecutionContext context = new ExecutionContext(engine, pipeline);
            IDocument[] inputs =
            {
                new Document(engine, pipeline).Clone(new []
                {
                    new MetadataItem("MyKey", input)
                })
            };
            FileName fileName = new FileName("MyKey");

            // When
            IEnumerable<IDocument> documents = fileName.Execute(inputs, context);

            // Then
            Assert.AreEqual(output, documents.First()[Keys.WriteFileName]);
        }