コード例 #1
0
        public void TestQSRecordLookup()
        {
            var c  = new CodeContext();
            var qs = new DummyQueryReference();
            var v  = Expression.Constant(10);

            c.Add(qs, v);

            Assert.AreEqual(0, c.GetAndResetQuerySourceLookups().Length, "# of query source look ups isn't zero initially");

            // Look up bogus and make sure it is null

            var qsNotStored = new DummyQueryReference();

            c.GetReplacement(qsNotStored);
            Assert.AreEqual(0, c.GetAndResetQuerySourceLookups().Length, "Dummy lookup shouldn't cache reference.");

            // Look up good one and make sure it worked.

            c.GetReplacement(qs);
            var qsReferenced = c.GetAndResetQuerySourceLookups();

            Assert.AreEqual(1, qsReferenced.Length, "# of qs lookups after a real reference");
            Assert.AreEqual(qs, qsReferenced[0], "QS recorded in lookup");
        }
コード例 #2
0
        public void TestQSResetsRecordLookup()
        {
            var c  = new CodeContext();
            var qs = new DummyQueryReference();
            var v  = Expression.Constant(10);

            c.Add(qs, v);

            c.GetReplacement(qs);
            var qsReferenced = c.GetAndResetQuerySourceLookups();

            Assert.AreEqual(0, c.GetAndResetQuerySourceLookups().Length, "# of qs lookups after a reset");
        }
コード例 #3
0
        public void TestQSReloadLookup()
        {
            var c      = new CodeContext();
            var qs1    = new DummyQueryReference();
            var qs2    = new DummyQueryReference();
            var qsList = new IQuerySource[] { qs1, qs2 };

            c.RestoreQuerySourceLookups(qsList);
            Assert.AreEqual(2, c.GetAndResetQuerySourceLookups().Length, "# after a restore");
        }
コード例 #4
0
        public void TestQMStoreResetsQSLookupList()
        {
            var c  = new CodeContext();
            var qm = new QueryModel(new Remotion.Linq.Clauses.MainFromClause("dude", typeof(int), Expression.Parameter(typeof(IEnumerable <int>))),
                                    new Remotion.Linq.Clauses.SelectClause(Expression.Parameter(typeof(int))));

            var qs = new DummyQueryReference();

            c.Add(qs, Expression.Constant(10));
            c.GetReplacement(qs);

            var e1 = Expression.Parameter(typeof(int));
            var s1 = c.Add(qm, e1);

            Assert.AreEqual(0, c.GetAndResetQuerySourceLookups().Length, "# of qs references after a lookup");
        }
コード例 #5
0
        public void TestQSRecordLookup()
        {
            var c = new CodeContext();
            var qs = new DummyQueryReference();
            var v = Expression.Constant(10);
            c.Add(qs, v);

            Assert.AreEqual(0, c.GetAndResetQuerySourceLookups().Length, "# of query source look ups isn't zero initially");

            // Look up bogus and make sure it is null

            var qsNotStored = new DummyQueryReference();
            c.GetReplacement(qsNotStored);
            Assert.AreEqual(0, c.GetAndResetQuerySourceLookups().Length, "Dummy lookup shouldn't cache reference.");

            // Look up good one and make sure it worked.

            c.GetReplacement(qs);
            var qsReferenced = c.GetAndResetQuerySourceLookups();
            Assert.AreEqual(1, qsReferenced.Length, "# of qs lookups after a real reference");
            Assert.AreEqual(qs, qsReferenced[0], "QS recorded in lookup");
        }
コード例 #6
0
        public void TestQMStoreResetsQSLookupList()
        {
            var c = new CodeContext();
            var qm = new QueryModel(new Remotion.Linq.Clauses.MainFromClause("dude", typeof(int), Expression.Parameter(typeof(IEnumerable<int>))),
                new Remotion.Linq.Clauses.SelectClause(Expression.Parameter(typeof(int))));

            var qs = new DummyQueryReference();
            c.Add(qs, Expression.Constant(10));
            c.GetReplacement(qs);

            var e1 = Expression.Parameter(typeof(int));
            var s1 = c.Add(qm, e1);

            Assert.AreEqual(0, c.GetAndResetQuerySourceLookups().Length, "# of qs references after a lookup");
        }
コード例 #7
0
        public void TestQSReloadLookup()
        {
            var c = new CodeContext();
            var qs1 = new DummyQueryReference();
            var qs2 = new DummyQueryReference();
            var qsList = new IQuerySource[] { qs1, qs2 };

            c.RestoreQuerySourceLookups(qsList);
            Assert.AreEqual(2, c.GetAndResetQuerySourceLookups().Length, "# after a restore");
        }
コード例 #8
0
        public void TestQSResetsRecordLookup()
        {
            var c = new CodeContext();
            var qs = new DummyQueryReference();
            var v = Expression.Constant(10);
            c.Add(qs, v);

            c.GetReplacement(qs);
            var qsReferenced = c.GetAndResetQuerySourceLookups();
            Assert.AreEqual(0, c.GetAndResetQuerySourceLookups().Length, "# of qs lookups after a reset");
        }