예제 #1
0
        public void DbCommandUtilExecuteScalarTest()
        {
            // Null
            var comm = new DbCommandUtil("SELECT ID FROM TEST");

            Assert.Equal(ConnectionState.Closed, comm.DaScopeContext.Connection.State);
            var testNullValue = comm.ExecuteScalar <int?>();

            Assert.Equal(ConnectionState.Closed, comm.DaScopeContext.Connection.State);
            Assert.Null(testNullValue);
            // Insert
            Insert();
            // NotNull
            var testNotNullValue = comm.ExecuteScalar <int?>();

            Assert.Equal(ConnectionState.Closed, comm.DaScopeContext.Connection.State);
            Assert.NotNull(testNotNullValue);
            Assert.Equal(2, testNotNullValue);
        }
예제 #2
0
        public void ParameterPrecisionTest()
        {
            Insert();
            var comm = new DbCommandUtil("SELECT ID FROM TEST WHERE Value = @Value");

            Assert.Equal(ConnectionState.Closed, comm.DaScopeContext.Connection.State);
            comm.AddParameter("@Value", DbType.Double, 4, 2, 35.4);
            var idValue = comm.ExecuteScalar <int?>();

            Assert.Equal(3, idValue);
        }