public async Task ValidarCartao_ReturnaSucesso(BandeiraCartaoEnum cardBrand, string nome, string numeroCartao, TipoCartaoEnum tipo, string password) { var cartao = new Cartao() { CardBrand = cardBrand, CardHolderName = nome, ExpirationDate = DateTime.Now.AddMonths(2), Number = numeroCartao, Type = tipo, Password = password }; // Arrange var service = new OperadoraCartaoServices(); var result = service.ValidarCartao(cartao); Assert.NotNull(result); }
public async Task ValidarCartao_ReturnaExcessao(BandeiraCartaoEnum cardBrand, string nome, string numeroCartao, TipoCartaoEnum tipo, string password) { var cartao = new Cartao() { CardBrand = cardBrand, CardHolderName = nome, ExpirationDate = DateTime.Now.AddMonths(2), Number = numeroCartao, Type = tipo, Password = password }; // Arrange //var mockServices = new Mock<IOperadoraCartaoServices>(); //mockServices.Setup(s => s.ValidarCartao(It.IsAny<Cartao>())).Returns(Task.FromResult(cartao)); var service = new OperadoraCartaoServices(); Assert.ThrowsAsync <Exception>(() => service.ValidarCartao(cartao)); }
public async Task CreateAsync_ReturnOkResult(double amaunt, string merchantId, TipoTransacaoEnum tipo, BandeiraCartaoEnum cardBrand, string nome, string numeroCartao, TipoCartaoEnum tipoCartao, string password) { Guid guid; Guid.TryParse(merchantId, out guid); var cartao = new Cartao() { CardBrand = cardBrand, CardHolderName = nome, ExpirationDate = DateTime.Now.AddMonths(2), Number = numeroCartao, Type = tipoCartao, Password = password }; var transacao = new Transacao() { Amount = amaunt, ComercianteId = guid, Type = tipo, Number = 1, Card = cartao }; var comerciante = new Comerciante() { Id = guid }; // Arrange var mockServices = new Mock <IComercianteServices>(); mockServices.Setup(s => s.GetById(guid)).Returns(Task.FromResult(comerciante)); var mockBaseServices = new Mock <IBaseRepository <Transacao> >(); mockBaseServices.Setup(s => s.Insert(transacao)); var mockOperacaoCartaoServices = new Mock <IOperadoraCartaoServices>(); mockOperacaoCartaoServices.Setup(s => s.ValidarCartao(It.IsAny <Cartao>())); var servico = new TransacaoServices(mockBaseServices.Object, mockOperacaoCartaoServices.Object, mockServices.Object); // Act await servico.EfetuarOperacao(transacao); // Assert Assert.True(true); }