Example #1
0
        public void GetAgentConfigByCityResponse_ThorwException_ReurnNegavite()
        {
            #region 配置 Substitute

            var agentConfigByCityService    = Substitute.For <IAgentConfigByCityService>();
            var agentRepository             = Substitute.For <IAgentRepository>();
            var channelModelMapRedisService = Substitute.For <IChannelModelMapRedisService>();

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


            var agentConfigByCity = new GetAgentConfigByCitysService(agentConfigByCityService, agentRepository,
                                                                     channelModelMapRedisService);

            #endregion

            #region 操作  Arg

            var request = agentConfigByCity.GetAgentConfigByCityResponse(0, 0);

            #endregion

            #region 断言  Assert

            Assert.AreEqual(-10003, request.BusinessStatus);

            #endregion
        }
Example #2
0
        public void GetAgentConfigByCityResponse_GetAgentConfigByCityIsNull_Reurn0()
        {
            #region 配置 Substitute

            var agentConfigByCityService    = Substitute.For <IAgentConfigByCityService>();
            var agentRepository             = Substitute.For <IAgentRepository>();
            var channelModelMapRedisService = Substitute.For <IChannelModelMapRedisService>();

            agentConfigByCityService.GetAgentConfigByCity(Arg.Any <int>(), Arg.Any <int>())
            .Returns(info => null);


            var agentConfigByCity = new GetAgentConfigByCitysService(agentConfigByCityService, agentRepository,
                                                                     channelModelMapRedisService);

            #endregion

            #region 操作  Arg

            var request = agentConfigByCity.GetAgentConfigByCityResponse(0, 0);

            #endregion

            #region 断言  Assert

            Assert.AreEqual(0, request.BusinessStatus);

            #endregion
        }
        public void GetLastQuotedResponse_ThorwException_ReurnNegavite()
        {
            //配置
            var agentConfigByCityService    = Substitute.For <IAgentConfigByCityService>();
            var agentRepository             = Substitute.For <IAgentRepository>();
            var channelModelMapRedisService = Substitute.For <IChannelModelMapRedisService>();

            agentRepository.When(x => x.GetAgent(Arg.Any <int>())).Do(info => { throw new Exception(); });

            var getAgentConfigByCitysService =
                new GetAgentConfigByCitysService(agentConfigByCityService, agentRepository, channelModelMapRedisService);

            //操作
            var result = getAgentConfigByCitysService.GetLastQuotedResponse(new GetLastQuotedRequest());

            //断言
            Assert.AreEqual(-10003, result.BusinessStatus);
        }