public void TestValidaCartaoTrue() { var service = new CartaoService(); var result = service.ValidaCartao("4111111111111111"); Assert.IsTrue(result is CartaoBase); }
static void ValidaCartao(string numero) { try { var cartao = service.ValidaCartao(numero); Console.WriteLine($"{cartao.CardBrand} {cartao.CardNumber} {cartao.IsValid}"); } catch (CartaoInvalidoExcepion ex) { Console.WriteLine($"{ex.Message}"); } }
public void TestValidaCartaoFalse() { var service = new CartaoService(); try { service.ValidaCartao("12345"); Assert.Fail("no exception thrown"); } catch (System.Exception ex) { Assert.IsTrue(ex is CartaoInvalidoExcepion); } }