コード例 #1
0
        public void Test_FormatWith_Property_Not_Found_Throws_Exception()
        {
            string template = "Name: {Name}, Capital: {Capital}, GdpPerCapita: {GdpPerCapita:F4}, NotFound: {NotFound}";
            var    model    = new FormatWithModel {
                Name = "Malawi", Capital = "Lilongwe", GdpPerCapita = 226.50
            };

            Assert.Throws <ParsingException>(() => template.FormatWith(model, true));
        }
コード例 #2
0
        public void Test_FormatWith_Property_Not_Found()
        {
            string template = "Name: {Name}, Capital: {Capital}, GdpPerCapita: {GdpPerCapita:F4}, NotFound: {NotFound}";
            var    model    = new FormatWithModel {
                Name = "Malawi", Capital = "Lilongwe", GdpPerCapita = 226.50
            };

            var sut = template.FormatWith(model);

            Assert.Equal("Name: Malawi, Capital: Lilongwe, GdpPerCapita: 226.5000, NotFound: {NotFound}", sut);
        }
コード例 #3
0
        public void Test_FormatWith_Properties_Found()
        {
            string template = "Name: {Name}, Capital: {Capital}, GdpPerCapita: {GdpPerCapita:F4}, NestedClass.ProjectId: {NestedClass.ProjectId}";
            var    model    = new FormatWithModel {
                Name = "Malawi", Capital = "Lilongwe", GdpPerCapita = 226.50, NestedClass = { ProjectId = "1234" }
            };

            var sut = template.FormatWith(model);

            Assert.Equal("Name: Malawi, Capital: Lilongwe, GdpPerCapita: 226.5000, NestedClass.ProjectId: 1234", sut);
        }