Beispiel #1
0
        protected void ApplyDefaultColumnNamesMapping(DatabaseSchema dbSchema, AbstractCollection collection, bool binaryToAttachment)
        {
            var tableSchema = dbSchema.Tables.First(x => x.Schema == collection.SourceTableSchema && x.TableName == collection.SourceTableName);

            var specialColumns = dbSchema.FindSpecialColumns(collection.SourceTableSchema, collection.SourceTableName);

            collection.ColumnsMapping = tableSchema.Columns
                                        .Where(x => specialColumns.Contains(x.Name) == false && (binaryToAttachment ? x.Type != ColumnType.Binary : true))
                                        .Select(c => (c.Name, c.Name.First().ToString().ToUpper() + c.Name.Substring(1)))
                                        .ToDictionary(x => x.Name, x => x.Item2);

            collection.AttachmentNameMapping = tableSchema.Columns
                                               .Where(x => binaryToAttachment ? x.Type == ColumnType.Binary : false)
                                               .Select(c => (c.Name, c.Name.First().ToString().ToUpper() + c.Name.Substring(1)))
                                               .ToDictionary(x => x.Name, x => x.Item2);

            if (collection is CollectionWithReferences collectionWithRefs)
            {
                if (collectionWithRefs.LinkedCollections != null)
                {
                    foreach (var linkedCollection in collectionWithRefs.LinkedCollections)
                    {
                        ApplyDefaultColumnNamesMapping(dbSchema, linkedCollection, binaryToAttachment);
                    }
                }

                if (collectionWithRefs.NestedCollections != null)
                {
                    foreach (var embeddedCollection in collectionWithRefs.NestedCollections)
                    {
                        ApplyDefaultColumnNamesMapping(dbSchema, embeddedCollection, binaryToAttachment);
                    }
                }
            }
        }
Beispiel #2
0
        private void CheckOnAbsentFalsePositive(int hashId, int numInsertions, RetouchedBloomFilter
                                                filter, TestBloomFilters.Digits digits, short removeSchema)
        {
            AbstractCollection <Key> falsePositives = FalsePositiveUnder1000[hashId];

            if (falsePositives == null)
            {
                NUnit.Framework.Assert.Fail(string.Format("false positives for hash %d not founded"
                                                          , hashId));
            }
            filter.AddFalsePositive(falsePositives);
            for (int i = digits.GetStart(); i < numInsertions; i += 2)
            {
                filter.Add(new Key(Runtime.GetBytesForString(Extensions.ToString(
                                                                 i))));
            }
            foreach (Key key in falsePositives)
            {
                filter.SelectiveClearing(key, removeSchema);
            }
            for (int i_1 = 1 - digits.GetStart(); i_1 < numInsertions; i_1 += 2)
            {
                NUnit.Framework.Assert.IsFalse(" testRetouchedBloomFilterAddFalsePositive error "
                                               + i_1, filter.MembershipTest(new Key(Runtime.GetBytesForString(Extensions.ToString
                                                                                                                  (i_1)))));
            }
        }
Beispiel #3
0
 public TableReference FindReference(AbstractCollection collection, List <string> columns)
 {
     return(References.FirstOrDefault(x => x.Table == collection.SourceTableName &&
                                      x.Schema == collection.SourceTableSchema &&
                                      EnumerableExtension.ContentEquals(x.Columns, columns)));
 }
        /*------------- assertQueryResults ----------------*/

        /**
         * Creates a query given the expression that is to be evaluated, then
         * asserts its result is equal to the evaluation of the given
         * <code>expectedResultExpression</code>.
         * <p>
         * If either the expected result or the expression result is a double, we'll
         * compare the two with a margin of 0.001.
         * </p>
         *
         * @param expectedResult
         *            Object with which the query's result is to be compared.
         * @param expression
         *            Expression that is to be evaluated. Note that we'll use
         *            {@link EClass} as this expression's context.
         */
        /*
         * public Object assertQueryResults(Object context, @NonNull String expectedResultExpression, @NonNull String expression){
         *  try
         *  {
         *      Object expectedResultQuery = evaluateLocal(context, expectedResultExpression);
         *      Object result = assertQueryEquals(context, expectedResultQuery, expression);
         *      PivotTestSuite.appendLog(testName, context, expression, null, expectedResultExpression, null);
         *      return result;
         *  }
         *  catch (Exception e)
         *  {
         *      PivotTestSuite.failOn(expectedResultExpression, e);
         *      return null;
         *  }
         * }
         */
        /*
         * public void assertQueryResults<T>(Collection<object> expectedResult, Collection<object> actualResult)
         * {
         * CollectionAssert.AreEqual(expectedResult as ICollection, actualResult as ICollection);
         * }
         *
         * public void assertQueryResults<T>(Bag<T> expectedResult, Sequence<T> actualResult)
         * {
         *  CollectionAssert.AreEqual(expectedResult, actualResult);
         * }*/


        /*
         * public void assertQueryResults<T>(Bag<T> expectedResult, Bag<T> actualResult){
         *  CollectionAssert.AreEqual(expectedResult, actualResult);
         * }
         *
         * public void assertQueryResults<T>(Bag<T> expectedResult, Sequence<T> actualResult)
         * {
         *  CollectionAssert.AreEqual(expectedResult, actualResult);
         * }
         *
         * public void assertQueryResults<T>(Set<T> expectedResult, Set<T> actualResult){
         *  CollectionAssert.AreEqual(expectedResult, actualResult);
         * }
         *
         * public void assertQueryResults<T>(Sequence<T> expectedResult, Sequence<T> actualResult){
         *  CollectionAssert.AreEquivalent(expectedResult, actualResult);
         * }
         *
         * public void assertQueryResults<T>(OrderedSet<T> expectedResult, OrderedSet<T> actualResult){
         *  CollectionAssert.AreEquivalent(expectedResult, actualResult);
         * }
         */

        public void assertQueryResults <T>(AbstractCollection <T> expectedResult, AbstractCollection <T> actualResult)
        {
            CollectionAssert.AreEqual(expectedResult, actualResult);
        }
        /*------------- assertResultContainsAll ----------------*/

        /**
         * Creates a query given the expression that is to be evaluated, then
         * asserts its result contains all elements included in
         * <code>expectedResult</code>.
         *
         * @param expectedResultExpression
         *            Expression which is to be evaluated to determine the expected
         *            result.
         * @param expression
         *            Expression that is to be evaluated. Note that we'll use
         *            {@link EClass} as this expression's context.
         */
        /*
         * public Object assertResultContainsAll(Object context, @NonNull String expectedResultExpression, @NonNull String expression){
         *  try {
         *      Object expectedResultQuery = evaluateLocal(null, expectedResultExpression);
         *      TestCase.assertTrue(expectedResultQuery instanceof CollectionValue);
         *      @SuppressWarnings("null")
         *      Object result = assertResultContainsAll(context, (CollectionValue) expectedResultQuery, expression);
         *      return result;
         *  } catch (Exception e) {
         *      PivotTestSuite.failOn(expectedResultExpression, e);
         *      return null;
         *  }
         * }
         */

        public void assertResultContainsAll <T>(AbstractCollection <T> expected, AbstractCollection <T> actual)
        {
            CollectionAssert.AreEqual(expected, actual);
        }
 public void assertQueryEquals <T>(AbstractCollection <T> expected, AbstractCollection <T> actual)
 {
     CollectionAssert.AreEqual(expected, actual);
 }