void AssertError(BoletoFacilRequestException response, string errorMessage)
 {
     Assert.IsNotNull(response);
     Assert.AreEqual(400, response.HTTPStatusCode);
     Assert.IsFalse(response.Error.Success);
     Assert.AreEqual(errorMessage, response.Error.ErrorMessage);
 }
        public void IssueChargeErrorNoPayer()
        {
            BoletoFacil boletoFacil = GetBoletoFacil();
            Charge      charge      = Charge;

            charge.Payer = null;

            BoletoFacilRequestException response = AssertException <BoletoFacilRequestException>(() => boletoFacil.IssueCharge(charge));

            AssertError(response, "Parâmetro obrigatório 'payerName' não está presente");
        }
        public void IssueChargeErrorInvalidAmount()
        {
            BoletoFacil boletoFacil = GetBoletoFacil();
            Charge      charge      = Charge;

            charge.Amount = 0;

            BoletoFacilRequestException response = AssertException <BoletoFacilRequestException>(() => boletoFacil.IssueCharge(charge));

            AssertError(response, "Valor mínimo para cobrança é de R$ 2,50");
        }
        public void CreatePayeeMethodNotAllowedException()
        {
            BoletoFacil boletoFacil = GetBoletoFacil();
            Payee       payee       = Payee;

            payee.CpfCnpj = "12345678000199";

            BoletoFacilRequestException response = AssertException <BoletoFacilRequestException>(() => boletoFacil.CreatePayee(payee));

            Assert.IsNotNull(response);
            Assert.AreEqual(405, response.HTTPStatusCode);
        }
        public void ListChargesErrorNoDatesInformed()
        {
            BoletoFacil      boletoFacil = GetBoletoFacil();
            ListChargesDates dates       = new ListChargesDates();

            BoletoFacilRequestException response = AssertException <BoletoFacilRequestException>(() => boletoFacil.ListCharges(dates));

            Assert.IsNotNull(response);
            Assert.AreEqual(400, response.HTTPStatusCode);
            Assert.IsFalse(response.Error.Success);
            Assert.AreEqual("Favor informar a data de início de vencimento ou de pagamento", response.Error.ErrorMessage);
        }
        public void GetPayeeStatusInvalidPayeeException()
        {
            BoletoFacil boletoFacil = GetBoletoFacil();
            Payee       payee       = new Payee();

            payee.CpfCnpj = "12345678000199";

            BoletoFacilRequestException response = AssertException <BoletoFacilRequestException>(() => boletoFacil.GetPayeeStatus(payee));

            Assert.IsNotNull(response);
            Assert.AreEqual(400, response.HTTPStatusCode);
            Assert.IsFalse(response.Error.Success);
            Assert.AreEqual("Favorecido com CPF/CNPJ 12345678000199 inválido ou não encontrado", response.Error.ErrorMessage);
        }
        public void CancelChargeError()
        {
            BoletoFacil boletoFacil = GetBoletoFacil();
            Charge      charge      = Charge;

            charge.Code = "00000000";

            BoletoFacilRequestException response = AssertException <BoletoFacilRequestException>(() => boletoFacil.CancelCharge(charge));

            Assert.IsNotNull(response);
            Assert.AreEqual(400, response.HTTPStatusCode);
            Assert.IsFalse(response.Error.Success);
            Assert.AreEqual("Cobrança inválida", response.Error.ErrorMessage);
        }