Пример #1
0
        public void ApllyDateAndTimeFormatTest()
        {
            var Formatter = new Formatter();

            FormatStorage.GetFormatStorageInstance().ChangeFormat(FormatStorage.Formats.DateAndTime);

            var actualText = Formatter.ApplyFormat(message);

            var expectedText = $"From: TestSender : {DateTime.MinValue} : Test text";

            Assert.AreEqual(expectedText, actualText);
        }
Пример #2
0
        public void ApllyNoFormatTest()
        {
            var Formatter = new Formatter();

            FormatStorage.GetFormatStorageInstance().ChangeFormat(FormatStorage.Formats.Unformatted);

            var actualText = Formatter.ApplyFormat(message);

            var expectedText = "From: TestSender : Test text";

            Assert.AreEqual(expectedText, actualText);
        }
Пример #3
0
 public void Write(ICollection messages)
 {
     if (Form.InvokeRequired)
     {
         var del = new GuiDelegate(Write);
         Form.BeginInvoke(del, messages);
     }
     else
     {
         Form.richTextBox2.Clear();
         foreach (var message in messages)
         {
             var formattedMessage = Formatter.ApplyFormat((Message)message);
             Form.richTextBox2.SelectionStart  = 0;
             Form.richTextBox2.SelectionLength = 0;
             Form.richTextBox2.SelectedText    = "\r\n" + formattedMessage;
         }
     }
 }
Пример #4
0
        public void ApllyUnknownFormatTest()
        {
            var Formatter = new Formatter();

            int[] formats   = (int[])typeof(FormatStorage.Formats).GetEnumValues();
            var   maxFormat = formats.Max();

            maxFormat++;
            FormatStorage.GetFormatStorageInstance().ChangeFormat((FormatStorage.Formats)maxFormat);
            var success = true;

            try
            {
                var actualText = Formatter.ApplyFormat(message);
            }
            catch (InvalidEnumArgumentException ex)
            {
                success = false;
            }

            Assert.IsFalse(success);
        }