Пример #1
0
        public void Content_Newline_Gets_Converted_To_Html_Br()
        {
            var message = new ServiceMessage();
            message.Content = "Test\r\n";

            Assert.That(message.ContentHtml, Is.EqualTo("Test<br />"));
        }
Пример #2
0
        private static void WriteMesaageFile(ServiceMessage message, string content)
        {
            if (string.IsNullOrEmpty(message.Book))
                message.Book = "{Book}";

            if (string.IsNullOrEmpty(message.Chapter))
                message.Chapter = "{Chapter}";

            if (string.IsNullOrEmpty(message.Title))
                message.Title = "{Title}";

            string fileName = string.Format("c:\\temp\\{0} {1} {2} {3} {4}", message.Year, message.Book, message.LectureNo, CleanUpForFileName(message.Chapter),
                CleanUpForFileName(message.Title));
            File.WriteAllText(fileName, content);
        }
Пример #3
0
        public void Should_Save_To_A_File()
        {
            var message = new ServiceMessage
                              {
                                  Content = "The first words of the bible are",
                                  Book = "Genesis",
                                  Chapter = "Ch 1:1-25",
                                  LectureNo = 1,
                                  Year = 2012,
                                  Title = "IN THE BEGINNING \"God\""
                              };

            string text = JsonSerializer.SerializeToString(message);
            File.WriteAllText(@"c:\temp\test.json", text);

            Assert.That(text, Is.EqualTo(""));
        }
Пример #4
0
        public ServiceMessage Parse(string content)
        {
            var message = new ServiceMessage();

            var lines = CleanUp(content);

            string[] yearBookLectureNoline = lines[0].Split(' ');
            message.Year = yearBookLectureNoline.Length >= 1 ? ParseInt(yearBookLectureNoline[0]) : 0;
            message.Book = yearBookLectureNoline.Length >= 2 ? yearBookLectureNoline[1] : "{Book}";
            message.LectureNo = yearBookLectureNoline.Length >= 3 ? ParseInt(yearBookLectureNoline[2]) : 0;

            message.Title = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(lines[1].Trim().ToLower());

            string[] chapterLine = lines[2].Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            message.Chapter = chapterLine.Length >= 2 ? chapterLine[1] : "{Chapter}";

            return message;
        }