Esempio n. 1
0
        /// <summary>
        /// Test records enumerators correctness.
        /// </summary>
        private static void TestRecordsEnumerators(string inputFileName)
        {
            using (TextReader reader = new StreamReader(inputFileName))
            {
                int count   = 0;
                var records = QueryResultParser.CreateRecordsEnumerator(reader);
                while (records.MoveNext())
                {
                    var record = records.Current;
                    // Check number of records
                    Assert.AreEqual(18, record.Count);
                    // Check that value names doesn't contain spaces
                    foreach (string name in record.Keys)
                    {
                        Assert.IsNotNull(name);
                        Assert.IsTrue(name.Length > 0);
                        Assert.IsFalse(name.StartsWith(" "));
                        Assert.IsFalse(name.EndsWith(" "));

                        string[] parts = name.Split(' ');
                        Assert.AreEqual(1, parts.Length);
                    }

                    count++;
                }
                Assert.AreEqual(6, count);
            }
        }
        public void Execute_QueryResult_DataSet()
        {
            var parser = new QueryResultParser();
            var dt     = parser.Execute(JSon);

            Assert.That(dt.Rows.Count, Is.EqualTo(5));
            Assert.That(dt.Columns.Count, Is.EqualTo(3));
        }
        /// <summary>
        /// Calculates number of records of data available.
        /// </summary>
        private static int CountRecords(TextReader reader)
        {
            int count = 0;
            // Create records enumerator from stream
            IEnumerator <Record> records = QueryResultParser.CreateRecordsEnumerator(reader);

            while (records.MoveNext())
            {
                count++;
            }
            return(count);
        }
Esempio n. 4
0
        public void CreateRawStringsEnumeratorTest()
        {
            string inputFileName = Path.Combine(this.TestContext.TestDeploymentDir,
                                                RawSourceFileName);
            string refFileName = Path.Combine(this.TestContext.TestDeploymentDir,
                                              RawRefFileName);

            using (TextReader reader = new StreamReader(inputFileName))
            {
                using (IEnumerator <string> actual = QueryResultParser.
                                                     CreateRawStringsEnumerator(reader))
                {
                    using (IEnumerator <string> expected = CreateFileEnumerator(refFileName))
                    {
                        CheckEnumeratorsAreEqual(expected, actual);
                    }
                }
            }
        }
        public void CanHandle_QueryResult_True()
        {
            var parser = new QueryResultParser();

            Assert.That(parser.CanHandle(JSon), Is.True);
        }
        /// <summary>
        /// Reads query results from stream and fills database.
        /// </summary>
        /// <remarks>
        /// Prerequisite for normal functioning of this method
        /// is initialized empty storage. But this particular
        /// method doesn't initialize storage itself. So prior
        /// calling this method storage shall be initialized.
        /// </remarks>
        public void FillStorage(TextReader reader)
        {
            // Create records enumerator from stream
            IEnumerator <Record> records = QueryResultParser.CreateRecordsEnumerator(reader);

            // Initialize caches
            m_appCache       = new Dictionary <string, Application>();
            m_moduleCache    = new Dictionary <ComplexKey, Module>();
            m_subModuleCache = new Dictionary <ComplexKey, SubModule>();
            m_relCache       = new Dictionary <ComplexKey, Release>();
            m_personCache    = new Dictionary <string, Person>();

            int current = 0;

            // Enumerate records (actually revisions)
            while (records.MoveNext())
            {
                // Take current record from parser
                Record record = records.Current;

                // Process number
                int number = ProcessNumber(record);

                // Process revision number
                int revision = ProcessRevisionNumber(record);

                // Process short description
                string summary = ProcessSummary(record);

                // Process date
                DateTime date = ProcessDate(record);

                // Process record type (could be null)
                BugType type = ProcessType(record);

                // Process status
                BugStatus status = ProcessStatus(record);

                // Process severity
                BugSeverity?severity = ProcessSeverity(record);

                // Process priority
                int?priority = ProcessPriority(record);

                // Process application
                Application app = ProcessApp(record);

                Module    module        = null;
                SubModule subModule     = null;
                Release   foundRelease  = null;
                Release   targetRelease = null;
                // Process some fields only if application is specified
                if (app != null)
                {
                    // Process module
                    module = ProcessModule(record, app);
                    // Don't process sub module if module is null
                    if (module != null)
                    {
                        // Process sub
                        subModule = ProcessSubModule(record, module);
                    }

                    // Process found release
                    foundRelease = ProcessRelease(record, app, FoundRelCol);
                    // Process target release
                    targetRelease = ProcessRelease(record, app, TargetRelCol);
                }

                // Process contributor
                Person contributor = ProcessPerson(record, ContributorCol);
                // Process team leader
                Person leader = ProcessPerson(record, LeaderCol);
                // Process developer
                Person developer = ProcessPerson(record, DevCol);
                // Process tester
                Person tester = ProcessPerson(record, QaCol);

                // Process revision
                ProcessRevision(number, revision, date, type, status,
                                summary, severity, priority, app, module,
                                subModule, foundRelease,
                                targetRelease, contributor, leader, developer, tester);

                current++;
                // Notify progress
                FireProgressChanged(current);
            }
        }
Esempio n. 7
0
        public void CreateRecordsEnumeratorTest()
        {
            string inputFileName = Path.Combine(this.TestContext.TestDeploymentDir,
                                                RecordSourceFileName);

            using (TextReader reader = new StreamReader(inputFileName))
            {
                var actual = QueryResultParser.CreateRecordsEnumerator(reader);
                // Reference data
                IDictionary <string, string> record1 = new Dictionary <string, string>()
                {
                    { "number", "15210" },
                    { "subnumber", "0" },
                    { "deadline", "bug" },
                    { "status", "open" },
                    { "date", "2004/02/23" },
                    { "closedate", null },
                    { "application", "Installer" },
                    { "modul", null },
                    { "submodul", null },
                    { "apprelease", "unknown" },
                    { "frelease", null },
                    { "severity", null },
                    { "priority", "n/a" },
                    { "contributor", "viktorov" },
                    { "leader", null },
                    { "developer", null },
                    { "qa", null },
                    {
                        "summary",
                        "VPIplayer: the error message comes up during deinstallation: \"-1612...\""
                    }
                };
                IDictionary <string, string> record2 = new Dictionary <string, string>()
                {
                    { "number", "12807" },
                    { "subnumber", "4" },
                    { "deadline", "bug" },
                    { "status", "closed" },
                    { "date", "2004/04/05" },
                    { "closedate", "2004/04/05" },
                    { "application", "VPIplayer" },
                    { "modul", null },
                    { "submodul", null },
                    { "apprelease", "1.0" },
                    { "frelease", "1.0" },
                    { "severity", "2" },
                    { "priority", "1" },
                    { "contributor", "a.lowery" },
                    { "leader", "k.soh" },
                    { "developer", null },
                    { "qa", "sohryn" },
                    { "summary", "Integer Controls in Player don't work at top setting" }
                };

                var records = new List <IDictionary <string, string> >()
                {
                    record1, record2
                };


                // Compare
                CheckEnumeratorsAreEqual2(records.GetEnumerator(), actual);
            }
        }