Ejemplo n.º 1
0
        public void convert_values_uses_the_specified_culture()
        {
            var converter = new FormatConverter();

            converter.FormatString = "Value 1: {0:00.00} and value 2: {1:00.00}";
            Assert.Equal("Value 1: 26,00 and value 2: 27,00", converter.Convert(new object[] { 26, 27 }, null, null, new CultureInfo("de-DE")));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 創建縮略圖
        /// </summary>
        /// <typeparam name="T">IFileUploadResult</typeparam>
        /// <param name="pResults">文件集合</param>
        /// <param name="serverRPath">服務器存放相對路徑</param>
        /// <param name="thumbHeadName">縮略圖頭名稱</param>
        protected void ConvertAndCreateThumb <T>(List <T> pResults, string serverRPath, string thumbHeadName)
            where T : IFileUploadResult, new()
        {
            string strThumbFileName = string.Empty;
            string serverAPath      = serverRPath.Replace("/", @"\");
            //轉換操作
            FormatConverter pCon = new FormatConverter();

            foreach (T pT in pResults)
            {
                // 25487815728572_stb.mp4
                strThumbFileName = string.Format("{0}{1}", pT.FileName, thumbHeadName);
                //
                string err = pCon.Convert(pT.APath, serverAPath, strThumbFileName, FormatConverter.VideoType.MP4, true, true);
                if (!string.IsNullOrEmpty(err))
                {
                    EGExceptionOperator.ThrowX <Exception>(err, EGActionCode.文件上传失败);
                }
                else
                {
                    pT.APath      = pT.APath.Replace(pT.FileName, strThumbFileName);
                    pT.FileName   = strThumbFileName;
                    pT.RPath      = string.Format("{0}/{1}.{2}", serverRPath, strThumbFileName, pT.FormatName);
                    pT.RPathThumb = string.Format("{0}/{1}.{2}", serverRPath, strThumbFileName, "jpg");
                }
            }
        }
Ejemplo n.º 3
0
        public void convert_value_throws_if_format_string_is_null()
        {
            var converter = new FormatConverter();
            var ex        = Assert.Throws <InvalidOperationException>(() => converter.Convert(27, null, null, null));

            Assert.Equal("No FormatString has been specified.", ex.Message);
        }
 private void Assert(string markdown, string expectedHtml)
 {
     var converter = new FormatConverter<HtmlData>(
     new MarkdownDataBuilder(markdown), new PlainToHtmlConverter());
       var actual = converter.Convert().Content;
       NUnit.Framework.Assert.AreEqual(expectedHtml, actual);
 }
Ejemplo n.º 5
0
        public void convert_values_formats_the_value_using_the_format_string()
        {
            var converter = new FormatConverter();

            converter.FormatString = "Value 1: {0} and value 2: {1}";
            Assert.Equal("Value 1: 26 and value 2: 27", converter.Convert(new object[] { 26, 27 }, null, null, null));
        }
 public void convert_value_uses_the_specified_culture()
 {
     var converter = new FormatConverter
     {
         FormatString = "{0:00.00}"
     };
     Assert.Equal("01,00", converter.Convert(1d, null, null, new CultureInfo("de-DE")));
 }
 public void convert_value_formats_the_value_using_the_format_string()
 {
     var converter = new FormatConverter
     {
         FormatString = "{0:00.00}"
     };
     Assert.Equal("01.00", converter.Convert(1d, null, null, null));
 }
Ejemplo n.º 8
0
        public void convert_value_uses_the_specified_culture()
        {
            var converter = new FormatConverter
            {
                FormatString = "{0:00.00}"
            };

            Assert.Equal("01,00", converter.Convert(1d, null, null, new CultureInfo("de-DE")));
        }
Ejemplo n.º 9
0
        public void convert_value_formats_the_value_using_the_format_string()
        {
            var converter = new FormatConverter
            {
                FormatString = "{0:00.00}"
            };

            Assert.Equal("01.00", converter.Convert(1d, null, null, null));
        }
Ejemplo n.º 10
0
        static void Main(string[] args)
        {
            if (args.Length != 1)
              {
            Console.WriteLine("Usage: Homework.exe <filename>");
            return;
              }

              var fileName = args[0];
              var rawData = File.ReadAllText(fileName);
              var converter = new FormatConverter<HtmlData>(
            new MarkdownDataBuilder(rawData), new PlainToHtmlConverter());
              File.WriteAllText(BuildHtmlFileName(fileName), converter.Convert().Content);
        }
 public void convert_values_throws_if_format_string_is_null()
 {
     var converter = new FormatConverter();
     var ex = Assert.Throws<InvalidOperationException>(() => converter.Convert(new object[] { 26, 27 }, null, null, null));
     Assert.Equal("No FormatString has been specified.", ex.Message);
 }
 public void convert_values_uses_the_specified_culture()
 {
     var converter = new FormatConverter();
     converter.FormatString = "Value 1: {0:00.00} and value 2: {1:00.00}";
     Assert.Equal("Value 1: 26,00 and value 2: 27,00", converter.Convert(new object[] { 26, 27 }, null, null, new CultureInfo("de-DE")));
 }
 public void convert_values_formats_the_value_using_the_format_string()
 {
     var converter = new FormatConverter();
     converter.FormatString = "Value 1: {0} and value 2: {1}";
     Assert.Equal("Value 1: 26 and value 2: 27", converter.Convert(new object[] { 26, 27 }, null, null, null));
 }