Provides a controller that deletes business objects. Where used, this can be replaced with a customised version that inherits from IBusinessObjectDeletor.
Inheritance: IBusinessObjectDeletor
 ///<summary>
 /// Deletes the given business object
 ///</summary>
 ///<param name="businessObject">The business object to delete</param>
 public void DeleteBusinessObject(IBusinessObject businessObject)
 {
     string message;
     if (CustomConfirmationMessageDelegate != null)
     {
         message = CustomConfirmationMessageDelegate(businessObject);
     }
     else
     {
         message = string.Format("Are you certain you want to delete the object '{0}'", businessObject);
     }
     Confirmer.Confirm(message, delegate(bool confirmed)
         {
             if (!confirmed) return;
             var defaultBODeletor = new DefaultBODeletor();
             try
             {
                 defaultBODeletor.DeleteBusinessObject(businessObject);
             }
             catch (Exception ex)
             {
                 GlobalRegistry.UIExceptionNotifier.Notify(ex, "", "Error Deleting");
             }
         });
 }
Exemplo n.º 2
0
        ///<summary>
        /// Deletes the given business object
        ///</summary>
        ///<param name="businessObject">The business object to delete</param>
        public void DeleteBusinessObject(IBusinessObject businessObject)
        {
            string message;

            if (CustomConfirmationMessageDelegate != null)
            {
                message = CustomConfirmationMessageDelegate(businessObject);
            }
            else
            {
                message = string.Format("Are you certain you want to delete the object '{0}'", businessObject);
            }
            Confirmer.Confirm(message, delegate(bool confirmed)
            {
                if (!confirmed)
                {
                    return;
                }
                var defaultBODeletor = new DefaultBODeletor();
                try
                {
                    defaultBODeletor.DeleteBusinessObject(businessObject);
                }
                catch (Exception ex)
                {
                    GlobalRegistry.UIExceptionNotifier.Notify(ex, "", "Error Deleting");
                }
            });
        }
 public void Test_Construct()
 {
     //---------------Set up test pack-------------------
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     DefaultBODeletor businessObjectDeletor = new DefaultBODeletor();
     //---------------Test Result -----------------------
     Assert.IsInstanceOf(typeof(IBusinessObjectDeletor), businessObjectDeletor);
 }
 public void Test_DeleteBusinessObject_Success()
 {
     //---------------Set up test pack-------------------
     ITransactionCommitter transactionCommitter = GetTransactionCommitter();
     IBusinessObject boToDelete = MockRepository.GenerateMock<IBusinessObject>();
     DefaultBODeletor businessObjectDeletor = new DefaultBODeletor();
     //---------------Assert Precondition----------------
     Assert.IsNotNull(transactionCommitter);
     transactionCommitter.AssertWasNotCalled(committer => committer.CommitTransaction());
     //---------------Execute Test ----------------------
     businessObjectDeletor.DeleteBusinessObject(boToDelete);
     //---------------Test Result -----------------------
     boToDelete.AssertWasCalled(o => o.MarkForDelete());
     transactionCommitter.AssertWasCalled(committer => committer.CommitTransaction());
     boToDelete.AssertWasNotCalled(o => o.CancelEdits());
 }
        public void Test_DeleteBusinessObject_Failure()
        {
            //---------------Set up test pack-------------------
            ITransactionCommitter transactionCommitter = GetTransactionCommitter();
            DefaultBODeletor businessObjectDeletor = new DefaultBODeletor();
            IBusinessObject boToDelete = new FakeAddress();
            Exception expectedException = new Exception();
            transactionCommitter.Stub(t => t.CommitTransaction()).Throw(expectedException);
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------

            try
            {
                businessObjectDeletor.DeleteBusinessObject(boToDelete);
                Assert.Fail("Expected to throw an Exception");
            }
                //---------------Test Result -----------------------
            catch (Exception exception)
            {
                Assert.AreSame(expectedException, exception);
            }
        }