コード例 #1
0
        public void CreateFormatterTrivialTest()
        {
            var formatterFactory = new FormatterSimpleFactory(null);

            FormatterSimpleFactory.Formatter formatterNull      = formatterFactory.CreateFormatter(null);
            FormatterSimpleFactory.Formatter formatterNotExists = formatterFactory.CreateFormatter("not existing formatter name asdfasdf");

            Assert.IsTrue(formatterNull == formatterFactory.DefaultFormatter);
            Assert.IsTrue(formatterNotExists == formatterFactory.DefaultFormatter);
        }
コード例 #2
0
        public void CreateFormatterLowercaseTest()
        {
            string message          = "some asdf random ;lkj message";
            var    date             = new DateTime(1993, 03, 11, 2, 25, 35);
            var    formatterFactory = new FormatterSimpleFactory();

            FormatterSimpleFactory.Formatter formatter = formatterFactory.CreateFormatter("Lowercase");

            string formatted = formatter(new Message(message, null, true, date));

            Assert.AreEqual(formatted, "some asdf random ;lkj message");
        }
コード例 #3
0
        public void CreateFormatterStartWithDateTest()
        {
            string message          = "some asdf random ;lkj message";
            var    date             = new DateTime(1993, 03, 11, 2, 25, 35);
            var    formatterFactory = new FormatterSimpleFactory();

            FormatterSimpleFactory.Formatter formatter = formatterFactory.CreateFormatter("Start with DateTime");

            string formatted = formatter(new Message(message, null, true, date));

            Assert.AreEqual(formatted, "[03/11/1993 02:25:35] some asdf random ;lkj message");
        }
コード例 #4
0
        public void CreateFormatterUppercase()
        {
            string message          = "some asdf random ;lkj message";
            var    date             = new DateTime(1993, 03, 11, 2, 25, 35);
            var    formatterFactory = new FormatterSimpleFactory();

            FormatterSimpleFactory.Formatter formatter = formatterFactory.CreateFormatter("Uppercase");

            string formatted = formatter(new Message(message, null, true, date));

            Assert.AreEqual(formatted, "SOME ASDF RANDOM ;LKJ MESSAGE");
        }