コード例 #1
0
        public void Execute(Project project)
        {
            this.project = project;

            Initialize();

            LOG.InfoFormat("Start testing: {0}", project.Name);

            if (!string.IsNullOrEmpty(this.settings.TestSet))
            {
                if (this.project.HasTestSet(this.settings.TestSet))
                {
                    LOG.InfoFormat("Only executing testset '{0}'", this.settings.TestSet);
                    Execute(this.project.GetTestSetByName(this.settings.TestSet));
                }
                else
                {
                    LOG.FatalFormat("Project does not containt a testset called '{0}'", this.settings.TestSet);
                    return;
                }
            }
            else
            {
                foreach (TestSet testSet in this.project.TestSets)
                {
                    Execute(testSet);
                }
            }
        }
コード例 #2
0
        private PdfPTable CreateProject(Project project)
        {
            PdfPTable table = new PdfPTable(new float[] { 2, 8 });
            StyleDefaultCell(table.DefaultCell);
            table.SpacingAfter = 20;
            table.WidthPercentage = 100f;
            AddHeaderCell(table, "Project");
            AddNormalCell(table, project.Name);
            AddHeaderCell(table, "Base URL");
            AddNormalCell(table, project.GetBaseUrl());
            AddHeaderCell(table, "Description");
            AddNormalCell(table, project.Description);

            return table;
        }
コード例 #3
0
        public void CreatePDF(Project project)
        {
            Document document = new Document(PageSize.A4);
            PdfWriter.GetInstance(document, new FileStream(project.GetSaveName() + ".pdf", FileMode.Create));

            document.Open();
            document.Add(CreateProject(project));

            foreach (TestSet testSet in project.TestSets)
            {
                if (testSet.Executed)
                {
                    document.Add(CreateTestSet(testSet));
                }
            }

            document.Close();
        }
コード例 #4
0
ファイル: Function.cs プロジェクト: Letractively/webmvctest
 public Function(Project project)
 {
     this.project = project;
 }
コード例 #5
0
ファイル: TestSet.cs プロジェクト: Letractively/webmvctest
 public TestSet(Project project)
 {
     this.project = project;
 }
コード例 #6
0
        private TestSet ReadTestSet(Project project)
        {
            TestSet testSet = new TestSet(project);

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:

                        if (reader.Name.Equals("name"))
                        {
                            testSet.Name = reader.ReadElementContentAsString();
                        }
                        else if (reader.Name.Equals("description"))
                        {
                            testSet.Description = GetDescription();
                        }
                        else if (reader.Name.Equals("authentication"))
                        {
                            string name = null;

                            for (int i = 0; i < reader.AttributeCount; i++)
                            {
                                reader.MoveToAttribute(i);
                                if (reader.Name.Equals("ref"))
                                {
                                    name = reader.Value;
                                }
                            }

                            testSet.SetAuthentication(project.GetAuthenticationByName(name));
                        }
                        else if (reader.Name.Equals("function"))
                        {
                            string refName = null;
                            int waitInSeconds = 0;
                            bool whenPreviousFunctionFailed = false;

                            if (testSet.Functions == null)
                            {
                                testSet.Functions = new List<Function>();
                            }
                            if (reader.HasAttributes)
                            {
                                for (int i = 0; i < reader.AttributeCount; i++)
                                {
                                    reader.MoveToAttribute(i);

                                    if (reader.Name.Equals("ref"))
                                    {
                                        refName = reader.Value;
                                    }

                                    else if (reader.Name.Equals("whenPreviousFunctionFailed"))
                                    {
                                        string boolVal = reader.Value;
                                        if (boolVal != null)
                                        {
                                            whenPreviousFunctionFailed = (boolVal.Equals("true") || boolVal.Equals("on") || boolVal.Equals("1"));
                                        }
                                    }
                                    else if (reader.Name.Equals("waitInSeconds"))
                                    {
                                        waitInSeconds = Int32.Parse(reader.Value);
                                    }
                                }

                                if (!string.IsNullOrEmpty(refName))
                                {
                                    Function functionRef = project.GetFunctionByName(reader.Value);
                                    if (functionRef != null)
                                    {
                                        testSet.Functions.Add(functionRef);
                                    }
                                }
                            }

                            if (string.IsNullOrEmpty(refName))
                            {
                                Function function = ReadFunction(project);
                                function.SetWaitInSeconds(waitInSeconds);
                                function.SetWhenPreviousFunctionFailed(whenPreviousFunctionFailed);

                                testSet.Functions.Add(function);
                            }
                        }
                        break;

                    case XmlNodeType.EndElement:

                        if (reader.Name.Equals("testSet"))
                        {
                            return testSet;
                        }

                        break;
                }
            }

            return testSet;
        }
