コード例 #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
ファイル: Program.cs プロジェクト: andrewchaa/LondonUbf
        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;
        }