Example #1
0
        public int Add(ErrorInfo errorInfo)
        {
            var db = new SqlDb(_connection);
            var com = StoredProcedureFactory.Create(_errorLoggingProcedure,
                                                    new SqlParameter("@OffendingURL", errorInfo.OffendingUrl),
                                                    new SqlParameter("@OccuredDate", errorInfo.ErrorDate),
                                                    new SqlParameter("@ErrorTitle", errorInfo.ErrorTitle),
                                                    new SqlParameter("@ErrorDescription", errorInfo.ErrorDescription),
                                                    new SqlParameter("@CurrentLogin", errorInfo.UserId),
                                                    new SqlParameter("@ApplicationName", errorInfo.ApplicationName));

            return db.ExecuteAndReturnScalar(com, "There was a problem logging the error to the database.").ToInt();
        }
Example #2
0
        public void ExecuteAndReturnScalar_ThrowsADBCommandExceptionWhenProcedureFails()
        {
            var database = new SqlDb(_testConn);
            // don't pass params to cause a failure
            var testProcedure = StoredProcedureFactory.Create("SqlDb_ExecuteAndReturnScalarTestProcedure1");

            database.ExecuteAndReturnScalar(testProcedure, "ExecuteAndReturnScalar test failed.");

            Assert.AreEqual(0, 0);
        }
Example #3
0
        public void ExecuteAndReturnScalar_InsertsItemAndReturnsIdOfAddedField()
        {
            const int expectedValue = 1;
            var database = new SqlDb(_testConn);
            var testProcedure = StoredProcedureFactory.Create("SqlDb_ExecuteAndReturnScalarTestProcedure1",
                new SqlParameter("@Param1", "Testing123"));

            object actualObject = database.ExecuteAndReturnScalar(testProcedure, "ExecuteAndReturnScalar test failed.");

            var actualValue = Convert.ToInt32(actualObject);
            Assert.AreEqual(expectedValue, actualValue);
        }