コード例 #1
0
        public void RequiredPlaceholderIsNullException_CtorWithColumnName_ColumnNameSet()
        {
            RequiredPlaceholderIsNullException exception = new RequiredPlaceholderIsNullException("ColumnA");

            Assert.AreEqual("The value for ColumnA is required but has not been set", exception.Message);
            Assert.AreEqual("ColumnA", exception.ColumnName);
        }
コード例 #2
0
        public void RequiredPlaceholderIsNullException_ToString_ReturnFullDetails()
        {
            RequiredPlaceholderIsNullException exception = new RequiredPlaceholderIsNullException("ColumnA");

            Assert.AreEqual(@"DBConfirm.Core.Exceptions.RequiredPlaceholderIsNullException: The value for ColumnA is required but has not been set
ColumnName: ColumnA", exception.ToString());
        }
コード例 #3
0
        public void RequiredPlaceholderIsNullException_ToStringWithInnerException_ReturnFullDetails()
        {
            Exception inner = new ArgumentNullException();
            RequiredPlaceholderIsNullException exception = new RequiredPlaceholderIsNullException("Custom message", "ColumnA", inner);

            Assert.AreEqual(@"DBConfirm.Core.Exceptions.RequiredPlaceholderIsNullException: Custom message
ColumnName: ColumnA ---> System.ArgumentNullException: Value cannot be null.", exception.ToString());
        }
コード例 #4
0
        public void RequiredPlaceholderIsNullException_CtorWithColumnAndTableName_MessageAndColumnSet()
        {
            RequiredPlaceholderIsNullException exception = new RequiredPlaceholderIsNullException("ColumnA", "Table1");

            Assert.AreEqual("The value for ColumnA in table Table1 is required but has not been set", exception.Message);
            Assert.AreEqual("ColumnA", exception.ColumnName);
            Assert.AreEqual("Table1", exception.TableName);
        }
コード例 #5
0
        public void RequiredPlaceholderIsNullException_CtorWithMessageAndException_MessageSet()
        {
            Exception inner = new ArgumentNullException();
            RequiredPlaceholderIsNullException exception = new RequiredPlaceholderIsNullException("Custom message", inner);

            Assert.AreEqual("Custom message", exception.Message);
            Assert.AreEqual(inner, exception.InnerException);
        }
コード例 #6
0
        public void SqlQueryParameterExtensions_ArrayWithMultipleRequiredPlaceholder_ThrowFirstError()
        {
            SqlQueryParameter[] array = new SqlQueryParameter[]
            {
                new SqlQueryParameter("ColumnA", Placeholders.IsRequired()),
                new SqlQueryParameter("ColumnB", Placeholders.IsRequired())
            };
            RequiredPlaceholderIsNullException exception = Assert.Throws <RequiredPlaceholderIsNullException>(() => array.ToSqlParameters());

            Assert.AreEqual("ColumnA", exception.ColumnName);
            Assert.AreEqual("The value for ColumnA is required but has not been set", exception.Message);
        }
コード例 #7
0
        public void IDictionaryExtensions_DictionaryWithMultipleRequiredPlaceholder_ThrowFirstError()
        {
            IDictionary <string, object> dictionary = new Dictionary <string, object>
            {
                { "ColumnA", Placeholders.IsRequired() },
                { "ColumnB", Placeholders.IsRequired() }
            };
            RequiredPlaceholderIsNullException exception = Assert.Throws <RequiredPlaceholderIsNullException>(() => dictionary.ToSqlParameters());

            Assert.AreEqual("ColumnA", exception.ColumnName);
            Assert.AreEqual("The value for ColumnA is required but has not been set", exception.Message);
        }
コード例 #8
0
        public void RequiredPlaceholderIsNullException_DefaultCtor_MessageSet()
        {
            RequiredPlaceholderIsNullException exception = new RequiredPlaceholderIsNullException();

            Assert.AreEqual("The column is marked as required but has had no value set", exception.Message);
        }