예제 #1
0
        public void Test_TextSubstitutor_Ok()
        {
            MessageTemplate template = new MessageTemplate
            {
                Id           = 1,
                Kind         = "TestKind",
                Culture      = "en",
                Subject      = "This is the Subject",
                BodyTemplate = "Hello, {0}. The time is now {1}"
            };

            TextSubstitutor substitutor = new TextSubstitutor();

            DateTime             now        = DateTime.Now;
            IEnumerable <object> parameters = new List <object>
            {
                "World",
                now
            };

            string actual   = substitutor.Substitute(template, parameters);
            string expected = $"Hello, World. The time is now {now}";

            Assert.AreEqual(expected, actual);
        }
예제 #2
0
        public void TestSubstitutionMissingParameter()
        {
            MessageTemplate template = new MessageTemplate
            {
                Id      = 1,
                Culture = "en",
                Text    = "Hello, {0}. The time is now {1}, but not {2}"
            };

            TextSubstitutor substitutor = new TextSubstitutor();

            DateTime             now        = DateTime.Now;
            IEnumerable <object> parameters = new List <object>
            {
                "World",
                now
            };

            string actual = substitutor.Substitute(template, parameters);
        }