public EntityResult <BLL_Deal> UpdateDeal(BLL_Deal bLL_Deal)
 {
     return(RunInContextScope(() =>
     {
         return _dealManager.UpdateDeal(bLL_Deal);
     }));
 }
        public void DealManager_Put_ShouldCall_RepositorySave(BLL_Deal entity, string bypassCedantBrokerValidation)
        {
            #region Arrange
            Mock <IDealRepository>            dealRepository            = new Mock <IDealRepository>();
            Mock <IWorkbenchDealsRepository>  workbenchDealsRepository  = new Mock <IWorkbenchDealsRepository>();
            Mock <IDealStatusesLookupManager> dealStatusesLookupManager = new Mock <IDealStatusesLookupManager>();
            Mock <ITblDealRepository>         tblDealRepository         = SetupTblDealRepository(false);
            Mock <ICedantManager>             cedantManager             = SetupCedant();
            Mock <IBrokerManager>             brokerManager             = SetupBroker();

            SetupUserIdentity();
            SetupDealRepository(dealRepository, false, bypassCedantBrokerValidation);

            DealManager dealManager = new DealManager(userManager.Object, cacheStoreManager, mockLogManager.Object, dealRepository.Object, workbenchDealsRepository.Object, tblDealRepository.Object, dealStatusesLookupManager.Object, dealLockManager.Object, transformationManager, cedantManager.Object, brokerManager.Object, new Mock <ITblClausesDealRepository>().Object);
            #endregion

            #region Act
            EntityResult <BLL_Deal> actual = dealManager.UpdateDeal(entity);
            #endregion

            #region  Assert
            dealRepository.Verify(p => p.Get(It.IsAny <Expression <Func <grs_VGrsDeal, bool> > >()));
            tblDealRepository.Verify(p => p.Save(It.IsAny <TblDeal>(), false));

            Assert.IsNotNull(actual.Data);
            Assert.AreEqual(entity.Dealnum, actual.Data.Dealnum);
            Assert.AreEqual(entity.Dealname, actual.Data.Dealname);

            #endregion
        }
        public void DealManager_Put_ShouldCall_RepositoryPut_Negative(BLL_Deal entity, string bypassCedantBrokerValidation)
        {
            #region Arrange
            var globalRedDealRepository = new Mock <IWorkbenchDealsRepository>();
            var tblDealRepository       = SetupTblDealRepository(true);

            SetupWorkbenchDealsRepository(globalRedDealRepository);

            DealManager dealManager = new DealManager(userManager.Object, cacheStoreManager, mockLogManager.Object, new Mock <IDealRepository>().Object, globalRedDealRepository.Object, tblDealRepository.Object, new Mock <IDealStatusesLookupManager>().Object, new Mock <IEntityLockManager>().Object, transformationManager, new Mock <ICedantManager>().Object, new Mock <IBrokerManager>().Object, new Mock <ITblClausesDealRepository>().Object);
            #endregion

            #region  Assert
            Assert.Throws <NotFoundAPIException>(delegate { dealManager.SaveDeal(entity); });
            //Assert.That(() => dealManager.SaveDeal(entity), Throws.Exception);
            #endregion
        }
        public void DealManager_Put_ShouldCall_Validate(BLL_Deal entity, string bypassCedantBrokerValidation, bool hasValidCompanyGroup)
        {
            #region Arrange
            Mock <IDealRepository>            dealRepository            = new Mock <IDealRepository>();
            Mock <IWorkbenchDealsRepository>  workbenchDealsRepository  = new Mock <IWorkbenchDealsRepository>();
            Mock <IDealStatusesLookupManager> dealStatusesLookupManager = new Mock <IDealStatusesLookupManager>();
            Mock <ITblDealRepository>         tblDealRepository         = SetupTblDealRepository(false);
            Mock <ICedantManager>             cedantManager             = SetupCedant(hasValidCompanyGroup);
            Mock <IBrokerManager>             brokerManager             = SetupBroker(hasValidCompanyGroup);

            SetupUserIdentity();
            SetupDealRepository(dealRepository, false, bypassCedantBrokerValidation);

            DealManager dealManager = new DealManager(userManager.Object, cacheStoreManager, mockLogManager.Object, dealRepository.Object, workbenchDealsRepository.Object, tblDealRepository.Object, dealStatusesLookupManager.Object, dealLockManager.Object, transformationManager, cedantManager.Object, brokerManager.Object, new Mock <ITblClausesDealRepository>().Object);
            #endregion

            #region Act
            #endregion

            #region  Assert
            Assert.Throws <IllegalArgumentAPIException>(delegate { dealManager.UpdateDeal(entity); });
            #endregion
        }