示例#1
0
        static void Main(string[] args)
        {
            var provider = DbEntityProvider.From("IQToolkit.Data.SqlClient",@"Data Source=ET1841\ETTSILVERS08;Initial Catalog=Northwind;Integrated Security=True", "Test.NorthwindWithAttributes");
            //var provider = DbEntityProvider.From(@"c:\data\Northwind.accdb", "Test.NorthwindWithAttributes");
            //var provider = DbEntityProvider.From(@"c:\data\Northwind.mdb", "Test.NorthwindWithAttributes");
            //var provider = DbEntityProvider.From(@"c:\data\Northwind.sdf", "Test.NorthwindWithAttributes");
            //var provider = DbEntityProvider.From("IQToolkit.Data.MySqlClient", "Northwind", "Test.MySqlNorthwind");
            //var provider = DbEntityProvider.From("IQToolkit.Data.SQLite", @"c:\data\Northwind.db3", "Test.NorthwindWithAttributes");

            //provider.Log = Console.Out;
            provider.Connection.Open();
            //provider.Cache = new QueryCache(5);

            try
            {
                var db = new Northwind(provider);

                //NorthwindTranslationTests.Run(db, true);
                NorthwindExecutionTests.Run(db);
                NorthwindCUDTests.Run(db);
                //MultiTableTests.Run(new MultiTableContext(provider.New(new AttributeMapping(typeof(MultiTableContext)))));
                //NorthwindPerfTests.Run(db, "TestStandardQuery");
            }
            finally
            {
                provider.Connection.Close();
            }
            Console.ReadKey();
        }
        public void TestCustomersAssociateOrders()
        {
            var policy = new EntityPolicy();
            policy.AssociateWith<Customer>(c => c.Orders.Where(o => (o.OrderID & 1) == 0));
            Northwind nw = new Northwind(this.provider.New(policy));

            var custs = nw.Customers.Where(c => c.CustomerID == "ALFKI")
                .Select(c => new { CustomerID = c.CustomerID, FilteredOrdersCount = c.Orders.Count() }).ToList();
            AssertValue(1, custs.Count);
            AssertValue(3, custs[0].FilteredOrdersCount);
        }
 public static void Run(Northwind db)
 {
     new NorthwindExecutionTests().RunTests(db, null, null, true);
 }
        public void TestCustomersApplyOrder()
        {
            var policy = new EntityPolicy();
            policy.Apply<Customer>(seq => seq.OrderBy(c => c.ContactName));
            Northwind nw = new Northwind(this.provider.New(policy));

            var list = nw.Customers.Where(c => c.City == "London").ToList();

            AssertValue(6, list.Count);
            var sorted = list.OrderBy(c => c.ContactName).ToList();
            AssertTrue(Enumerable.SequenceEqual(list, sorted));
        }
示例#5
0
 public static void Run(Northwind db)
 {
     new NorthwindCUDTests().RunTests(db, null, null, true);
 }
示例#6
0
        private static bool RunTest(DbEntityProvider provider, string selection)
        {
            if (selection.Equals("q", StringComparison.OrdinalIgnoreCase))
                return false;

            if (selection.StartsWith("log", StringComparison.OrdinalIgnoreCase))
            {
                if (selection.Equals("log on", StringComparison.OrdinalIgnoreCase))
                {
                    logEnabled = true;
                }
                else if (selection.Equals("log off", StringComparison.OrdinalIgnoreCase))
                {
                    logEnabled = false;
                }

                Console.WriteLine(String.Format("Log is {0}.", logEnabled ? "On" : "Off"));
                return true;
            }

            if(logEnabled)
                provider.Log = Console.Out;
            else
                provider.Log = null;

            provider.Connection.Open();
            //provider.Cache = new QueryCache(5);
            try
            {
                var db = new Northwind(provider);

                if (selection.Contains("0") || selection.Contains("1"))
                    NorthwindTranslationTests.Run(db, true);
                if (selection.Contains("0") || selection.Contains("2"))
                    NorthwindExecutionTests.Run(db);
                if (selection.Contains("0") || selection.Contains("3"))
                    NorthwindCUDTests.Run(db);
                if (selection.Contains("0") || selection.Contains("4"))
                    MultiTableTests.Run(new MultiTableContext(provider.New(new AttributeMapping(typeof(MultiTableContext)))));
                if (selection.Contains("0") || selection.Contains("5"))
                    NorthwindPerfTests.Run(db, "TestStandardQuery");
            }
            catch(Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
            }
            finally
            {
                provider.Connection.Close();
            }

            return true;
        }
