예제 #1
0
        public async Task QueryDictionaryTest(bool predicate)
        {
            var testData = new Tuple <int, string>[]
            {
                new Tuple <int, string>(1, "v1"),
                new Tuple <int, string>(2, "v2"),
                new Tuple <int, string>(3, "v3"),
            };

            var query = SqQueryBuilder.SelectOne();

            TestSqDatabase database = new TestSqDatabase(BuildQueryDelegate(query: query, testData: testData));


            Func <int, string, bool>?p = null;

            if (predicate)
            {
                p = (k, v) => k != 3 && v != "v3";
            }

            var result = await query.QueryDictionary(database, r => r.GetInt32("K"), r => r.GetString("V"), predicate : p);

            var count = predicate ? 2 : 3;

            Assert.AreEqual(count, result.Count);
            for (int i = 0; i < count; i++)
            {
                Assert.AreEqual(testData[i].Item2, result[testData[i].Item1]);
            }
        }
예제 #2
0
        public async Task QueryDictionaryTest_KeyDuplication()
        {
            var testData = new Tuple <int, string>[]
            {
                new Tuple <int, string>(1, "v1"),
                new Tuple <int, string>(2, "v2"),
                new Tuple <int, string>(2, "v3"),
            };

            var query = SqQueryBuilder.SelectOne();

            TestSqDatabase database = new TestSqDatabase(queryImplementation: BuildQueryDelegate(query, testData));


            var result = await query.QueryDictionary(database, r => r.GetInt32("K"), r => r.GetString("V"), KeyDuplicationHandler);

            var count = 3;

            Assert.AreEqual(count, result.Count);
            for (int i = 0; i < count; i++)
            {
                var item1 = testData[i].Item2 == "v3" ? 3 : testData[i].Item1;
                Assert.AreEqual(testData[i].Item2, result[item1]);
            }