Ejemplo n.º 1
0
        public void Execute_Numeric_Format()
        {
            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.GetCultureInfo("en-us");
            var code     = "0000.0000";
            var provider = new FormatTransformer <Decimal>();

            provider.Initialize(code);

            var result = provider.Execute(12.1);

            Assert.That(result, Is.EqualTo("0012.1000"));
        }
Ejemplo n.º 2
0
        public void Execute_DateTime_Format()
        {
            var code     = "MM.yyyy";
            var provider = new FormatTransformer <DateTime>();

            provider.Initialize(code);

            var result = provider.Execute(new DateTime(2016, 5, 12));

            Assert.That(result, Is.EqualTo("05.2016"));

            result = provider.Execute(new DateTime(2016, 10, 12));
            Assert.That(result, Is.EqualTo("10.2016"));
        }
Ejemplo n.º 3
0
        private static void Main(string[] args)
        {
            // Standard to standard with validation
            FormatTransformer <StandardMap> standardTransformer = new FormatTransformer <StandardMap>();

            standardTransformer.TrnasformFile();

            // Source account file #1 with header transformation
            FormatTransformer <CustomMapWithHeader> customHeaderTransformer =
                new FormatTransformer <CustomMapWithHeader>(ConfigurationManager.AppSettings["CustomFormatWithHeaderFileSourcePath"], ConfigurationManager.AppSettings["StandardFileOutputPath"]);

            customHeaderTransformer.TrnasformFile();

            // Source account file #2 without header transformation
            FormatTransformer <CustomMapWithoutHeader> customWithoutHeaderTransformer =
                new FormatTransformer <CustomMapWithoutHeader>(ConfigurationManager.AppSettings["CustomFormatWithoutHeaderFileSourcePath"], ConfigurationManager.AppSettings["StandardFileOutputPath"]);

            customWithoutHeaderTransformer.TrnasformFile();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Converts a FormatTransformer value to a corresponding string value
        /// </summary>
        /// <param name="enumValue">The FormatTransformer value to convert</param>
        /// <returns>The representative string value</returns>
        public static string ToValue(FormatTransformer enumValue)
        {
            switch (enumValue)
            {
            //only valid enum elements can be used
            //this is necessary to avoid errors
            case FormatTransformer.APIMATIC:
            case FormatTransformer.WADL2009:
            case FormatTransformer.SWAGGER10:
            case FormatTransformer.SWAGGER20:
            case FormatTransformer.SWAGGERYAML:
            case FormatTransformer.APIBLUEPRINT:
            case FormatTransformer.RAML:
                return(stringValues[(int)enumValue]);

            //an invalid enum value was requested
            default:
                return(null);
            }
        }
Ejemplo n.º 5
0
        public void Execute_NotInitialized_InvalidOperation()
        {
            var provider = new FormatTransformer <DateTime>();

            Assert.Throws <InvalidOperationException>(delegate { provider.Execute(200); });
        }