Ejemplo n.º 1
0
 public void ReportTest_DeSerialize()
 {
     var reporter = new Reporter.ReportRoot();
     var reporterDes = new Reporter.ReportSerialization();
     Reporter.ReportRoot xmldata = reporterDes.ReportDeserialization("c:\\temp\\bbb.xml");
     Assert.AreEqual("Test Name 123123", xmldata.Summary.TestName);
     Assert.AreEqual("Order Type", xmldata.Details.TestStep[0].InputDatas.InputData[0].FieldName);
 }
Ejemplo n.º 2
0
 public void ReportTest_Initial()
 {
     var reporter = new Reporter.ReportRoot();
     var ReporterSerialization = new Reporter.ReportSerialization();
     var summary = new Reporter.Summary();
     summary.TestName = "asdfasdf";
     reporter.Summary = summary;
     ReporterSerialization.ReportSerialize(reporter, "c:\\temp\\aaa.xml");
 }
Ejemplo n.º 3
0
 public void ReportTest_Initialize()
 {
     //initialize a report
     var reporter = new Reporter.Reporter();
     var report = new Reporter.ReportRoot();
     var RS = new Reporter.ReportSerialization();
     reporter.initialize("Test_Name_1231231234");//don't use space;
     //add details
         //deserializae xml file
     List<Reporter.InputData> inputdata = new List<Reporter.InputData>();
     List<Reporter.OutputData> outputdata = new List<Reporter.OutputData>();
     inputdata.Add(new Reporter.InputData { FieldName="OrderType",FieldValue="ZOR"});
     outputdata.Add (new Reporter.OutputData{FieldName = "DocNo",FieldValue =  "11223344"});
     reporter.AddStep("CaseName001", "Pass", "StepName", 1);
     reporter.AddStep("CaseName002", "Pass", "StepName", 2);
     reporter.updateinputdata("asdfasdf", "true");
     reporter.updateoutputdata("dfasdfasdfs", "false");
     //add details
 }
Ejemplo n.º 4
0
 public void ReportTest_AddTestStep()
 {
     //Deserialization Latest report
     var reporter = new Reporter.ReportRoot();
     var reporterDes = new Reporter.ReportSerialization();
     Reporter.ReportRoot xmldata = reporterDes.ReportDeserialization("c:\\temp\\bbb.xml");
     //add test step info
     reporter = xmldata;
     var inputdatas = new Reporter.InputDatas();
     List<Reporter.InputData> inputdata = new List<Reporter.InputData>();
     var outputdatas = new Reporter.OutputDatas();
     List<Reporter.OutputData> outputdata = new List<Reporter.OutputData>();
     inputdata.Add(new Reporter.InputData { FieldName = "SalesDocNo", FieldValue = "555555" });
     outputdata.Add(new Reporter.OutputData { FieldName = "changed", FieldValue = "true" });
     inputdatas.InputData=inputdata;
     outputdatas.OutputData=outputdata;
     reporter.Details.TestStep.Add(new Reporter.TestStep { CaseName = "va02_asdafsdf", CaseStatus = "Pass", StepName = "va02_stepname", Number = 2, InputDatas = inputdatas, OutputDatas = outputdatas });
     //Serialization new report
     var ReporterSerialization = new Reporter.ReportSerialization();
     ReporterSerialization.ReportSerialize(reporter, "c:\\temp\\bbb.xml");
 }
Ejemplo n.º 5
0
        public void ReportTest_Serialize()
        {
            var reporter = new Reporter.ReportRoot();
            var Summary = new Reporter.Summary();
            var Details = new Reporter.Details();
            List<Reporter.TestStep> TestStep = new List<Reporter.TestStep>();
            Reporter.InputDatas Inputdatas = new Reporter.InputDatas();
            List<Reporter.InputData> Inputdata = new List<Reporter.InputData>();
            Reporter.OutputDatas OutputDatas = new Reporter.OutputDatas();
            List<Reporter.OutputData> OutputData = new List<Reporter.OutputData>();
            Inputdata.Add(new Reporter.InputData {FieldName="Order Type",FieldValue="ZOR" });
            Inputdata.Add(new Reporter.InputData { FieldName = "Organization", FieldValue = "ZZ" });
            Inputdatas.InputData = Inputdata;
            OutputData.Add(new Reporter.OutputData { FieldName = "DocNo", FieldValue = "5555555" });
            OutputDatas.OutputData = OutputData;
            //Inputdatas.Add(new Reporter.InputDatas { InputData = Inputdata });
            TestStep.Add(new Reporter.TestStep {  CaseName="CaseName 123123",CaseStatus="Pass",StepName="va01_createasdfasdf",Number=1,InputDatas=Inputdatas,OutputDatas=OutputDatas});
            Summary.TestName = "Test Name 123123";
            reporter.Summary = Summary;

            Details.TestStep = TestStep;
            reporter.Details = Details;
            //Summary.TestName = "Test Name 123123";
            //TestStep.CaseName = "case name 123";
            //TestStep.CaseStatus = "Pass";
            //TestStep.Number = 1;
            //TestStep.StepName = "va01_createsalesorder";
            //inputdata.FieldName = "order type";
            //inputdata.FieldValue = "ZOR";
            //Inputdatas.InputData = inputdata;
            //TestStep.InputDatas = Inputdatas;
            //Details.TestStep = TestStep;
            //Reporter.Summary = Summary;

            //Reporter.Summary = Reporter.Summary();
            var ReporterSerialization = new Reporter.ReportSerialization();
            ReporterSerialization.ReportSerialize(reporter, "c:\\temp\\aaa.xml");
        }
