Ejemplo n.º 1
0
        public void CanParseShortestValidTableString()
        {
            IList <InvolvedTable> tables = IssueUtils.ParseInvolvedTables("[T:F]1||2||3;[Y:G]A");

            Assert.AreEqual(2, tables.Count);

            InvolvedTable table1 = tables[0];

            Assert.AreEqual("T", table1.TableName);
            Assert.AreEqual("F", table1.KeyField);
            IList <RowReference> rows1 = table1.RowReferences;

            Assert.AreEqual(3, rows1.Count);
            Assert.AreEqual("1", rows1[0].Key);
            Assert.AreEqual("2", rows1[1].Key);
            Assert.AreEqual("3", rows1[2].Key);

            InvolvedTable table2 = tables[1];

            Assert.AreEqual("Y", table2.TableName);
            Assert.AreEqual("G", table2.KeyField);
            IList <RowReference> rows2 = table2.RowReferences;

            Assert.AreEqual(1, rows2.Count);
            Assert.AreEqual("A", rows2[0].Key);
        }
Ejemplo n.º 2
0
        public void CanParseInvolvedTablesWithOids()
        {
            IList <InvolvedTable> tables =
                IssueUtils.ParseInvolvedTables("[Table1]1||2;[Table2]1000||1001");

            Assert.AreEqual(2, tables.Count);

            InvolvedTable table1 = tables[0];

            Assert.AreEqual("Table1", table1.TableName);
            Assert.IsNull(table1.KeyField);
            IList <RowReference> rows1 = table1.RowReferences;

            Assert.AreEqual(2, rows1.Count);
            Assert.AreEqual(1, rows1[0].OID);
            Assert.AreEqual(2, rows1[1].OID);

            InvolvedTable table2 = tables[1];

            Assert.AreEqual("Table2", table2.TableName);
            Assert.IsNull(table2.KeyField);
            IList <RowReference> rows2 = table2.RowReferences;

            Assert.AreEqual(2, rows2.Count);
            Assert.AreEqual(1000, rows2[0].OID);
            Assert.AreEqual(1001, rows2[1].OID);
        }
Ejemplo n.º 3
0
        private IList <InvolvedTable> ParseInvolvedTables(
            [NotNull] string involvedTablesString, Guid qualityConditionGuid)
        {
            IAlternateKeyConverter keyConverter =
                _alternateKeyConverterProvider?.GetConverter(qualityConditionGuid);

            return(IssueUtils.ParseInvolvedTables(involvedTablesString, keyConverter));
        }
Ejemplo n.º 4
0
        public void CanParseInvolvedTableWithKeyFieldNoIds()
        {
            IList <InvolvedTable> tables = IssueUtils.ParseInvolvedTables("[Table:FieldName]");

            Assert.AreEqual(1, tables.Count);

            InvolvedTable table = tables[0];

            Assert.AreEqual("Table", table.TableName);
            Assert.AreEqual("FieldName", table.KeyField);
            IList <RowReference> rows = table.RowReferences;

            Assert.AreEqual(0, rows.Count);
        }
Ejemplo n.º 5
0
        private static void AssertFastEnough([NotNull] string involvedTables,
                                             int count,
                                             double maximumMilliseconds)
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            for (int i = 0; i < count; i++)
            {
                IssueUtils.ParseInvolvedTables(involvedTables);
            }

            stopwatch.Stop();
            long milliseconds = stopwatch.ElapsedMilliseconds;

            double millisecondsPerOperation = (double)milliseconds / count;

            Console.WriteLine(@"Parsing {0}: {1} ms", involvedTables, millisecondsPerOperation);

            Assert.LessOrEqual(millisecondsPerOperation, maximumMilliseconds);
        }
Ejemplo n.º 6
0
        private static void ExpectException([NotNull] string involvedTablesString,
                                            [CanBeNull] string expectedMessage)
        {
            try
            {
                IList <InvolvedTable> involvedTables =
                    IssueUtils.ParseInvolvedTables(involvedTablesString);

                foreach (InvolvedTable involvedTable in involvedTables)
                {
                    Console.WriteLine(@"- {0}", involvedTable);
                }

                Assert.Fail("Exception expected for invalid string: {0}", involvedTablesString);
            }
            catch (AssertionException exception)
            {
                Console.WriteLine(exception.Message);
                if (expectedMessage != null)
                {
                    Assert.AreEqual(expectedMessage, exception.Message);
                }
            }
        }
Ejemplo n.º 7
0
        public void CanParseEmptyTableString1()
        {
            IList <InvolvedTable> involvedTables = IssueUtils.ParseInvolvedTables(string.Empty);

            Assert.AreEqual(0, involvedTables.Count);
        }