public void UpdateBjdInfo_ThrowExecption_Return0()
        {
            #region 配置  Substitute
            IBaodanXianZhongRepository _baodanXianZhongRepository = Substitute.For <IBaodanXianZhongRepository>();
            IBaodanxinxiRepository     _baodanxinxiRepository     = Substitute.For <IBaodanxinxiRepository>();
            IBxBjUnionRepository       _bjxUnionRepository        = Substitute.For <IBxBjUnionRepository>();
            ICreateActivity            _createActivity            = Substitute.For <ICreateActivity>();
            IMapBaoDanXinXiRecord      _mapBaoDanXinXiRecord      = Substitute.For <IMapBaoDanXinXiRecord>();
            IMapBaoDanXianZhongRecord  _mapBaoDanXianZhongRecord  = Substitute.For <IMapBaoDanXianZhongRecord>();
            IUpdateBjdCheck            _bjdCheck = Substitute.For <IUpdateBjdCheck>();

            _bjdCheck.Valid(new CreateOrUpdateBjdInfoRequest()).Returns(x => new UpdateBjdCheckMessage()
            {
                State = 1
            });

            _createActivity.When(x => x.AddActivity(new CreateOrUpdateBjdInfoRequest(), Arg.Any <int>()))
            .Do(info => { throw new Exception(); });

            CreateBjdInfoService service = new CreateBjdInfoService(_createActivity, _mapBaoDanXinXiRecord, _mapBaoDanXianZhongRecord, _bjxUnionRepository, _baodanXianZhongRepository, _baodanxinxiRepository, _bjdCheck);
            #endregion

            #region 操作  Arg
            var result = service.UpdateBjdInfo(Arg.Any <CreateOrUpdateBjdInfoRequest>(), null);
            #endregion

            #region 断言  Assert
            Assert.AreEqual(0, result);
            #endregion
        }
        public void UpdateBjdInfo_BaoDanXinXiIsNull_Return0()
        {
            #region 配置  Substitute
            IBaodanXianZhongRepository _baodanXianZhongRepository = Substitute.For <IBaodanXianZhongRepository>();
            IBaodanxinxiRepository     _baodanxinxiRepository     = Substitute.For <IBaodanxinxiRepository>();
            IBxBjUnionRepository       _bjxUnionRepository        = Substitute.For <IBxBjUnionRepository>();
            ICreateActivity            _createActivity            = Substitute.For <ICreateActivity>();
            IMapBaoDanXinXiRecord      _mapBaoDanXinXiRecord      = Substitute.For <IMapBaoDanXinXiRecord>();
            IMapBaoDanXianZhongRecord  _mapBaoDanXianZhongRecord  = Substitute.For <IMapBaoDanXianZhongRecord>();
            IUpdateBjdCheck            _bjdCheck = Substitute.For <IUpdateBjdCheck>();

            var request = new CreateOrUpdateBjdInfoRequest();
            int type    = Arg.Any <int>();

            _bjdCheck.Valid(request).Returns(x => new UpdateBjdCheckMessage()
            {
                State = 0
            });
            _createActivity.AddActivity(Arg.Any <CreateOrUpdateBjdInfoRequest>(), type)
            .Returns(x => new bx_preferential_activity());
            _baodanxinxiRepository.Add(Arg.Any <bj_baodanxinxi>()).Returns(x => null);

            CreateBjdInfoService service = new CreateBjdInfoService(_createActivity, _mapBaoDanXinXiRecord, _mapBaoDanXianZhongRecord, _bjxUnionRepository, _baodanXianZhongRepository, _baodanxinxiRepository, _bjdCheck);
            #endregion

            #region 操作  Arg
            var result = service.UpdateBjdInfo(request, null);
            #endregion

            #region 断言  Assert
            Assert.AreEqual(0, result);
            #endregion
        }
        public void UpdateBjdInfo_CheckReturn0_Return0()
        {
            #region 配置  Substitute
            IBaodanXianZhongRepository _baodanXianZhongRepository = Substitute.For <IBaodanXianZhongRepository>();
            IBaodanxinxiRepository     _baodanxinxiRepository     = Substitute.For <IBaodanxinxiRepository>();
            IBxBjUnionRepository       _bjxUnionRepository        = Substitute.For <IBxBjUnionRepository>();
            ICreateActivity            _createActivity            = Substitute.For <ICreateActivity>();
            IMapBaoDanXinXiRecord      _mapBaoDanXinXiRecord      = Substitute.For <IMapBaoDanXinXiRecord>();
            IMapBaoDanXianZhongRecord  _mapBaoDanXianZhongRecord  = Substitute.For <IMapBaoDanXianZhongRecord>();
            IUpdateBjdCheck            _bjdCheck = Substitute.For <IUpdateBjdCheck>();

            var request = new CreateOrUpdateBjdInfoRequest();

            _bjdCheck.Valid(request).Returns(x => new UpdateBjdCheckMessage()
            {
                State = 0
            });

            CreateBjdInfoService service = new CreateBjdInfoService(_createActivity, _mapBaoDanXinXiRecord, _mapBaoDanXianZhongRecord, _bjxUnionRepository, _baodanXianZhongRepository, _baodanxinxiRepository, _bjdCheck);
            #endregion

            #region 操作  Arg
            var result = service.UpdateBjdInfo(request, null);
            #endregion

            #region 断言  Assert
            Assert.AreEqual(0, result);
            #endregion
        }
