Esempio n. 1
0
        protected VirtualJournal CreateVirtualJournal(int yearStart, int yearEnd, bool onlyValidEntries = false)
        {
            var samples    = onlyValidEntries ? ValidJournalSamples : ValidJournalSamples.Concat(InvalidJournalSamples).ToList();
            var fileSystem = new VirtualJournal();

            for (var year = yearStart; year <= yearEnd; year++)
            {
                foreach (var month in Enumerable.Range(1, 12))
                {
                    var monthName   = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(month);
                    var currentPath = $@"J:\Current\{year}\{month:00} {monthName}";
                    fileSystem.AddDirectory(currentPath);

                    foreach (var day in Enumerable.Range(1, 28))
                    {
                        var dt       = new LocalDate(year, month, day);
                        var filePath = fileSystem.Path.Combine(currentPath, dt.ToJournalEntryFileName());
                        var index    = _random.Next(0, samples.Count - 1);

                        var text = samples[index];
                        fileSystem.AddFile(filePath, new MockFileData(text));

                        if (text == TestEntries.WithTagsAndReadme)
                        {
                            fileSystem.TotalReadmeEntries++;
                        }
                    }
                }
            }

            return(fileSystem);
        }
Esempio n. 2
0
        protected VirtualJournal CreateEmptyJournal()
        {
            var fileSystem = new VirtualJournal();

            fileSystem.AddDirectory(@"J:\Current\");
            return(fileSystem);
        }