示例#7
0
        private static bool RunTest(string selection)
        {
            if (selection.Equals("q", StringComparison.OrdinalIgnoreCase))
                return false;

            if (selection.Equals("s", StringComparison.OrdinalIgnoreCase))
            {
                if(adoProviderName == "IQToolkit.Data.OracleClient")
                    adoProviderName = "IQToolkit.Data.ODP";
                else
                    adoProviderName = "IQToolkit.Data.OracleClient";
                return true;
            }

            string connectionStringName = "Oracle";
            string providerName = ConfigurationManager.ConnectionStrings[connectionStringName].ProviderName;
            string connectionString = ConfigurationManager.ConnectionStrings[connectionStringName].ConnectionString;

            var provider = DbEntityProvider.From(adoProviderName, connectionString, "Test.NorthwindWithAttributes");

            if (selection.StartsWith("log", StringComparison.OrdinalIgnoreCase))
            {
                if (selection.Equals("log on", StringComparison.OrdinalIgnoreCase))
                {
                    logEnabled = true;
                }
                else if (selection.Equals("log off", StringComparison.OrdinalIgnoreCase))
                {
                    logEnabled = false;
                }

                Console.WriteLine(String.Format("Log is {0}.", logEnabled ? "On" : "Off"));
                return true;
            }

            if(logEnabled)
                provider.Log = Console.Out;
            else
                provider.Log = null;

            provider.Connection.Open();
            //provider.Cache = new QueryCache(5);
            try
            {
                var db = new Northwind(provider);

                if (selection.Contains("0") || selection.Contains("1"))
                    NorthwindTranslationTests.Run(db, true);
                if (selection.Contains("0") || selection.Contains("2"))
                    NorthwindExecutionTests.Run(db);
                if (selection.Contains("0") || selection.Contains("3"))
                    NorthwindCUDTests.Run(db);
                if (selection.Contains("0") || selection.Contains("4"))
                    MultiTableTests.Run(new MultiTableContext(provider.New(new AttributeMapping(typeof(MultiTableContext)))));
                if (selection.Contains("0") || selection.Contains("5"))
                    NorthwindPerfTests.Run(db, "TestStandardQuery");
            }
            catch(Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
            }
            finally
            {
                provider.Connection.Close();
            }

            return true;
        }
        public void TestCustomersIncludeOrdersDeferred()
        {
            var policy = new EntityPolicy();
            policy.IncludeWith<Customer>(c => c.Orders, true);
            Northwind nw = new Northwind(this.provider.New(policy));

            var custs = nw.Customers.Where(c => c.CustomerID == "ALFKI").ToList();
            AssertValue(1, custs.Count);
            AssertNotValue(null, custs[0].Orders);
            AssertValue(6, custs[0].Orders.Count);
        }
示例#9
0
        public void TestSessionProviderNotIdentityCached()
        {
            NorthwindSession ns = new NorthwindSession(this.GetProvider());
            Northwind db2 = new Northwind(ns.Session.Provider);

            // both objects should be different instances
            var cust = ns.Customers.Single(c => c.CustomerID == "ALFKI");
            var cust2 = ns.Customers.ProviderTable.Single(c => c.CustomerID == "ALFKI");

            Assert.NotEqual(null, cust);
            Assert.NotEqual(null, cust2);
            Assert.Equal(cust.CustomerID, cust2.CustomerID);
            Assert.NotEqual(cust, cust2);
        }
 public static void Initialize(TestContext context)
 {
     var provider = EntityProvider.From(TestConstants.ConnectionString, TestConstants.MappingId);
     db = new Northwind(provider);
     InitBase(provider);
 }
