Example #1
0
        public void Column_Default_const()
        {
            var column = new _Int32();

            column.SetDefaultValue(5, null, null);
            column.VerifyDefault(5);
        }
Example #2
0
        public void Columns_Union()
        {
            {
                Assert.AreEqual(Columns.Empty, Columns.Empty.Union(Columns.Empty));
            }

            {
                var column1 = new _Int32();
                Assert.AreEqual(column1, Columns.Empty.Union(column1));
                Assert.AreEqual(column1, column1.Union(Columns.Empty));
            }

            {
                var column1 = new _Int32();
                Assert.AreEqual(column1, column1.Union(column1));
            }

            {
                var column1   = new _Int32();
                var column2   = new _Int32();
                var columnSet = column1.Union(column2);
                Assert.AreEqual(2, columnSet.Count);
                Assert.IsTrue(columnSet.Contains(column1));
                Assert.IsTrue(columnSet.Contains(column2));
            }
        }
Example #3
0
        public void CaseOn_Test()
        {
            var dataSet = DataSet <SimpleModel> .Create();

            var    column1 = dataSet._.Column1;
            _Int32 c1      = 1;
            _Int32 c0      = 0;
            var    expr    = Case.On(column1)
                             .When(c1).Then(_Boolean.True)
                             .When(c0).Then(_Boolean.False)
                             .Else(_Boolean.Null);
            var dbExpr = (DbCaseExpression)expr.DbExpression;

            dbExpr.Verify(column1, c1, _Boolean.True, c0, _Boolean.False, _Boolean.Null);

            var dataRow = dataSet.AddRow();

            column1[dataRow] = 1;
            Assert.AreEqual(true, expr[dataRow]);

            column1[dataRow] = 0;
            Assert.AreEqual(false, expr[dataRow]);

            column1[dataRow] = null;
            Assert.AreEqual(null, expr[dataRow]);
        }
Example #4
0
        private void TestFromBoolean(_Boolean x, Int32?expectedValue)
        {
            _Int32 expr   = (_Int32)x;
            var    dbExpr = (DbCastExpression)expr.DbExpression;

            dbExpr.Verify(x, typeof(bool?), typeof(Int32?));
            expr.VerifyEval(expectedValue);
        }
Example #5
0
        private void TestFromDouble(Double?x, Int32?expectedValue)
        {
            _Double column1 = x;
            _Int32  expr    = (_Int32)column1;
            var     dbExpr  = (DbCastExpression)expr.DbExpression;

            dbExpr.Verify(column1, typeof(Double?), typeof(Int32?));
            expr.VerifyEval(expectedValue);
        }
Example #6
0
        private void TestFromString(String x, Int32?expectedValue)
        {
            _String column1 = x;
            _Int32  expr    = (_Int32)column1;
            var     dbExpr  = (DbCastExpression)expr.DbExpression;

            dbExpr.Verify(column1, typeof(String), typeof(Int32?));
            expr.VerifyEval(expectedValue);
        }
Example #7
0
        private void TestCastToString(Int32?x, String expectedValue)
        {
            _Int32  column1 = x;
            _String expr    = (_String)column1;
            var     dbExpr  = (DbCastExpression)expr.DbExpression;

            dbExpr.Verify(column1, typeof(Int32?), typeof(String));
            expr.VerifyEval(expectedValue);
        }
Example #8
0
        private void TestNegate(Int32?x, Int32?expectedValue)
        {
            _Int32 column = x;
            var    expr   = -column;
            var    dbExpr = (DbUnaryExpression)expr.DbExpression;

            dbExpr.Verify(DbUnaryExpressionKind.Negate, column);
            expr.VerifyEval(expectedValue);
        }
Example #9
0
        private void TestOnesComplement(Int32?x, Int32?expectedValue)
        {
            _Int32 column = x;
            var    expr   = ~column;
            var    dbExpr = (DbUnaryExpression)expr.DbExpression;

            dbExpr.Verify(DbUnaryExpressionKind.OnesComplement, column);
            expr.VerifyEval(expectedValue);
        }