コード例 #7
0
        public Project ReadProject()
        {
            Project project = null;

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:

                        if (reader.Name.Equals("project"))
                        {
                            project = new Project();
                        }

                        else if (reader.Name.Equals("name"))
                        {
                            project.Name = reader.ReadElementContentAsString();
                        }
                        else if (reader.Name.Equals("description"))
                        {
                            project.Description = GetDescription();
                        }
                        else if (reader.Name.Equals("baseUrl"))
                        {
                            project.SetBaseUrl(reader.ReadElementContentAsString());
                        }
                        else if (reader.Name.Equals("context"))
                        {
                            ReadParams(project);
                        }
                        else if (reader.Name.Equals("headers"))
                        {
                            project.SetDefaultHeaders(ReadHeaders());
                        }
                        else if (reader.Name.Equals("testSet"))
                        {
                            if (project.TestSets == null)
                            {
                                project.TestSets = new List<TestSet>();
                            }
                            project.TestSets.Add(ReadTestSet(project));
                        }
                        else if (reader.Name.Equals("functions"))
                        {
                            if (project.Functions == null)
                            {
                                project.Functions = new List<Function>();
                            }
                        }
                        else if (reader.Name.Equals("function"))
                        {
                            project.Functions.Add(ReadFunction(project));
                        }
                        else if (reader.Name.Equals("authentications"))
                        {
                            ReadAuthentications(project);
                        }
                        break;

                    case XmlNodeType.EndElement:

                        if (reader.Name.Equals("project"))
                        {
                            return project;
                        }

                        break;
                }
            }

            return project;
        }
コード例 #8
0
        private Function ReadFunction(Project project)
        {
            Function function = new Function(project);

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:

                        if (reader.Name.Equals("name"))
                        {
                            function.Name = reader.ReadElementContentAsString();
                        }
                        else if (reader.Name.Equals("description"))
                        {
                            function.Description = GetDescription();
                        }
                        else if (reader.Name.Equals("method"))
                        {
                            function.Method = reader.ReadElementContentAsString();
                        }
                        else if (reader.Name.Equals("url"))
                        {
                            function.SetUrl(reader.ReadElementContentAsString());
                        }
                        else if (reader.Name.Equals("postbody"))
                        {
                            function.SetPostBody(reader.ReadElementContentAsString());
                        }
                        else if (reader.Name.Equals("params"))
                        {
                            ReadParams(function);
                        }
                        else if (reader.Name.Equals("headers"))
                        {
                            function.SetHeaders(ReadHeaders());
                        }
                        else if (reader.Name.Equals("assertions"))
                        {
                            ReadAssertions(function);
                        }
                        else if (reader.Name.Equals("processors"))
                        {
                            ReadProcessors(function);
                        }
                        break;

                    case XmlNodeType.EndElement:

                        if (reader.Name.Equals("function"))
                        {
                            return function;
                        }

                        break;
                }
            }

            return function;
        }
コード例 #9
0
        private void ReadAuthentications(Project project)
        {
            Authentication authentication = null;

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:

                        if (reader.Name.Equals("authentication"))
                        {
                            authentication = new Authentication();

                            for (int i = 0; i < reader.AttributeCount; i++)
                            {
                                reader.MoveToAttribute(i);
                                if (reader.Name.Equals("type"))
                                {
                                    authentication.Type = reader.Value;
                                }
                            }
                        }
                        else if (reader.Name.Equals("name"))
                        {
                            authentication.Name = reader.ReadElementContentAsString();
                        }
                        else if (reader.Name.Equals("user"))
                        {
                            authentication.User = reader.ReadElementContentAsString();
                        }
                        else if (reader.Name.Equals("password"))
                        {
                            authentication.Password = reader.ReadElementContentAsString();
                        }

                        break;

                    case XmlNodeType.EndElement:

                        if (reader.Name.Equals("authentication"))
                        {
                            project.AddAuthentication(authentication);
                            return;
                        }
                        else if (reader.Name.Equals("authentications"))
                        {
                            return;
                        }

                        break;
                }
            }
        }