public void TestListarMoedasUsandoAAPIExterna() { byte[] resultmockNull = null; Mock <IDistributedCache> mckcache = new Mock <IDistributedCache>(); mckcache.Setup(x => x.Get("GetMoedasList")).Returns(resultmockNull); Mock <IConfigurationHelper> mckconfigurationHelper = new Mock <IConfigurationHelper>(); mckconfigurationHelper.Setup(x => x.GetSection("ACCESS_KEY")).Returns("?access_key=1503440cbd4d453ce74962abd00a82c2"); mckconfigurationHelper.Setup(x => x.GetSection("BASE_URL")).Returns("http://apilayer.net/api/"); IConversorService service = new ConversorService(new ConversorACLFactory(new MoedaFactory(), new RedisConnectorHelperFactory(mckcache.Object), mckconfigurationHelper.Object), new MoedaFactory()); List <IMoeda> result = service.GetMoedas(); Assert.True(result.Count > 0); }
public void TesteListarMoedas() { List <IMoeda> result = new List <IMoeda>(); result.Add(new Moeda("USD", 10)); result.Add(new Moeda("BRL", 10)); Mock <IMoedaFactory> moedaFactoryMock = new Mock <IMoedaFactory>(); Mock <IConversorACL> aclMck = new Mock <IConversorACL>(); Mock <IConversorACLFactory> aclFactoryMck = new Mock <IConversorACLFactory>(); aclMck.Setup(x => x.GetMoedas()).Returns(result); aclFactoryMck.Setup(x => x.Create()).Returns(aclMck.Object); IConversorService service = new ConversorService(aclFactoryMck.Object, moedaFactoryMock.Object); List <IMoeda> retorno = service.GetMoedas(); Assert.True(retorno.Count == 2); aclMck.VerifyAll(); aclFactoryMck.VerifyAll(); }