Example #10
0
        private void TestFromInt32(Int32?x, WeekDay?expectedValue)
        {
            _Int32 column1 = x;
            var    expr    = (_Int32Enum <WeekDay>)column1;
            var    dbExpr  = (DbCastExpression)expr.DbExpression;

            dbExpr.Verify(column1, typeof(Int32?), typeof(WeekDay?));
            expr.VerifyEval(expectedValue);
        }
Example #11
0
        private void TestFromInt32(Int32?x, Double?expectedValue)
        {
            _Int32  column1 = x;
            _Double expr    = (_Double)column1;
            var     dbExpr  = (DbCastExpression)expr.DbExpression;

            dbExpr.Verify(column1, typeof(Int32?), typeof(Double?));
            expr.VerifyEval(expectedValue);
        }
Example #12
0
        private void TestFromInt16(Int16?x, Int32?expectedValue)
        {
            _Int16 column1 = x;
            _Int32 expr    = column1;
            var    dbExpr  = (DbCastExpression)expr.DbExpression;

            dbExpr.Verify(column1, typeof(Int16?), typeof(Int32?));
            expr.VerifyEval(expectedValue);
        }
Example #13
0
        private void TestAdd(Int32?x, Int32?y, Int32?expectedValue)
        {
            _Int32 column1 = x;
            _Int32 column2 = y;
            var    expr    = column1 + column2;
            var    dbExpr  = (DbBinaryExpression)expr.DbExpression;

            dbExpr.Verify(BinaryExpressionKind.Add, column1, column2);
            expr.VerifyEval(expectedValue);
        }
Example #14
0
        private void TestGreaterThan(Int32?x, Int32?y, bool?expectedValue)
        {
            _Int32 column1 = x;
            _Int32 column2 = y;
            var    expr    = column1 > column2;
            var    dbExpr  = (DbBinaryExpression)expr.DbExpression;

            dbExpr.Verify(BinaryExpressionKind.GreaterThan, column1, column2);
            expr.VerifyEval(expectedValue);
        }
Example #15
0
        public void Columns_Equals()
        {
            var column1 = new _Int32();
            var column2 = new _Int32();

            var columns1 = Columns.Empty.Add(column1).Add(column2);
            var columns2 = Columns.Empty.Add(column2).Add(column1);

            Assert.IsTrue(columns1.Equals(columns2));
        }
Example #16
0
        private void TestNotEqual(Int32?x, Int32?y, bool?expectedValue)
        {
            _Int32 column1 = x;
            _Int32 column2 = y;
            var    expr    = column1 != column2;
            var    dbExpr  = (DbBinaryExpression)expr.DbExpression;

            dbExpr.Verify(BinaryExpressionKind.NotEqual, column1, column2);
            expr.VerifyEval(expectedValue);
        }
Example #17
0
        public void KeyBase_column_sort_list_successfully_constructed()
        {
            var column1   = new _Int32();
            var column2   = new _Int32();
            var simpleKey = new SimpleKey(column1, column2);

            Assert.AreEqual(2, simpleKey.Count);
            Assert.AreEqual(column1, simpleKey[0].Column);
            Assert.AreEqual(column2, simpleKey[1].Column);
            Assert.AreEqual(SortDirection.Unspecified, simpleKey[0].Direction);
            Assert.AreEqual(SortDirection.Descending, simpleKey[1].Direction);
        }
Example #18
0
        public void Columns_IsProperSupersetOf()
        {
            Assert.IsTrue(Columns.Empty.IsSubsetOf(Columns.Empty));

            var column1     = new _Int32();
            var column2     = new _Int32();
            var column1And2 = Columns.New(column1, column2);

            Assert.IsTrue(column1And2.IsProperSupersetOf(column1));
            Assert.IsTrue(column1And2.IsProperSupersetOf(column2));
            Assert.IsFalse(column1And2.IsProperSupersetOf(column1And2));
        }
