public void Valid_savequoteIsNull_Return0() { #region 配置 Substitute ISaveQuoteRepository _saveQuoteRepository = Substitute.For <ISaveQuoteRepository>(); ISubmitInfoRepository _submitInfoRepository = Substitute.For <ISubmitInfoRepository>(); IQuoteResultRepository _quoteResultRepository = Substitute.For <IQuoteResultRepository>(); IUserInfoRepository _userInfoRepository = Substitute.For <IUserInfoRepository>(); _submitInfoRepository.GetSubmitInfo(Arg.Any <long>(), Arg.Any <int>()).Returns(x => new bx_submit_info()); _quoteResultRepository.GetQuoteResultByBuid(Arg.Any <long>(), Arg.Any <int>()).Returns(x => new bx_quoteresult()); _saveQuoteRepository.GetSavequoteByBuid(Arg.Any <long>()).Returns(x => null); UpdateBjdCheck updateBjdCheck = new UpdateBjdCheck(_saveQuoteRepository, _submitInfoRepository, _quoteResultRepository, _userInfoRepository); #endregion #region 操作 Arg bx_submit_info submitInfo = new bx_submit_info(); bx_quoteresult quoteresult = new bx_quoteresult(); bx_savequote savequote = new bx_savequote(); bx_userinfo userinfo = new bx_userinfo(); var result = updateBjdCheck.Valid(new CreateOrUpdateBjdInfoRequest()); #endregion #region 断言 Assert Assert.AreEqual(0, result.State); #endregion }
public UpdateBjdCheckMessage Valid(CreateOrUpdateBjdInfoRequest request) { UpdateBjdCheckMessage message = new UpdateBjdCheckMessage(); message.State = 1; try { message.SubmitInfo = _submitInfoRepository.GetSubmitInfo(request.Buid, SourceGroupAlgorithm.GetOldSource(request.Source)); if (message.SubmitInfo == null) { message.Message = string.Format("Buid为{0}Source为{1}的记录submitinfo为空", request.Buid, request.Source); message.State = 0; return(message); } message.Quoteresult = _quoteResultRepository.GetQuoteResultByBuid(request.Buid, SourceGroupAlgorithm.GetOldSource(request.Source)); if (message.Quoteresult == null) { message.Message = string.Format("Buid为{0}Source为{1}的记录quoteinfo为空", request.Buid, request.Source); message.State = 0; return(message); } message.ReqCarInfo = _quoteReqCarinfoRepository.Find(request.Buid); if (message.ReqCarInfo == null) { message.Message = string.Format("Buid为{0}Source为{1}的记录quotereqcarinfo为空", request.Buid, request.Source); message.State = 0; return(message); } message.Savequote = _saveQuoteRepository.GetSavequoteByBuid(request.Buid); if (message.Savequote == null) { message.Message = string.Format("Buid为{0}Source为{1}的记录saveinfo为空", request.Buid, request.Source); message.State = 0; return(message); } message.Userinfo = _userInfoRepository.FindByBuid(request.Buid); if (message.Userinfo == null) { message.Message = string.Format("Buid为{0}Source为{1}的记录userinfo为空", request.Buid, request.Source); message.State = 0; return(message); } } catch (Exception ex) { message.Message = string.Format("程序出险异常,错误信息为:{0}", ex.Message); message.State = -1; return(message); } return(message); }
public void Valid_quoteresultIsNull_Return0() { #region 配置 Substitute _submitInfoRepository.GetSubmitInfo(Arg.Any <long>(), Arg.Any <int>()).Returns(x => new bx_submit_info()); _quoteResultRepository.GetQuoteResultByBuid(Arg.Any <long>()).Returns(x => null); UpdateBjdCheck updateBjdCheck = new UpdateBjdCheck(_saveQuoteRepository, _submitInfoRepository, _quoteResultRepository, _userInfoRepository); #endregion #region 操作 Arg var result = updateBjdCheck.Valid(new CreateOrUpdateBjdInfoRequest()); #endregion #region 断言 Assert Assert.AreEqual(0, result.State); #endregion }