Пример #4
0
        public long UpdateBjdInfo(CreateOrUpdateBjdInfoRequest request, IEnumerable <KeyValuePair <string, string> > pairs)
        {
            //校验
            #region
            //bx_claim_detail
            long baodanxinxiid = 0;

            //20160905修改source1248=>0123,传入的新数据转换
            var checkResult = _bjdCheck.Valid(request);
            if (checkResult.State == 0)
            {
                logErr.Info(checkResult.Message);
                return(checkResult.State);
            }

            #endregion
            try
            {
                //新增
                if (request.BxId == 0)
                {
                    //单独写一个接口  实现
                    bx_preferential_activity model = _createActivity.AddActivity(request, 5);
                    //单独写一个接口  实现

                    var baodanxinxi = _mapBaoDanXinXiRecord.MapBaodanxinxi(request, checkResult.SubmitInfo, checkResult.Quoteresult,
                                                                           checkResult.Savequote, checkResult.Userinfo, checkResult.ReqCarInfo, model);
                    var item = _baodanxinxiRepository.Add(baodanxinxi);

                    var agentinfo = _agentRepository.GetAgent(checkResult.Userinfo.Agent);

                    Task.Factory.StartNew(() =>
                    {
                        _addCrmStepsService.AddCrmSteps(request.ChildAgent, agentinfo == null ? "" : agentinfo.AgentName, "",
                                                        checkResult.Userinfo.LicenseNo, request.Source, request.BizRate, request.ForceRate,
                                                        model.id, request.Buid, item.Id, request.CityCode);
                    });

                    List <bx_ywxdetail> ywxList = _ywxdetailRepository.GetList(request.Buid);

                    var baodanxianzhong = _mapBaoDanXianZhongRecord.MapBaodanxianzhong(baodanxinxi, checkResult.Quoteresult, checkResult.Savequote,
                                                                                       checkResult.SubmitInfo, ywxList);
                    _baodanXianZhongRepository.Add(baodanxianzhong);

                    _bjxUnionRepository.Add(request.Buid, item.Id);
                    baodanxinxiid = item.Id;
                }
            }
            catch (Exception ex)
            {
                baodanxinxiid = -1;
                logErr.Info("创建报价单发生异常,请求串为:" + request.ToJson() + "/n错误信息:" + ex.Source + "\n" + ex.StackTrace + "\n" + ex.Message + "\n" + ex.InnerException);
            }
            return(baodanxinxiid);
        }