Ejemplo n.º 6
0
 public void ReportSerialize(ReportRoot rr,string xmlFilePath)
 {
     XmlSerializer serializer = new XmlSerializer(typeof(ReportRoot));
     using (TextWriter writer = new StreamWriter(xmlFilePath))
     {
         serializer.Serialize(writer,rr);
     }
     //add xml header <?xml-stylesheet type='text/xsl' href='../NewReportTemplate2.xsl'?>
     string[] content = File.ReadAllText(xmlFilePath).Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
     content[1] = "<?xml-stylesheet type='text/xsl' href='../NewReportTemplate2.xsl'?>" + "\r\n<ReportRoot>";
     File.WriteAllText(xmlFilePath, string.Join("\r\n", content));
 }
Ejemplo n.º 7
0
 public void updateoutputdata(string fieldname,string fieldvalue)
 {
     string TestOutputPath = "";
     if (File.Exists(@"C:\temp\DriverTemp.txt"))
     {
         FileStream fs = new FileStream(@"c:\temp\DriverTemp.txt", FileMode.Open, FileAccess.Read);
         StreamReader sw = new StreamReader(fs);
         TestOutputPath = sw.ReadLine();
         sw.Close();
         fs.Close();
         fs.Dispose();
         sw.Dispose();
     }
     var reporter = new ReportRoot();
     var reporterDes = new ReportSerialization();
     ReportRoot xmldata = reporterDes.ReportDeserialization(TestOutputPath);
     //add step inputdata
     reporter = xmldata;
     List<OutputData> updatedata = new List<OutputData>();
     OutputDatas updatedatas = new OutputDatas();
     updatedata.Add(new OutputData { FieldName = fieldname, FieldValue = fieldvalue });
     updatedatas.OutputData = updatedata;
     int LastStepNum = reporter.Details.TestStep.Count();
     if (reporter.Details.TestStep[LastStepNum - 1].OutputDatas == null)
     {
         reporter.Details.TestStep[LastStepNum - 1].OutputDatas = updatedatas;
     }
     else
     {
         reporter.Details.TestStep[LastStepNum - 1].OutputDatas.OutputData.Add(new OutputData { FieldName = fieldname, FieldValue = fieldvalue });
     }
     //Serialization new report
     var ReporterSerialization = new ReportSerialization();
     ReporterSerialization.ReportSerialize(reporter, TestOutputPath);
 }
Ejemplo n.º 8
0
        //public string TestOutputPath;
        public void initialize(string TestName)
        {
            string TestOutputPath;
            ReportRoot Report = new ReportRoot();
            ReportSerialization RS = new ReportSerialization();
            var Summary = new Summary();
            Summary.TestName = TestName;
            Report.Summary = Summary;
            string TestFolderName = @"C:\Temp\" + TestName;
            TestOutputPath = @"C:\Temp\" + TestName+"\\output.xml";
            if (!Directory.Exists(TestFolderName))
            {
                Directory.CreateDirectory(TestFolderName);
            }
            if(!File.Exists(@"C:\temp\DriverTemp.txt"))
            {
                FileStream fs = new FileStream(@"C:\temp\DriverTemp.txt", FileMode.Create, FileAccess.Write);
                StreamWriter sw = new StreamWriter(fs);
                sw.WriteLine(TestOutputPath);
                sw.Close();
                fs.Close();
            }
            else
            {
                close();
                FileStream fs = new FileStream(@"C:\temp\DriverTemp.txt", FileMode.Create, FileAccess.Write);
                StreamWriter sw = new StreamWriter(fs);
                sw.WriteLine(TestOutputPath);
                sw.Close();
                fs.Close();
            }
            RS.ReportSerialize(Report, TestOutputPath);

            //return TestOutputPath;
        }
Ejemplo n.º 9
0
        public void AddStep(string CaseName,string CaseStatus,string StepName,int Number)
        {
            string TestOutputPath = "";
            if(File.Exists(@"C:\temp\DriverTemp.txt"))
            {
                FileStream fs = new FileStream(@"c:\temp\DriverTemp.txt",FileMode.Open,FileAccess.Read);
                StreamReader sw = new StreamReader(fs);
                TestOutputPath = sw.ReadLine();
            }

            var reporter = new ReportRoot();
            var reporterDes = new ReportSerialization();
            ReportRoot xmldata = reporterDes.ReportDeserialization(TestOutputPath);
            //add test step info
            reporter = xmldata;
            var inputdatas = new InputDatas();
            var outputdatas = new OutputDatas();
            //inputdatas.InputData = inputdata;
            //outputdatas.OutputData = outputdata;
            List<TestStep> teststep = new List<TestStep>();
            if (reporter.Details != null)
            {
                teststep = reporter.Details.TestStep;
            }
            teststep.Add(new TestStep { CaseName = CaseName, CaseStatus = CaseStatus, StepName = StepName, Number = Number, InputDatas = null, OutputDatas = null });
            Details details = new Details();
            details.TestStep = teststep;
            reporter.Details = details;
            //Serialization new report
            var ReporterSerialization = new ReportSerialization();
            ReporterSerialization.ReportSerialize(reporter, TestOutputPath);
        }