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