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); }
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()); }
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()); }
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); }
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); }
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); }
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); }
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); }