Пример #5
0
        public void UpdateBjdInfo_ThrowExecption_ReturnNegavite()
        {
            #region 配置  Substitute
            IBaodanXianZhongRepository _baodanXianZhongRepository = Substitute.For <IBaodanXianZhongRepository>();
            IBaodanxinxiRepository     _baodanxinxiRepository     = Substitute.For <IBaodanxinxiRepository>();
            IBxBjUnionRepository       _bjxUnionRepository        = Substitute.For <IBxBjUnionRepository>();
            ICreateActivity            _createActivity            = Substitute.For <ICreateActivity>();
            IMapBaoDanXinXiRecord      _mapBaoDanXinXiRecord      = Substitute.For <IMapBaoDanXinXiRecord>();
            IMapBaoDanXianZhongRecord  _mapBaoDanXianZhongRecord  = Substitute.For <IMapBaoDanXianZhongRecord>();
            IUpdateBjdCheck            _bjdCheck           = Substitute.For <IUpdateBjdCheck>();
            IAgentRepository           _agentRepository    = Substitute.For <IAgentRepository>();
            IAddCrmStepsService        _addCrmStepsService = Substitute.For <IAddCrmStepsService>();

            var request = new CreateOrUpdateBjdInfoRequest();
            int type    = Arg.Any <int>();

            _bjdCheck.Valid(request)
            .Returns(
                x =>
                new UpdateBjdCheckMessage()
            {
                State       = 1,
                SubmitInfo  = new bx_submit_info(),
                Quoteresult = new bx_quoteresult(),
                Savequote   = new bx_savequote(),
                Userinfo    = new bx_userinfo()
            });

            _createActivity.When(x => x.AddActivity(request, type))
            .Do(info => { throw new Exception(); });

            CreateBjdInfoService service = new CreateBjdInfoService(_createActivity, _mapBaoDanXinXiRecord, _mapBaoDanXianZhongRecord, _bjxUnionRepository, _baodanXianZhongRepository, _baodanxinxiRepository, _bjdCheck, _agentRepository, _addCrmStepsService);
            #endregion

            #region 操作  Arg
            var result = service.UpdateBjdInfo(request, null);
            #endregion

            #region 断言  Assert
            Assert.AreEqual(-1, result);
            #endregion
        }
Пример #6
0
        public void UpdateBjdInfo_CheckReturn0_Return0()
        {
            #region 配置  Substitute
            IBaodanXianZhongRepository _baodanXianZhongRepository = Substitute.For <IBaodanXianZhongRepository>();
            IBaodanxinxiRepository     _baodanxinxiRepository     = Substitute.For <IBaodanxinxiRepository>();
            IBxBjUnionRepository       _bjxUnionRepository        = Substitute.For <IBxBjUnionRepository>();
            ICreateActivity            _createActivity            = Substitute.For <ICreateActivity>();
            IMapBaoDanXinXiRecord      _mapBaoDanXinXiRecord      = Substitute.For <IMapBaoDanXinXiRecord>();
            IMapBaoDanXianZhongRecord  _mapBaoDanXianZhongRecord  = Substitute.For <IMapBaoDanXianZhongRecord>();
            IUpdateBjdCheck            _bjdCheck           = Substitute.For <IUpdateBjdCheck>();
            IAgentRepository           _agentRepository    = Substitute.For <IAgentRepository>();
            IAddCrmStepsService        _addCrmStepsService = Substitute.For <IAddCrmStepsService>();

            var request = new CreateOrUpdateBjdInfoRequest();

            _bjdCheck.Valid(request)
            .Returns(
                x =>
                new UpdateBjdCheckMessage()
            {
                State       = 0,
                SubmitInfo  = new bx_submit_info(),
                Quoteresult = new bx_quoteresult(),
                Savequote   = new bx_savequote(),
                Userinfo    = new bx_userinfo()
            });

            CreateBjdInfoService service = new CreateBjdInfoService(_createActivity, _mapBaoDanXinXiRecord, _mapBaoDanXianZhongRecord, _bjxUnionRepository, _baodanXianZhongRepository, _baodanxinxiRepository, _bjdCheck, _agentRepository, _addCrmStepsService);
            #endregion

            #region 操作  Arg
            var result = service.UpdateBjdInfo(request, null);
            #endregion

            #region 断言  Assert
            Assert.AreEqual(0, result);
            #endregion
        }