private void onInvoiceMasterDBCError(DBConcurrencyException dbcx) { if (this.RefreshData(dbcx.Row as MDataSet.InvoiceMasterRow)) { MessageBox.Show("Запись была изменена пользователем :" + (dbcx.Row as MDataSet.InvoiceMasterRow).AuthorLastModif, "Ошибка совмесного доступа", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } }
public void DoesNotThrowWhenPostHandlingIsNotifyRethrowAndExceptionShouldBeHandled() { var originalException = new DBConcurrencyException(); ExceptionAssertHelper.DoesNotThrow(() => this.exceptionManager.HandleException(originalException, "Absorbing DBConcurrencyException, NotifyRethrow postHandling")); }
internal static Exception UpdateConcurrencyViolation(StatementType statementType, int affected, int expected, DataRow[] dataRows) { string resource; switch (statementType) { case StatementType.Update: resource = SR.ADP_UpdateConcurrencyViolation_Update; break; case StatementType.Delete: resource = SR.ADP_UpdateConcurrencyViolation_Delete; break; case StatementType.Batch: resource = SR.ADP_UpdateConcurrencyViolation_Batch; break; #if DEBUG case StatementType.Select: case StatementType.Insert: Debug.Assert(false, "should be here"); goto default; #endif default: throw ADP.InvalidStatementType(statementType); } DBConcurrencyException exception = new DBConcurrencyException(SR.Format(resource, affected.ToString(CultureInfo.InvariantCulture), expected.ToString(CultureInfo.InvariantCulture)), null, dataRows); TraceExceptionAsReturnValue(exception); return(exception); }
public void TranslatesExceptionMessageFromResourceFileWhenExceptionMessageResourceIsConfigured() { DBConcurrencyException exceptionThatIsHandled = new DBConcurrencyException(); Exception exceptionToThrowEnglish; this.exceptionManager.HandleException(exceptionThatIsHandled, "Wrap DBConcurrencyException into BusinessException, ThrowNewException postHandling", out exceptionToThrowEnglish); CultureInfo originalCulture = Thread.CurrentThread.CurrentUICulture; Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr-Ca"); Exception exceptionToThrowFrench; try { this.exceptionManager.HandleException(exceptionThatIsHandled, "Wrap DBConcurrencyException into BusinessException, ThrowNewException postHandling", out exceptionToThrowFrench); } finally { Thread.CurrentThread.CurrentUICulture = originalCulture; } Assert.IsTrue(exceptionToThrowEnglish.Message.Contains("English"), "English problem"); Assert.IsTrue(exceptionToThrowFrench.Message.Contains("French"), "French problem"); Assert.AreNotEqual(exceptionToThrowEnglish.Message, exceptionToThrowFrench.Message); }
public static Exception UpdateConcurrencyViolation(StatementType statementType, int affected, int expected, DataRow[] dataRows) { string format; switch (statementType) { case StatementType.Update: format = "Concurrency violation during update"; break; case StatementType.Delete: format = "Concurrency violation during delete"; break; case StatementType.Batch: format = "Concurrency violation during batch"; break; #if DEBUG case StatementType.Select: case StatementType.Insert: Debug.Assert(false, "should be here"); goto default; #endif default: throw ADP.InvalidStatementType(statementType); } string msg = string.Format(CultureInfo.CurrentCulture, format, affected, expected); DBConcurrencyException exception = new DBConcurrencyException(message: msg, inner: null, dataRows: dataRows); return(exception); }
[Fact] // .ctor (String) public void Constructor2() { DBConcurrencyException dbce; string msg = "MONO"; dbce = new DBConcurrencyException(msg); Assert.Null(dbce.InnerException); Assert.Same(msg, dbce.Message); Assert.Null(dbce.Row); Assert.Equal(0, dbce.RowCount); dbce = new DBConcurrencyException(null); Assert.Null(dbce.InnerException); Assert.NotNull(dbce.Message); Assert.Contains(typeof(DBConcurrencyException).FullName, dbce.Message); Assert.Null(dbce.Row); Assert.Equal(0, dbce.RowCount); dbce = new DBConcurrencyException(string.Empty); Assert.Null(dbce.InnerException); Assert.Equal(string.Empty, dbce.Message); Assert.Null(dbce.Row); Assert.Equal(0, dbce.RowCount); }
[Test] // .ctor (String) public void Constructor2() { DBConcurrencyException dbce; string msg = "MONO"; dbce = new DBConcurrencyException(msg); Assert.IsNull(dbce.InnerException, "#A:InnerException"); Assert.AreSame(msg, dbce.Message, "#A:Message:" + dbce.Message); Assert.IsNull(dbce.Row, "#A:Row"); #if NET_2_0 Assert.AreEqual(0, dbce.RowCount, "#A:RowCount"); #endif dbce = new DBConcurrencyException((string)null); Assert.IsNull(dbce.InnerException, "#B:InnerException"); Assert.IsNotNull(dbce.Message, "#B:Message1"); Assert.IsTrue(dbce.Message.IndexOf(typeof(DBConcurrencyException).FullName) != -1, "#B:Message2:" + dbce.Message); Assert.IsNull(dbce.Row, "#B:Row"); #if NET_2_0 Assert.AreEqual(0, dbce.RowCount, "#B:RowCount"); #endif dbce = new DBConcurrencyException(string.Empty); Assert.IsNull(dbce.InnerException, "#C:InnerException"); Assert.AreEqual(string.Empty, dbce.Message, "#C:Message"); Assert.IsNull(dbce.Row, "#C:Row"); #if NET_2_0 Assert.AreEqual(0, dbce.RowCount, "#C:RowCount"); #endif }
public void ThrowsExceptionHandlingExceptionWhenPostHandlingIsNotifyRethrowAndExceptionShouldBeHandled() { var originalException = new DBConcurrencyException(); ExceptionAssertHelper.Throws <ExceptionHandlingException>(() => this.exceptionManager.HandleException(originalException, "Throwing when DBConcurrencyException, NotifyRethrow postHandling")); }
[Fact] // .ctor (String) public void Constructor2() { DBConcurrencyException dbce; string msg = "MONO"; dbce = new DBConcurrencyException(msg); Assert.Null(dbce.InnerException); Assert.Same(msg, dbce.Message); Assert.Null(dbce.Row); Assert.Equal(0, dbce.RowCount); dbce = new DBConcurrencyException(null); Assert.Null(dbce.InnerException); Assert.NotNull(dbce.Message); Assert.True(dbce.Message.IndexOf(typeof(DBConcurrencyException).FullName) != -1); Assert.Null(dbce.Row); Assert.Equal(0, dbce.RowCount); dbce = new DBConcurrencyException(string.Empty); Assert.Null(dbce.InnerException); Assert.Equal(string.Empty, dbce.Message); Assert.Null(dbce.Row); Assert.Equal(0, dbce.RowCount); }
public void ThrowsExceptionHandlingExceptionWhenPostHandlingIsThrowNewExceptionAndExceptionShouldBeHandled() { var originalException = new DBConcurrencyException(); ExceptionAssertHelper.Throws <ExceptionHandlingException>(() => this.exceptionManager.HandleException(originalException, "Absorbing DBConcurrencyException, ThrowNewException postHandling")); }
private void onInvoiceDetailDBCError(DBConcurrencyException dbcx) { MDataSet.InvoiceDetailRow _invoiceDetailRow = dbcx.Row as MDataSet.InvoiceDetailRow; MDataSet.InvoiceDetailDataTable _invoiceDetailDataTable = new MDataSet.InvoiceDetailDataTable(); this.invoiceDetailTableAdapter.FillById(_invoiceDetailDataTable, (dbcx.Row as MDataSet.InvoiceDetailRow).ID); MDataSet.InvoiceDetailRow rowInDB = (_invoiceDetailDataTable.Rows[0] as MDataSet.InvoiceDetailRow); /*Сравнить изменения*/ if ((Convert.ToDecimal(_invoiceDetailRow["Quantity", DataRowVersion.Original]) != rowInDB.Quantity) | (Convert.ToDecimal(_invoiceDetailRow["PriceRetailNDS", DataRowVersion.Original]) != rowInDB.PriceRetailNDS)) { /*** Отменить **/ string strInDB = "Запись была изменена пользователем: \n"; string strMessage; strInDB += rowInDB.AuthorLastModif.ToString() + "\n"; strMessage = strInDB + "\n"; MessageBox.Show(strMessage + "Изменения отменены ", "Ошибка совмесного доступа", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.mDataSet.InvoiceDetail.Merge(_invoiceDetailDataTable); } else { _invoiceDetailRow.ClearErrors(); this.mDataSet.InvoiceDetail.Merge(_invoiceDetailDataTable, true); } }
[Fact] // .ctor () public void Constructor1() { DBConcurrencyException dbce = new DBConcurrencyException(); Assert.Null(dbce.InnerException); Assert.NotNull(dbce.Message); Assert.NotNull(dbce.Message); Assert.Null(dbce.Row); Assert.Equal(0, dbce.RowCount); }
public void ThrowsWrapedExceptionWhenPostHandlingIsThrowNewExceptionAndExceptionShouldBeHandled() { var originalException = new DBConcurrencyException(); BusinessException thrownException = ExceptionAssertHelper.Throws <BusinessException>(() => this.exceptionManager.HandleException(originalException, "Wrap DBConcurrencyException into BusinessException, ThrowNewException postHandling")); Assert.AreSame(originalException, thrownException.InnerException); }
public void ThrowsReplacedExceptionWhenPostHandlingIsThrowNewExceptionAndExceptionShouldBeHandled() { var originalException = new DBConcurrencyException(); BusinessException thrownException = ExceptionAssertHelper.Throws <BusinessException>(() => this.exceptionManager.HandleException(originalException, "Replace DBConcurrencyException with BusinessException, ThrowNewException postHandling")); Assert.IsNotNull(thrownException); Assert.IsTrue(typeof(BusinessException).IsAssignableFrom(thrownException.GetType())); }
[Test] // .ctor () public void Constructor1() { DBConcurrencyException dbce = new DBConcurrencyException(); Assert.IsNull(dbce.InnerException, "InnerException"); Assert.IsNotNull(dbce.Message, "Message1"); Assert.IsNotNull(dbce.Message, "Message2:" + dbce.Message); Assert.IsNull(dbce.Row, "Row"); Assert.AreEqual(0, dbce.RowCount, "RowCount"); }
// private static string GetMessage(DbEntityValidationException ex) // { // var errors = new StringBuilder(); // errors.AppendLine(); //#if DEBUG // errors.AppendLine($"[{ex.GetType().Name}]"); //#endif // foreach (var error in ex.EntityValidationErrors) // { // var entity = error.Entry.Entity; // if (entity == null) continue; // var entityName = GetEntityName(entity); // errors.AppendLine($"{entityName}:"); // errors.AppendLine(); // foreach (var validation in error.ValidationErrors) // { // var propertyName = validation.PropertyName; // var entityType = error.Entry.Entity.GetType(); // var propInfo = entityType.GetProperty(propertyName); // var attributes = propInfo?.GetCustomAttributes(typeof(DisplayAttribute), false); // var displayAttribute = attributes?.Length > 0 ? attributes[0] as DisplayAttribute : null; // propertyName = displayAttribute?.Name ?? propertyName; // if (displayAttribute?.ResourceType != null) // { // var resourceManager = new ResourceManager(displayAttribute.ResourceType); // propertyName = resourceManager.GetString(propertyName) ?? propertyName; // } // errors.AppendLine($"{propertyName}: {validation.ErrorMessage}"); // } // } // return errors.ToString(); // } private static string GetMessage(DBConcurrencyException ex) { var errors = new StringBuilder(); errors.AppendLine(); #if DEBUG errors.AppendLine($"[{ex.GetType().Name}]"); #endif return(errors.ToString()); }
/// <summary> /// Creates a new <see cref="IResponse"/> instance that represents a /// failed response for a resource that is currently locked for editing by another user. /// </summary> /// <param name="factory"><see cref="IResponseFactory"/></param> /// <param name="exception">A <see cref="DBConcurrencyException"/> that contains the details of who has the resource currently locked.</param> /// <returns><see cref="IResponse"/></returns> public static IResponse Locked(this IResponseFactory factory, DBConcurrencyException exception) { var details = new Dictionary <string, object> { ["UserId"] = exception?.Data["UserId"] as int?, ["DisplayName"] = exception?.Data["DisplayName"] as string, }; return(Error(factory, CommonStatusCodes.Locked, "The resource is currently locked for editing by another user.", details)); }
public void ProcessThrowsOriginalExceptionWhenPostHandlingIsNotifyRethrowAndExceptionShouldBeHandled() { var originalException = new DBConcurrencyException(); DBConcurrencyException thrownException = ExceptionAssertHelper.Throws <DBConcurrencyException>(() => this.exceptionManager.Process( () => { throw originalException; }, "Wrap DBConcurrencyException into BusinessException, NotifyRethrow postHandling")); Assert.AreSame(originalException, thrownException); }
[Test] // .ctor (String, Exception, DataRow []) public void Constructor4() { DataTable dt = new DataTable(); DataRow rowA = dt.NewRow(); DataRow rowB = dt.NewRow(); DataRow [] rows; Exception inner = new Exception(); DBConcurrencyException dbce; string msg = "MONO"; rows = new DataRow [] { rowA, null, rowB }; dbce = new DBConcurrencyException(msg, inner, rows); Assert.AreSame(inner, dbce.InnerException, "#A:InnerException"); Assert.AreSame(msg, dbce.Message, "#A:Message:" + dbce.Message); Assert.AreSame(rowA, dbce.Row, "#A:Row"); Assert.AreEqual(3, dbce.RowCount, "#A:RowCount"); rows = new DataRow [] { rowB, rowA, null }; dbce = new DBConcurrencyException((string)null, inner, rows); Assert.AreSame(inner, dbce.InnerException, "#B:InnerException"); Assert.IsTrue(dbce.Message.IndexOf(typeof(DBConcurrencyException).FullName) != -1, "#B:Message:" + dbce.Message); Assert.AreSame(rowB, dbce.Row, "#B:Row"); Assert.AreEqual(3, dbce.RowCount, "#B:RowCount"); rows = new DataRow [] { null, rowA }; dbce = new DBConcurrencyException(string.Empty, inner, rows); Assert.AreSame(inner, dbce.InnerException, "#C:InnerException"); Assert.AreEqual(string.Empty, dbce.Message, "#C:Message"); Assert.IsNull(dbce.Row, "#C:Row"); Assert.AreEqual(2, dbce.RowCount, "#C:RowCount"); rows = new DataRow [] { rowA }; dbce = new DBConcurrencyException(msg, (Exception)null, rows); Assert.IsNull(dbce.InnerException, "#D:InnerException"); Assert.AreSame(msg, dbce.Message, "#D:Message:" + dbce.Message); Assert.AreSame(rowA, dbce.Row, "#D:Row"); Assert.AreEqual(1, dbce.RowCount, "#D:RowCount"); rows = null; dbce = new DBConcurrencyException(msg, (Exception)null, rows); Assert.IsNull(dbce.InnerException, "#E:InnerException"); Assert.AreSame(msg, dbce.Message, "#E:Message:" + dbce.Message); Assert.IsNull(dbce.Row, "#E:Row"); Assert.AreEqual(0, dbce.RowCount, "#E:RowCount"); rows = null; dbce = new DBConcurrencyException((string)null, (Exception)null, rows); Assert.IsNull(dbce.InnerException, "#F:InnerException"); Assert.IsTrue(dbce.Message.IndexOf(typeof(DBConcurrencyException).FullName) != -1, "#F:Message:" + dbce.Message); Assert.IsNull(dbce.Row, "#F:Row"); Assert.AreEqual(0, dbce.RowCount, "#F:RowCount"); }
[Fact] // .ctor (String, Exception, DataRow []) public void Constructor4() { DataTable dt = new DataTable(); DataRow rowA = dt.NewRow(); DataRow rowB = dt.NewRow(); DataRow[] rows; Exception inner = new Exception(); DBConcurrencyException dbce; string msg = "MONO"; rows = new DataRow[] { rowA, null, rowB }; dbce = new DBConcurrencyException(msg, inner, rows); Assert.Same(inner, dbce.InnerException); Assert.Same(msg, dbce.Message); Assert.Same(rowA, dbce.Row); Assert.Equal(3, dbce.RowCount); rows = new DataRow[] { rowB, rowA, null }; dbce = new DBConcurrencyException(null, inner, rows); Assert.Same(inner, dbce.InnerException); Assert.Contains(typeof(DBConcurrencyException).FullName, dbce.Message); Assert.Same(rowB, dbce.Row); Assert.Equal(3, dbce.RowCount); rows = new DataRow[] { null, rowA }; dbce = new DBConcurrencyException(string.Empty, inner, rows); Assert.Same(inner, dbce.InnerException); Assert.Equal(string.Empty, dbce.Message); Assert.Null(dbce.Row); Assert.Equal(2, dbce.RowCount); rows = new DataRow[] { rowA }; dbce = new DBConcurrencyException(msg, null, rows); Assert.Null(dbce.InnerException); Assert.Same(msg, dbce.Message); Assert.Same(rowA, dbce.Row); Assert.Equal(1, dbce.RowCount); rows = null; dbce = new DBConcurrencyException(msg, null, rows); Assert.Null(dbce.InnerException); Assert.Same(msg, dbce.Message); Assert.Null(dbce.Row); Assert.Equal(0, dbce.RowCount); rows = null; dbce = new DBConcurrencyException(null, null, rows); Assert.Null(dbce.InnerException); Assert.Contains(typeof(DBConcurrencyException).FullName, dbce.Message); Assert.Null(dbce.Row); Assert.Equal(0, dbce.RowCount); }
public void ReturnsNullInOutParameterAndRecommendsRethrowingWhenPostHandlingIsNotifyRethrowAndExceptionShouldBeHandled() { var originalException = new DBConcurrencyException(); Exception exceptionToThrow; bool rethrowRecommended = this.exceptionManager.HandleException( originalException, "Replace DBConcurrencyException with BusinessException, NotifyRethrow postHandling", out exceptionToThrow); Assert.IsTrue(rethrowRecommended); Assert.IsNull(exceptionToThrow); }
public void ReturnsNullInOutParameterAndDoesNotRecommendRethrowingWhenPostHandlingIsNoneAndExceptionShouldBeHandled() { var originalException = new DBConcurrencyException(); Exception exceptionToThrow; bool rethrowRecommended = this.exceptionManager.HandleException( originalException, "Wrap DBConcurrencyException into BusinessException, None postHandling", out exceptionToThrow); Assert.IsFalse(rethrowRecommended); Assert.IsNull(exceptionToThrow); }
public void ReplacesExceptionInOutParameterAndRecommendsRethrowingWhenPostHandlingIsThrowNewExceptionAndExceptionShouldBeHandled() { var originalException = new DBConcurrencyException(); Exception exceptionToThrow; bool rethrowRecommended = this.exceptionManager.HandleException( originalException, "Replace DBConcurrencyException with BusinessException, ThrowNewException postHandling", out exceptionToThrow); Assert.IsTrue(rethrowRecommended); Assert.IsNotNull(exceptionToThrow); Assert.IsTrue(typeof(BusinessException).IsAssignableFrom(exceptionToThrow.GetType())); }
[Test] // .ctor () public void Constructor1() { DBConcurrencyException dbce = new DBConcurrencyException(); Assert.IsNull(dbce.InnerException, "InnerException"); Assert.IsNotNull(dbce.Message, "Message1"); #if NET_2_0 Assert.IsNotNull(dbce.Message, "Message2:" + dbce.Message); #else Assert.AreEqual(new SystemException().Message, dbce.Message, "Message2:" + dbce.Message); #endif Assert.IsNull(dbce.Row, "Row"); #if NET_2_0 Assert.AreEqual(0, dbce.RowCount, "RowCount"); #endif }
public void Row() { DataTable dt = new DataTable(); DataRow rowA = dt.NewRow(); DataRow rowB = dt.NewRow(); DBConcurrencyException dbce = new DBConcurrencyException(); dbce.Row = rowA; Assert.Same(rowA, dbce.Row); Assert.Equal(1, dbce.RowCount); dbce.Row = rowB; Assert.Same(rowB, dbce.Row); Assert.Equal(1, dbce.RowCount); dbce.Row = null; Assert.Null(dbce.Row); Assert.Equal(1, dbce.RowCount); }
public void Row() { DataTable dt = new DataTable(); DataRow rowA = dt.NewRow(); DataRow rowB = dt.NewRow(); DBConcurrencyException dbce = new DBConcurrencyException(); dbce.Row = rowA; Assert.AreSame(rowA, dbce.Row, "#A:Row"); Assert.AreEqual(1, dbce.RowCount, "#A:RowCount"); dbce.Row = rowB; Assert.AreSame(rowB, dbce.Row, "#B:Row"); Assert.AreEqual(1, dbce.RowCount, "#B:RowCount"); dbce.Row = null; Assert.IsNull(dbce.Row, "#C:Row"); Assert.AreEqual(1, dbce.RowCount, "#C:RowCount"); }
public async Task Apply <T>(string key, Func <T, T> f) where T : class, new() { var(item, tag) = await client.GetStateAndETagAsync <T>(StoreName, key); if (item == null) { item = new T(); } var newItem = f(item); var success = await client.TrySaveStateAsync(StoreName, key, newItem, tag); if (!success) { var ex = new DBConcurrencyException($"item with {key} have been updated"); logger.LogError(ex, ex.Message); throw ex; } }
private void onReceiptMasterDBCError(DBConcurrencyException dbcx) { try { MDataSet.ReceiptMasterDataTable _tmp = new MDataSet.ReceiptMasterDataTable(); this.receiptMasterTableAdapter.FillByPeriodNum(_tmp, 0); this.mDataSet.ReceiptMaster.Merge(_tmp); dbcx.Row.RowError = ""; } catch (Exception err) { MessageBox.Show(err.Message); MainForm.Log("onReceiptMasterDBCError" + err.Message); } }
private bool onInvoiceMasterDBCError(DBConcurrencyException dbcx) { try { MDataSet.InvoiceMasterDataTable _tmpTable = new MDataSet.InvoiceMasterDataTable(); this.invoiceMasterTableAdapter.FillByPeriodNum(_tmpTable, 0); this.mDataSet.InvoiceMaster.Merge(_tmpTable, true); this.invoiceMasterTableAdapter.Update(this.mDataSet.InvoiceMaster); } catch (Exception err) { MainForm.Log("onInvoiceMasterDBCError" + err.Message); return(false); } return(true); }
private void onInvoiceDetailDBCError(DBConcurrencyException dbcx) { MDataSet.InvoiceDetailRow _invoiceDetailRow = dbcx.Row as MDataSet.InvoiceDetailRow; MDataSet.InvoiceDetailDataTable _invoiceDetailDataTable = new MDataSet.InvoiceDetailDataTable(); if (_invoiceDetailRow.RowState == DataRowState.Deleted) { int _id = Convert.ToInt32(_invoiceDetailRow["ID", DataRowVersion.Original].ToString()); this.invoiceDetailTableAdapter.FillById(_invoiceDetailDataTable, _id); } else { this.invoiceDetailTableAdapter.FillById(_invoiceDetailDataTable, (dbcx.Row as MDataSet.InvoiceDetailRow).ID); } { _invoiceDetailRow.ClearErrors(); this.mDataSet.InvoiceDetail.Merge(_invoiceDetailDataTable, true); } MainForm.Log(" onInvoiceDetailDBCError " + "успешно"); }
[Test] // .ctor (String, Exception) public void Constructor3() { Exception inner = new Exception(); DBConcurrencyException dbce; string msg = "MONO"; dbce = new DBConcurrencyException(msg, inner); Assert.AreSame(inner, dbce.InnerException, "#A:InnerException"); Assert.AreSame(msg, dbce.Message, "#A:Message:" + dbce.Message); Assert.IsNull(dbce.Row, "#A:Row"); Assert.AreEqual(0, dbce.RowCount, "#A:RowCount"); dbce = new DBConcurrencyException((string)null, inner); Assert.AreSame(inner, dbce.InnerException, "#B:InnerException"); Assert.IsTrue(dbce.Message.IndexOf(typeof(DBConcurrencyException).FullName) != -1, "#B:Message:" + dbce.Message); Assert.IsNull(dbce.Row, "#B:Row"); Assert.AreEqual(0, dbce.RowCount, "#B:RowCount"); dbce = new DBConcurrencyException(string.Empty, inner); Assert.AreSame(inner, dbce.InnerException, "#C:InnerException"); Assert.AreEqual(string.Empty, dbce.Message, "#C:Message"); Assert.IsNull(dbce.Row, "#C:Row"); Assert.AreEqual(0, dbce.RowCount, "#C:RowCount"); dbce = new DBConcurrencyException(msg, (Exception)null); Assert.IsNull(dbce.InnerException, "#D:InnerException"); Assert.AreSame(msg, dbce.Message, "#D:Message:" + dbce.Message); Assert.IsNull(dbce.Row, "#D:Row"); Assert.AreEqual(0, dbce.RowCount, "#D:RowCount"); dbce = new DBConcurrencyException((string)null, (Exception)null); Assert.IsNull(dbce.InnerException, "#E:InnerException"); Assert.IsTrue(dbce.Message.IndexOf(typeof(DBConcurrencyException).FullName) != -1, "#E:Message:" + dbce.Message); Assert.IsNull(dbce.Row, "#E:Row"); Assert.AreEqual(0, dbce.RowCount, "#E:RowCount"); }
[Fact] // .ctor (String, Exception, DataRow []) public void Constructor4() { DataTable dt = new DataTable(); DataRow rowA = dt.NewRow(); DataRow rowB = dt.NewRow(); DataRow[] rows; Exception inner = new Exception(); DBConcurrencyException dbce; string msg = "MONO"; rows = new DataRow[] { rowA, null, rowB }; dbce = new DBConcurrencyException(msg, inner, rows); Assert.Same(inner, dbce.InnerException); Assert.Same(msg, dbce.Message); Assert.Same(rowA, dbce.Row); Assert.Equal(3, dbce.RowCount); rows = new DataRow[] { rowB, rowA, null }; dbce = new DBConcurrencyException(null, inner, rows); Assert.Same(inner, dbce.InnerException); Assert.True(dbce.Message.IndexOf(typeof(DBConcurrencyException).FullName) != -1); Assert.Same(rowB, dbce.Row); Assert.Equal(3, dbce.RowCount); rows = new DataRow[] { null, rowA }; dbce = new DBConcurrencyException(string.Empty, inner, rows); Assert.Same(inner, dbce.InnerException); Assert.Equal(string.Empty, dbce.Message); Assert.Null(dbce.Row); Assert.Equal(2, dbce.RowCount); rows = new DataRow[] { rowA }; dbce = new DBConcurrencyException(msg, null, rows); Assert.Null(dbce.InnerException); Assert.Same(msg, dbce.Message); Assert.Same(rowA, dbce.Row); Assert.Equal(1, dbce.RowCount); rows = null; dbce = new DBConcurrencyException(msg, null, rows); Assert.Null(dbce.InnerException); Assert.Same(msg, dbce.Message); Assert.Null(dbce.Row); Assert.Equal(0, dbce.RowCount); rows = null; dbce = new DBConcurrencyException(null, null, rows); Assert.Null(dbce.InnerException); Assert.True(dbce.Message.IndexOf(typeof(DBConcurrencyException).FullName) != -1); Assert.Null(dbce.Row); Assert.Equal(0, dbce.RowCount); }