Beispiel #1
0
        public void All_NoParameters_Streaming()
        {
            var soh     = new SalesOrderHeaders();
            var allRows = soh.All();
            var count   = 0;
            int nonZeroSalesPersonID = 0;

            foreach (var r in allRows)
            {
                count++;
                Assert.Greater(r.SalesOrderID, 0);
                if (r.SalesPersonID > 0)
                {
                    nonZeroSalesPersonID++;
                    Assert.AreNotEqual("", r.PurchaseOrderNumber);
                }
                else
                {
                    Assert.Null(r.PurchaseOrderNumber);
                }
                Assert.Greater(r.CustomerID, 0);
                Assert.Greater(r.Status, 0);
            }
            Assert.AreEqual(31465, count);
            Assert.AreEqual(3806, nonZeroSalesPersonID);
        }
Beispiel #2
0
        public void All_LimitSpecification()
        {
            var soh     = new SalesOrderHeaders();
            var allRows = soh.All(limit: 10).ToList();

            Assert.AreEqual(10, allRows.Count);
        }
Beispiel #3
0
        public void All_WhereParams()
        {
            var soh     = new SalesOrderHeaders();
            var allRows = soh.All(new { CustomerId = 30052 }).ToList();

            Assert.AreEqual(4, allRows.Count);
        }
Beispiel #4
0
        public void All_NoParameters()
        {
            var soh     = new SalesOrderHeaders();
            var allRows = soh.All().ToList();

            Assert.AreEqual(31465, allRows.Count);
        }
Beispiel #5
0
        public void All_WhereClause()
        {
            var soh     = new SalesOrderHeaders();
            var allRows = soh.All(where : "WHERE CustomerId=@0", args: 30052).ToList();

            Assert.AreEqual(4, allRows.Count);
        }
Beispiel #6
0
        public void All_WhereParamsKey_ThrowsInvalidOperationException()
        {
            var ex = Assert.Throws <InvalidOperationException>(() => {
                var soh     = new SalesOrderHeaders();
                var allRows = soh.All(limit: 2, columns: "SalesOrderID, Status, SalesPersonID", whereParams: 30052).ToList();
            });

            Assert.AreEqual("whereParams in All(...) should contain names and values but it contained values only. If you want to get a single item by its primary key use Single(...) instead.", ex.Message);
        }
Beispiel #7
0
        public void All_ColumnSpecification()
        {
            var soh     = new SalesOrderHeaders();
            var allRows = soh.All(columns: "SalesOrderID, Status, SalesPersonID").ToList();

            Assert.AreEqual(31465, allRows.Count);
            var firstRow = allRows[0];

            Assert.Greater(firstRow.SalesOrderID, 0);
            Assert.AreNotEqual(0, firstRow.Status);
            Assert.Greater(firstRow.SalesPersonID, 0);
        }
Beispiel #8
0
        public void All_WhereParams_OrderBy()
        {
            var soh     = new SalesOrderHeaders();
            var allRows = soh.All(orderBy: "SalesOrderID DESC", whereParams: new { CustomerId = 30052 }).ToList();

            Assert.AreEqual(4, allRows.Count);
            int previous = int.MaxValue;

            foreach (var r in allRows)
            {
                int current = r.SalesOrderID;
                Assert.IsTrue(current <= previous);
                previous = current;
            }
        }
Beispiel #9
0
        public void All_OrderBySpecification()
        {
            var soh     = new SalesOrderHeaders();
            var allRows = soh.All(orderBy: "CustomerID DESC").ToList();

            Assert.AreEqual(31465, allRows.Count);
            int previous = int.MaxValue;

            foreach (var r in allRows)
            {
                int current = r.CustomerID;
                Assert.IsTrue(current <= previous);
                previous = current;
            }
        }
Beispiel #10
0
        public void All_WhereParams_Columns_Limit()
        {
            var soh     = new SalesOrderHeaders();
            var allRows = soh.All(limit: 2, columns: "SalesOrderID, Status, SalesPersonID", whereParams: new { CustomerId = 30052 }).ToList();
            int count   = 0;

            foreach (var item in allRows)
            {
                Assert.Greater(item.SalesOrderID, 0);
                Assert.Greater(item.Status, 0);
                Assert.Greater(item.SalesPersonID, 0);

                Assert.AreEqual(item.CustomerID, 0);
                Assert.Null(item.PurchaseOrderNumber);
                count++;
            }
            Assert.AreEqual(2, count);
        }
Beispiel #11
0
        public void All_WhereClause_Columns()
        {
            var soh     = new SalesOrderHeaders();
            var allRows = soh.All(columns: "SalesOrderID, Status, SalesPersonID", where : "WHERE CustomerId=@0", args: 30052);
            int count   = 0;

            foreach (var item in allRows)
            {
                Assert.Greater(item.SalesOrderID, 0);
                Assert.Greater(item.Status, 0);
                Assert.Greater(item.SalesPersonID, 0);

                Assert.AreEqual(item.CustomerID, 0);
                Assert.Null(item.PurchaseOrderNumber);
                count++;
            }
            Assert.AreEqual(4, count);
        }