Example #19
0
        public void Column_Nullable()
        {
            var column = new _Int32();

            column.VerifyNullable(true);

            column.Nullable(false);
            column.VerifyNullable(false);

            column.Nullable(true);
            column.VerifyNullable(true);
        }
Example #20
0
        public void Columns_New()
        {
            {
                var column1 = new _Int32();
                Assert.AreEqual(column1, Columns.New(column1));
            }

            {
                var column1   = new _Int32();
                var column2   = new _Int32();
                var columnSet = Columns.New(column1, column2);
                Assert.AreEqual(2, columnSet.Count);
                Assert.IsTrue(columnSet.Contains(column1));
                Assert.IsTrue(columnSet.Contains(column2));
            }
        }
Example #21
0
        public async Task DbTable_UpdateAsync_self_increment()
        {
            var log = new StringBuilder();

            using (var db = await MockSalesOrder.CreateAsync(CreateDb(log)))
            {
                _Int32 salesOrderId = 1;
                var    dataSet      = await db.SalesOrderHeader.Where(_ => _.SalesOrderID == salesOrderId).ToDataSetAsync();

                Assert.AreEqual(1, dataSet.Count);
                var revisionNumber = dataSet._.RevisionNumber[0];

                await db.SalesOrderHeader.UpdateAsync((m, _) => m.Select(_.RevisionNumber + 1, _.RevisionNumber), _ => _.SalesOrderID == salesOrderId);

                dataSet = await db.SalesOrderHeader.Where(_ => _.SalesOrderID == salesOrderId).ToDataSetAsync();

                Assert.AreEqual(1, dataSet.Count);
                Assert.AreEqual(revisionNumber + 1, dataSet._.RevisionNumber[0]);
            }
        }
Example #22
0
 private static int Calculate8(DataRow dataRow, _Int32 id1, _Int32 id2, _Int32 id3, _Int32 id4, _Int32 id5, _Int32 id6, _Int32 id7, _Int32 id8)
 {
     return(id1[dataRow].Value + id2[dataRow].Value + id3[dataRow].Value + id4[dataRow].Value + id5[dataRow].Value + id6[dataRow].Value
            + id7[dataRow].Value + id8[dataRow].Value);
 }
Example #23
0
 public SimpleKey(_Int32 column1, [Desc] _Int32 column2)
     : base(column1, column2.Desc())
 {
 }
Example #24
0
 private static int Calculate1(DataRow dataRow, _Int32 id)
 {
     return(id[dataRow].Value);
 }
Example #25
0
 private static int Calculate12(DataRow dataRow, _Int32 id1, _Int32 id2, _Int32 id3, _Int32 id4, _Int32 id5, _Int32 id6, _Int32 id7,
                                _Int32 id8, _Int32 id9, _Int32 id10, _Int32 id11, _Int32 id12)
 {
     return(id1[dataRow].Value + id2[dataRow].Value + id3[dataRow].Value + id4[dataRow].Value + id5[dataRow].Value + id6[dataRow].Value
            + id7[dataRow].Value + id8[dataRow].Value + id9[dataRow].Value + id10[dataRow].Value + id11[dataRow].Value + id12[dataRow].Value);
 }
Example #26
0
 private static int Calculate3(DataRow dataRow, _Int32 id1, _Int32 id2, _Int32 id3)
 {
     return(id1[dataRow].Value + id2[dataRow].Value + id3[dataRow].Value);
 }
Example #27
0
 public PK(_Int32 id) : base(id)
 {
 }
Example #28
0
        private void TestConst(Int32?x)
        {
            _Int32 column = _Int32.Const(x);

            column.VerifyConst(x);
        }
Example #29
0
 private static int Calculate5(DataRow dataRow, _Int32 id1, _Int32 id2, _Int32 id3, _Int32 id4, _Int32 id5)
 {
     return(id1[dataRow].Value + id2[dataRow].Value + id3[dataRow].Value + id4[dataRow].Value + id5[dataRow].Value);
 }
Example #30
0
        private void TestImplicit(Int32?x)
        {
            _Int32 column = x;

            column.VerifyParam(x);
        }