public void AgentCanUse_NullObject_ReturnFalse() { IBxAgent agent = new NullBxAgent(); var result = agent.AgentCanUse(); Assert.IsFalse(result); }
private IBxAgent GetAgentModel(int agentid) { string cacheKey = string.Format("agent_key_cache_{0}", agentid); IBxAgent cacheValue = _cacheService.Get <bx_agent>(cacheKey); if (cacheValue == null) { cacheValue = _agentRepository.GetAgent(agentid); if (cacheValue == null) { cacheValue = new NullBxAgent(); } _cacheService.Set(cacheKey, cacheValue, 120);//5分钟 } return(cacheValue); }
public IBxAgent GetCommonAgentModelFactory(int agentid, IAgentRepository agentRepository) { string cacheKey = string.Format("agent_key_cache_{0}", agentid); IBxAgent cacheValue = CacheProvider.Get <bx_agent>(cacheKey); if (cacheValue == null) { cacheValue = agentRepository.GetAgent(agentid); if (cacheValue == null) { cacheValue = new NullBxAgent(); } CacheProvider.Set(cacheKey, cacheValue, 120);//5分钟 } return(cacheValue); }