Пример #1
0
        public static void JsonDeserialize()
        {
            string myJson = @"{'TestCaseName': 'Testcase1', 'TestInput': 'Inputul meu', 'OtherInfo': 'Alte informatii'}";

            ScenarioDto myObject = JsonConvert.DeserializeObject <ScenarioDto>(myJson);

            Console.WriteLine(myObject.TestCaseName);
        }
Пример #2
0
        static void Main(string[] args)
        {
            string[] lines = { "Linia 1", "Linia 2", "Linia 3", "Linia 4", "Linia 5" };

            ////System.IO.File.WriteAllLines(@"C:\Users\radu.flitar\DEV\Learning\AgileHub\AutomationTestingAgileHub\ReadWriteFromFiles\WriteLinesSample.txt", lines);


            //string text = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. ";

            //using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Users\radu.flitar\DEV\Learning\AgileHub\AutomationTestingAgileHub\ReadWriteFromFiles\WriteLinesSample.txt", true) )
            //{
            //    foreach (var line in lines)
            //    {
            //        if(line.Contains("3"))
            //        {
            //            file.WriteLine(line);
            //        }

            //    }
            //}

            //string [] readLines = System.IO.File.ReadAllLines(@"C:\Users\radu.flitar\DEV\Learning\AgileHub\AutomationTestingAgileHub\ReadWriteFromFiles\WriteLinesSample.txt");
            //string readText = System.IO.File.ReadAllText(@"C:\Users\radu.flitar\DEV\Learning\AgileHub\AutomationTestingAgileHub\ReadWriteFromFiles\WriteLinesSample.txt");

            //foreach (var line in readLines)
            //{
            //    Console.WriteLine(line);
            //}

            //string line;
            //System.IO.StreamReader file = new System.IO.StreamReader(@"C:\Users\radu.flitar\DEV\Learning\AgileHub\AutomationTestingAgileHub\ReadWriteFromFiles\WriteLinesSample.txt");

            //while ((line = file.ReadLine()) != string.Empty)
            //{
            //    Console.WriteLine(line);
            //}

            //file.Close();
            //System.IO.File.WriteAllText(@"C:\Users\radu.flitar\DEV\Learning\AgileHub\AutomationTestingAgileHub\ReadWriteFromFiles\WriteLinesSample.txt", text);

            // ScenarioDto.WriteXML();

            //var myScenario = ScenarioDto.ReadXML();

            // Console.WriteLine($"Numele scenariului este {myScenario.TestCaseName}, numele proprieatii este {myScenario.TestInput}, numele proprietatii 3 este {myScenario.OtherInfo}");



            var myList = ScenarioDto.LoadValuesFromJsonFIle();

            foreach (var element in myList)
            {
                Console.WriteLine($" elementul {myList.IndexOf(element)}: {element.TestCaseName}, {element.TestInput}, {element.OtherInfo}, numarul de valori in campul Values {element.Values.Count}");
            }
            Console.ReadKey();
        }
Пример #3
0
        public static void WriteXML()
        {
            ScenarioDto myScenario = new ScenarioDto();

            myScenario.TestCaseName = "Scenariul1";
            myScenario.TestInput    = "*****@*****.**";
            myScenario.OtherInfo    = "password123";
            System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(ScenarioDto));

            var path = @"C:\Users\radu.flitar\DEV\Learning\AgileHub\AutomationTestingAgileHub\ReadWriteFromFiles\WriteInXML.xml";

            System.IO.FileStream file = System.IO.File.Create(path);

            writer.Serialize(file, myScenario);

            file.Close();
        }
Пример #4
0
        //public static ScenarioDto ReadXML()
        //{
        //    System.Xml.Serialization.XmlSerializer reader = new System.Xml.Serialization.XmlSerializer(typeof(ScenarioDto));

        //    var path = @"C:\Users\radu.flitar\DEV\Learning\AgileHub\AutomationTestingAgileHub\ReadWriteFromFiles\WriteInXML.xml";

        //    System.IO.StreamReader file = new System.IO.StreamReader(path);

        //    ScenarioDto myScenarioDto = (ScenarioDto)reader.Deserialize(file);

        //    file.Close();

        //    return myScenarioDto;
        //}

        public static void JsonSerialize()
        {
            ScenarioDto myObject = new ScenarioDto
            {
                TestCaseName = "Testcase1",
                TestInput    = "Inputul meu",
                OtherInfo    = "Alte informatii",
                Values       = new List <string> {
                    "value1", "value2", "value3"
                }
            };



            //string myJson = JsonConvert.SerializeObject(myObject, Formatting.Indented);

            //File.WriteAllText(@"C:\Users\radu.flitar\DEV\Learning\AgileHub\AutomationTestingAgileHub\ReadWriteFromFiles\ReadWriteFromFiles\MyJsonExample.json", JsonConvert.SerializeObject(myObject, Formatting.Indented));
            using (StreamWriter file = File.CreateText(@"C:\Users\radu.flitar\DEV\Learning\AgileHub\AutomationTestingAgileHub\ReadWriteFromFiles\ReadWriteFromFiles\MyJsonExample2.json"))
            {
                JsonSerializer serializator = new JsonSerializer();
                serializator.Serialize(file, myObject);
            }
            Console.WriteLine("Fisierul json a fost creat");
        }