Ejemplo n.º 1
0
        private void buildTestSuiteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var tsCreate = new TestSuiteCreate();
            tsCreate.Actual.QueriesDirectory = Configuration.Project.Directories[Configuration.DirectoryCollection.DirectoryType.Query].FullFileName;
            tsCreate.Actual.ConnectionString = Configuration.Project.ConnectionStrings[
                Configuration.ConnectionStringCollection.ConnectionClass.Oledb,
                Configuration.ConnectionStringCollection.ConnectionType.Expect
                ].Value;
            tsCreate.Expect.ResultSetsDirectory = Configuration.Project.Directories[Configuration.DirectoryCollection.DirectoryType.Expect].FullFileName;

            DialogResult dialogResult = tsCreate.ShowDialog();
            if (dialogResult.HasFlag(DialogResult.OK))
            {
                StartClick(null);
                try
                {
                    var tsb = new TestSuiteBuilder();
                    TestSuiteXml ts = null;

                    tsb.DefineActual(tsCreate.Actual.QueriesDirectory, tsCreate.Actual.ConnectionString);
                    if (tsCreate.Expect.IsResultSetsBased)
                        tsb.DefineExpect(tsCreate.Expect.ResultSetsDirectory);
                    else
                        tsb.DefineExpect(tsCreate.Expect.QueriesDirectory, tsCreate.Expect.ConnectionString);

                    ts = tsb.Build();

                    var xm = new XmlManager();

                    using (var sfd = new SaveFileDialog())
                    {
                        sfd.InitialDirectory = Configuration.Project.Directories[Configuration.DirectoryCollection.DirectoryType.TestSuite].FullPath;
                        sfd.FileName = Configuration.Project.Directories[Configuration.DirectoryCollection.DirectoryType.TestSuite].FilenameWithoutExtension;
                        sfd.Filter = "Xml|*.xml";
                        if (sfd.ShowDialog() == DialogResult.OK)
                        {
                            Configuration.Project.Directories[Configuration.DirectoryCollection.DirectoryType.TestSuite].FullFileName = sfd.FileName;
                            xm.Persist(sfd.FileName, ts);
                        }
                    }
                }
                finally
                {
                    Configuration.Project.Directories[Configuration.DirectoryCollection.DirectoryType.Query].FullFileName = tsCreate.Actual.QueriesDirectory;
                    Configuration.Project.ConnectionStrings[
                        Configuration.ConnectionStringCollection.ConnectionClass.Oledb,
                        Configuration.ConnectionStringCollection.ConnectionType.Actual
                        ].Value = tsCreate.Actual.ConnectionString;

                    if (tsCreate.Expect.IsResultSetsBased)
                        Configuration.Project.Directories[Configuration.DirectoryCollection.DirectoryType.Expect].FullFileName = tsCreate.Expect.ResultSetsDirectory;
                    EndClick(null);
                }
            }
        }
Ejemplo n.º 2
0
        private void buildTestSuiteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var tsCreate = new TestSuiteCreate();

            tsCreate.Actual.QueriesDirectory = Configuration.Project.Directories[Configuration.DirectoryCollection.DirectoryType.Query].FullFileName;
            tsCreate.Actual.ConnectionString = Configuration.Project.ConnectionStrings[
                Configuration.ConnectionStringCollection.ConnectionClass.Oledb,
                Configuration.ConnectionStringCollection.ConnectionType.Expect
                                               ].Value;
            tsCreate.Expect.ResultSetsDirectory = Configuration.Project.Directories[Configuration.DirectoryCollection.DirectoryType.Expect].FullFileName;

            DialogResult dialogResult = tsCreate.ShowDialog();

            if (dialogResult.HasFlag(DialogResult.OK))
            {
                StartClick(null);
                try
                {
                    var          tsb = new TestSuiteBuilder();
                    TestSuiteXml ts  = null;

                    tsb.DefineActual(tsCreate.Actual.QueriesDirectory, tsCreate.Actual.ConnectionString);
                    if (tsCreate.Expect.IsResultSetsBased)
                    {
                        tsb.DefineExpect(tsCreate.Expect.ResultSetsDirectory);
                    }
                    else
                    {
                        tsb.DefineExpect(tsCreate.Expect.QueriesDirectory, tsCreate.Expect.ConnectionString);
                    }

                    ts = tsb.Build();

                    var xm = new XmlManager();

                    using (var sfd = new SaveFileDialog())
                    {
                        sfd.InitialDirectory = Configuration.Project.Directories[Configuration.DirectoryCollection.DirectoryType.TestSuite].FullPath;
                        sfd.FileName         = Configuration.Project.Directories[Configuration.DirectoryCollection.DirectoryType.TestSuite].FilenameWithoutExtension;
                        sfd.Filter           = "Xml|*.xml";
                        if (sfd.ShowDialog() == DialogResult.OK)
                        {
                            Configuration.Project.Directories[Configuration.DirectoryCollection.DirectoryType.TestSuite].FullFileName = sfd.FileName;
                            xm.Persist(sfd.FileName, ts);
                        }
                    }
                }
                finally
                {
                    Configuration.Project.Directories[Configuration.DirectoryCollection.DirectoryType.Query].FullFileName = tsCreate.Actual.QueriesDirectory;
                    Configuration.Project.ConnectionStrings[
                        Configuration.ConnectionStringCollection.ConnectionClass.Oledb,
                        Configuration.ConnectionStringCollection.ConnectionType.Actual
                    ].Value = tsCreate.Actual.ConnectionString;

                    if (tsCreate.Expect.IsResultSetsBased)
                    {
                        Configuration.Project.Directories[Configuration.DirectoryCollection.DirectoryType.Expect].FullFileName = tsCreate.Expect.ResultSetsDirectory;
                    }
                    EndClick(null);
                }
            }
        }