Example #1
0
        public CambioBusinessUnitTest()
        {
            mock = Substitute.For <ICambioBusiness>();

            mock.GetTaxasDeCambio(null)
            .Returns(s => { throw new Exception("A moeda precisa ser preenchida."); });

            mock.GetTaxasDeCambio(MOEDA_EMPTY)
            .Returns(s => { throw new Exception("A moeda precisa ser preenchida."); });

            mock.GetTaxasDeCambio(MOEDA_INVALIDA)
            .Returns(s => { throw new ArgumentException("A moeda informada é inválida."); });

            mock.GetTaxasDeCambio(MOEDA_VALIDA)
            .Returns(s => new CambioBuilder(MOEDA_VALIDA).TaxasDeCambio);
        }
Example #2
0
 public JsonResult GetTaxasDeCambio(string moeda)
 {
     try
     {
         var retorno = cambioBusiness.GetTaxasDeCambio(moeda);
         return(Json(new { success = true, response = retorno }));
     }
     catch (Exception ex)
     {
         return(Json(new { success = false, response = ex.Message }));
     }
 }
Example #3
0
        public void TestarParametroNull()
        {
            Exception ex = Assert.Throws <Exception>(() => mock.GetTaxasDeCambio(null));

            Assert.Equal("A moeda precisa ser preenchida.", ex.Message);
        }