コード例 #1
0
        public void ReadValueFromSQL_InvalidCast()
        {
            // Arrange
            SqlValueReaderModule <string> db = new SqlValueReaderModule <string>();

            db.Context = ConnectionString;

            SqlQuery query = new SqlQuery();

            query.Query = "SELECT count(*) FROM Item;";

            // Act
            string count = db.Read(query);

            // Assert exception occured
        }
コード例 #2
0
        public void ReadValueFromSQL()
        {
            // Arrange
            SqlValueReaderModule <int> db = new SqlValueReaderModule <int>();

            db.Context = ConnectionString;

            SqlQuery query = new SqlQuery();

            query.Query = "SELECT count(*) FROM Item;";

            // Act
            int count = db.Read(query);

            // Assert
            Assert.IsTrue(count > 0);
        }
コード例 #3
0
        public void ReadValueFromSQL_WithParameters()
        {
            // Arrange
            SqlValueReaderModule <int> db = new SqlValueReaderModule <int>();

            db.Context = ConnectionString;

            SqlQuery query = new SqlQuery();

            query.Query = "SELECT count(*) FROM Item WHERE Color = @color;";
            query.Parameters["@color"] = "Black";

            // Act
            int count = db.Read(query);

            // Assert
            Assert.IsTrue(count == 1);
        }