Skip to content

Commit

Permalink
#5 - melhorias
Browse files Browse the repository at this point in the history
  • Loading branch information
matmiranda committed Aug 16, 2023
1 parent 9880292 commit dc27e46
Showing 1 changed file with 61 additions and 1 deletion.
62 changes: 61 additions & 1 deletion PagBankTest/UnitTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Moq;
using PagBank;
using PagBank.Model;
using RestSharp;
using System.Net;
using System.Reflection;
Expand All @@ -11,12 +12,71 @@ public class Tests
[Test]
public async Task SandBoxInvalidToken()
{
var body = new PagBankBody();
var customer = new Customer();
var phones = new List<Phone>();
var item = new Item();
var items = new List<Item>();
var phone = new Phone();
var charge = new Charge();
var address = new Address();
var charges = new List<Charge>();
var paymentMethod = new PaymentMethod();
var card = new Card();
var holder = new Holder();

body.ReferenceId = "referencia do pedido";
customer.Name = "Jose da Silva";
customer.Email = "[email protected]";
customer.TaxId = "12345678909";
phone.Area = 11;
phone.Number = 999999999;
phone.Type = "MOBILE";
customer.Phone = phone;
item.ReferenceId = "referencia do item";
item.Name = "nome do item";
item.Quantity = 1;
item.UnitAmount = 10000;
charge.ReferenceId = "referencia do pagamento";
charge.Description = "descricao do pagamento";
charge.Amount = new Amount { Value = 10000, Currency = "BRL" };
paymentMethod.Type = "CREDIT_CARD";
paymentMethod.Installments = 1;
card.Number = "4111111111111111";
card.ExpMonth = "12";
card.ExpYear = "2026";
card.SecuritCode = "123";
holder.Name = "Jose da Silva";
card.Holder = holder;
paymentMethod.Card = card;
paymentMethod.Capture = true;
charge.PaymentMethod = paymentMethod;
items.Add(item);
charges.Add(charge);
address.Street = "Avenida Brigadeiro Faria Lima";
address.Number = "1384";
address.Complement = "apto 12";
address.Locality = "Pinheiros";
address.City = "São Paulo";
address.RegionCode = "SP";
address.Country = "BRA";
address.PostalCode = "01452002";
customer.Phones = phones;
body.Customer = customer;
body.Items = items;
body.Charges = charges;
body.Shipping = new Shipping { Address = address };
body.NotificationUrls = new List<string> { "https://meusite.com/notificacoes" };
body.Charges = charges;
body.Trial = new Trial { Enabled = true, HoldSetupFee = false };
body.TosAccpetance = new TosAcceptance { Date = DateTime.Now, UserIp = "1" };

var client = new PagBankClient();
client.WithBaseUrl(BaseUrl.Sandbox);
client.WithMethod(PagBankMethod.Get);
client.WithToken("your-token");
client.WithResource("{seu-recurso}");
client.WithJsonBody(new PagBankBody());
client.WithJsonBody(body);
client.AddOrUpdateHeader("custom-header", "123");
var response = await client.ExecuteAsync();
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.Forbidden));
Expand Down

0 comments on commit dc27e46

Please sign in to comment.