示例#11
0
        private static bool RunTest(string selection)
        {
            if (selection.Equals("q", StringComparison.OrdinalIgnoreCase))
            {
                return(false);
            }

            if (selection.Equals("s", StringComparison.OrdinalIgnoreCase))
            {
                if (adoProviderName == "IQToolkit.Data.OracleClient")
                {
                    adoProviderName = "IQToolkit.Data.ODP";
                }
                else
                {
                    adoProviderName = "IQToolkit.Data.OracleClient";
                }
                return(true);
            }

            string connectionStringName = "Oracle";
            string providerName         = ConfigurationManager.ConnectionStrings[connectionStringName].ProviderName;
            string connectionString     = ConfigurationManager.ConnectionStrings[connectionStringName].ConnectionString;

            var provider = DbEntityProvider.From(adoProviderName, connectionString, "Test.NorthwindWithAttributes");


            if (selection.StartsWith("log", StringComparison.OrdinalIgnoreCase))
            {
                if (selection.Equals("log on", StringComparison.OrdinalIgnoreCase))
                {
                    logEnabled = true;
                }
                else if (selection.Equals("log off", StringComparison.OrdinalIgnoreCase))
                {
                    logEnabled = false;
                }

                Console.WriteLine(String.Format("Log is {0}.", logEnabled ? "On" : "Off"));
                return(true);
            }

            if (logEnabled)
            {
                provider.Log = Console.Out;
            }
            else
            {
                provider.Log = null;
            }

            provider.Connection.Open();
            //provider.Cache = new QueryCache(5);
            try
            {
                var db = new Northwind(provider);

                if (selection.Contains("0") || selection.Contains("1"))
                {
                    NorthwindTranslationTests.Run(db, true);
                }
                if (selection.Contains("0") || selection.Contains("2"))
                {
                    NorthwindExecutionTests.Run(db);
                }
                if (selection.Contains("0") || selection.Contains("3"))
                {
                    NorthwindCUDTests.Run(db);
                }
                if (selection.Contains("0") || selection.Contains("4"))
                {
                    MultiTableTests.Run(new MultiTableContext(provider.New(new AttributeMapping(typeof(MultiTableContext)))));
                }
                if (selection.Contains("0") || selection.Contains("5"))
                {
                    NorthwindPerfTests.Run(db, "TestStandardQuery");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
            }
            finally
            {
                provider.Connection.Close();
            }

            return(true);
        }
 protected void RunTests(Northwind db, string baselineFile, string newBaselineFile, bool executeQueries)
 {
     this.db = db;
     var provider = (DbEntityProvider)db.Provider;
     base.RunTests(provider, baselineFile, newBaselineFile, executeQueries);
 }
 protected void RunTest(Northwind db, string baselineFile, bool executeQueries, string testName)
 {
     this.db = db;
     var provider = (DbEntityProvider)db.Provider;
     base.RunTest(provider, baselineFile, executeQueries, testName);
 }
示例#14
0
 public static void Run(Northwind db)
 {
     new NorthwindPerfTests().RunTests(db, null, null, true);
 }
示例#15
0
 public static void Run(Northwind db, string testName)
 {
     new NorthwindCUDTests().RunTest(db, null, true, testName);
 }
 public static void Run(Northwind db, string testName)
 {
     new NorthwindExecutionTests().RunTest(db, null, true, testName);
 }
        public void TestCustomersIncludeOrdersAndDetails()
        {
            var policy = new EntityPolicy();
            policy.IncludeWith<Customer>(c => c.Orders);
            policy.IncludeWith<Order>(o => o.Details);
            Northwind nw = new Northwind(this.provider.New(policy));

            var custs = nw.Customers.Where(c => c.CustomerID == "ALFKI").ToList();
            AssertValue(1, custs.Count);
            AssertNotValue(null, custs[0].Orders);
            AssertValue(6, custs[0].Orders.Count);
            AssertTrue(custs[0].Orders.Any(o => o.OrderID == 10643));
            AssertNotValue(null, custs[0].Orders.Single(o => o.OrderID == 10643).Details);
            AssertValue(3, custs[0].Orders.Single(o => o.OrderID == 10643).Details.Count);
        }
        public void TestOrdersIncludeDetailsWithFirst()
        {
            EntityPolicy policy = new EntityPolicy();
            policy.IncludeWith<Order>(o => o.Details);

            var ndb = new Northwind(provider.New(policy));
            var q = from o in ndb.Orders
                    where o.OrderID == 10248
                    select o;

            Order so = q.Single();
            AssertValue(3, so.Details.Count);
            Order fo = q.First();
            AssertValue(3, fo.Details.Count);
        }
        public void TestCustomersIncludeThenAssociateOrders()
        {
            var policy = new EntityPolicy();
            policy.IncludeWith<Customer>(c => c.Orders);
            policy.AssociateWith<Customer>(c => c.Orders.Where(o => (o.OrderID & 1) == 0));
            Northwind nw = new Northwind(this.provider.New(policy));

            var custs = nw.Customers.Where(c => c.CustomerID == "ALFKI").ToList();
            AssertValue(1, custs.Count);
            AssertNotValue(null, custs[0].Orders);
            AssertValue(3, custs[0].Orders.Count);
        }
 public void TestOrdersIncludeDetailsWithGroupBy()
 {
     var policy = new EntityPolicy();
     policy.IncludeWith<Order>(o => o.Details);
     Northwind nw = new Northwind(this.provider.New(policy));
     var list = nw.Orders.Where(o => o.CustomerID == "ALFKI").GroupBy(o => o.CustomerID).ToList();
     AssertValue(1, list.Count);
     var grp = list[0].ToList();
     AssertValue(6, grp.Count);
     var o10643 = grp.SingleOrDefault(o => o.OrderID == 10643);
     AssertNotValue(null, o10643);
     AssertValue(3, o10643.Details.Count);
 }
示例#21
0
        public override void Setup(string[] args)
        {
            base.Setup(args);

            this.db = new Northwind(this.GetProvider());
        }
        public void TestCustomersApplyComputedFilter()
        {
            string ci = "Lon";
            string ty = "don";
            var policy = new EntityPolicy();
            policy.Apply<Customer>(seq => seq.Where(c => c.City == ci + ty));
            Northwind nw = new Northwind(this.provider.New(policy));

            var custs = nw.Customers.ToList();
            AssertValue(6, custs.Count);
        }
        public void TestCustomersApplyFilterTwice()
        {
            var policy = new EntityPolicy();
            policy.Apply<Customer>(seq => seq.Where(c => c.City == "London"));
            policy.Apply<Customer>(seq => seq.Where(c => c.Country == "UK"));
            Northwind nw = new Northwind(this.provider.New(policy));

            var custs = nw.Customers.ToList();
            AssertValue(6, custs.Count);
        }
示例#24
0
        public override void Setup(string[] args)
        {
            base.Setup(args);

            this.db = new Northwind(this.GetProvider());
        }