Exemplo n.º 1
0
        /// <summary>
        /// from YAML to CLI_Commands
        /// </summary>
        /// <param name="text">The text.</param>
        /// <returns>CLI_Commands</returns>
        public static CLI_Commands DeSerialize(string text)
        {
            var i = new Interpret();

            text = i.InterpretText(text);
            var serializer = new DeserializerBuilder()
                             //.WithNamingConvention(CamelCaseNamingConvention.Instance)
                             .Build();

            return(serializer.Deserialize <CLI_Commands>(text));
        }
Exemplo n.º 2
0
        public void InterpretTextNone()
        {
            #region arrange
            string textToInterpret = RandomString(22);
            #endregion
            #region act

            var i   = new Interpret();
            var str = i.InterpretText(textToInterpret);
            #endregion
            #region assert
            Assert.AreEqual(textToInterpret, str);
            #endregion
        }
Exemplo n.º 3
0
        private int OnExecute()
        {
            Console.WriteLine($"processing files accordingly to settings from {Name}");
            var i       = new Interpret();
            var text    = i.InterpretText(File.ReadAllText(Name));
            var rewrite = RewriteAction.UnSerializeMe(text);

            rewrite.Rewrite();
            return(0);
            //for (var i = 0; i < Count; i++)
            //{
            //    Console.WriteLine($"Hello {Name}!");
            //}
            //return 0;
        }
Exemplo n.º 4
0
        public void InterpretDateTimeUtcNow()
        {
            #region arrange
            string textToInterpret = "this is from #utcnow:yyyyMMddHHmmss#";
            #endregion
            #region act

            var i = new Interpret();
            i.TwoSlashes = false;
            var str = i.InterpretText(textToInterpret);
            #endregion
            #region assert
            Console.WriteLine("interpreted: " + str);
            str.Should().Contain($"this is from {DateTime.UtcNow.ToString("yyyyMMdd")}");
            #endregion
        }
Exemplo n.º 5
0
        public void InterpretGuid()
        {
            #region arrange
            string textToInterpret = "#guid:n#";
            #endregion
            #region act

            var i = new Interpret();
            i.TwoSlashes = false;
            var str = i.InterpretText(textToInterpret);
            #endregion
            #region assert
            Console.WriteLine("interpreted: " + str);
            str.Should().HaveLength(32);
            var g = new Guid(str);
            //g should exists without error
            #endregion
        }
Exemplo n.º 6
0
        public void InterpretSettingsFile()
        {
            #region arrange
            string textToInterpret = "this is from #file:SqlServerConnectionString#";
            #endregion
            #region act

            var i   = new Interpret();
            var str = i.InterpretText(textToInterpret);
            #endregion
            #region assert
            Console.WriteLine("interpreted: " + str);
            Assert.IsFalse(str.Contains("#"), "should be interpreted");
            Assert.IsTrue(str.Contains("this is from"), "should contain first chars");
            //Assert.IsTrue(str.Contains("atabase"),"should contain database");
            Assert.IsTrue(str.Contains("rusted"), "should containt trusted connection");
            #endregion
        }
Exemplo n.º 7
0
        public void InterpretStaticParameterString()
        {
            #region arrange
            string textToInterpret = "this is @static:System.IO.Path.GetFileNameWithoutExtension(#env:solutionPath#)@";
            Environment.SetEnvironmentVariable("solutionPath", "a.sln");

            #endregion
            #region act

            var i = new Interpret();
            i.TwoSlashes = false;
            var str = i.InterpretText(textToInterpret);
            #endregion
            #region assert

            str.Should().Be($"this is a");
            #endregion
        }
Exemplo n.º 8
0
        public void InterpretStaticOneParameter()
        {
            #region arrange
            string textToInterpret = "this is from #static:DateTime.Today#";
            textToInterpret += " and #static:Directory.GetCurrentDirectory()#";

            #endregion
            #region act

            var i = new Interpret();
            i.TwoSlashes = false;
            var str = i.InterpretText(textToInterpret);
            #endregion
            #region assert
            Console.WriteLine("interpreted: " + str);
            str.Should().Be($"this is from {DateTime.Today.ToString()} and {Directory.GetCurrentDirectory()}");
            #endregion
        }
        public override void UnSerialize(string serializeData)
        {
            var settings = new JsonSerializerSettings()
            {
                TypeNameHandling = TypeNameHandling.Objects,
                Formatting       = Formatting.Indented,
                //Error = HandleDeserializationError
                //ConstructorHandling= ConstructorHandling.AllowNonPublicDefaultConstructor
            };

            settings.Converters.Add(new JsonEncodingConverter());
            var i       = new Interpret();
            var newText = i.InterpretText(serializeData);
            var sj      = (SimpleJobConditionalTransformers)JsonConvert.DeserializeObject(newText, settings);

            this.association = sj.association;
            this.Receivers   = sj.Receivers;
        }
Exemplo n.º 10
0
        public void InterpretStaticTwoParameterString()
        {
            #region arrange

            string textToInterpret = "this is @static:Path.GetPathRoot(#static:Directory.GetCurrentDirectory()#)@";


            #endregion
            #region act

            var i = new Interpret();
            i.TwoSlashes = false;
            var str = i.InterpretText(textToInterpret);
            #endregion
            #region assert

            string s = Path.GetPathRoot(Directory.GetCurrentDirectory());
            str.Should().Be($"this is {s}");
            #endregion
        }
Exemplo n.º 11
0
        public void InterpretEnv()
        {
            #region arrange
            string textToInterpret = "";
            string textInterpreted = "";
            var    var             = Environment.GetEnvironmentVariables();
            foreach (var item in var.Keys)
            {
                var randomString = RandomString(10);
                textToInterpret += randomString + "#env:" + item + "#" + Environment.NewLine;
                textInterpreted += randomString + var[item] + Environment.NewLine;
                continue;
            }
            #endregion
            #region act
            var i = new Interpret();
            i.TwoSlashes = false;
            var str = i.InterpretText(textToInterpret);
            #endregion
            #region assert
            Assert.AreEqual(textInterpreted, str);

            #endregion
        }