public void Setup()
        {
            this.file = MockRepository.GenerateStub<IFile>();
            this.converter = MockRepository.GeneratePartialMock<FileNameConverter>();

            this.fileRenamer = new FileRenamer(this.file, this.converter, testFileNames);
        }
Exemplo n.º 2
0
        private static int ConvertFileName(FileNameConverter fileNameConverter)
        {
            List <BlogExcerptModel> blogList = new List <BlogExcerptModel>();
            var folder = fileNameConverter.FolderPath.Trim();

            foreach (var file in Directory.GetFiles(folder, "*.md"))
            {
                var blog = ParseBlog(file);

                if (blog == null)
                {
                    continue;
                }

                var fileName = BlogNameConverter.ConvertTitleToFileName(blog.Title);
                fileName     += ".md";
                blog.FileName = fileName;
                Debug.WriteLine(fileName);
                File.Move(file, Path.Combine(folder, fileName), true);

                blogList.Add(blog);
            }

            blogList.Sort(new BlogExcerptModelComparer());
            blogList.Reverse();

            var json = JsonSerializer.Serialize(blogList, new JsonSerializerOptions()
            {
                IgnoreNullValues = true,
                WriteIndented    = false,
            });

            File.WriteAllText(Path.Combine(folder, "Summary.json"), json);

            File.WriteAllText(Path.Combine(folder, "FileList.txt"), string.Join("\n", blogList.Select(temp => temp.Title)));

            var pageCount = blogList.Count * 1.0 / MaxBlogPrePage;

            for (int i = 0; i < pageCount; i++)
            {
                BlogPageModel blogPage = new BlogPageModel
                {
                    PageCount = (int)pageCount,
                    BlogList  = blogList.Skip(i * MaxBlogPrePage).Take(MaxBlogPrePage).ToList()
                };

                json = JsonSerializer.Serialize(blogPage, new JsonSerializerOptions()
                {
                    IgnoreNullValues = true,
                    WriteIndented    = false,
                });

                File.WriteAllText(Path.Combine(folder, $"Summary-{i}.json"), json);
            }

            return(0);
        }
 public void Setup()
 {
     m_converter = new FileNameConverter {
         MaximumFileNameLenght = 123, IllegalCharacters = m_illegalCharacters
     };
 }
 public void Setup()
 {
     this.renamer = new FileNameConverter();
 }
Exemplo n.º 5
0
 public void Setup()
 {
     _converter = new FileNameConverter();
 }