public void SHouldReturnErrorWhenHadActiveSubsription() { var payment = new PayPalPayment("123456", DateTime.Now, DateTime.Now.AddDays(5), 10, 10, "bruceWayne", _address, _document, "teste", _email); _subscription.AddPayment(payment); _student.AddSubscription(_subscription); _student.AddSubscription(_subscription); Assert.IsTrue(_student.Invalid); }
public void ShouldReturnErrorWhenHadActiveSubscription() { var payment = new PayPalPayment("12345678", DateTime.Now, DateTime.Now.AddDays(5), 10, 10, "Mountain Web", _document, _address, _email); _subscription.AddPayment(payment); _student.AddSubscription(_subscription); _student.AddSubscription(_subscription); Assert.IsTrue(_student.Invalid); }
public void ShouldReturnErrorWhenHadActiveSubscription() { var payment = new PayPalPayment("12345678", DateTime.Now, DateTime.Now.AddDays(5), 10, 10, document, "Meta Tecnologia", address, email); subscription.AddPayment(payment); student.AddSubscription(subscription); student.AddSubscription(subscription); Assert.IsTrue(student.Invalid); }
public void ShouldReturnErrorWhenHadActiveSubscription() { var payment = new PayPalPayment("4554", DateTime.Now, DateTime.Now.AddDays(5), 10, 10, "Stark Industries", _document, _address, _email); _subscription.AddPayment(payment); _student.AddSubscription(_subscription); _student.AddSubscription(_subscription); Assert.IsTrue(_student.Invalid); }
public void ShouldReturnErrorWhenActiveSubscription() { var payment = new PayPalPayment("54984887", _email, DateTime.Now, DateTime.Now.AddDays(3), 600, 600, "DEV CORP", _document, _address); _subscription.AddPayment(payment); _student.AddSubscription(_subscription); _student.AddSubscription(_subscription); Assert.True(_student.Invalid); }
public void ShouldReturnErrorWhenAddSubscription() { var payment = new PayPalPayment(DateTime.Now, DateTime.Now.AddDays(5), 10, 10, "WAYNE CORP", _document, _address, _email, "1234678"); _subscription.AddPayment(payment); _student.AddSubscription(_subscription); _student.AddSubscription(_subscription); Assert.IsTrue(_student.Invalid); }
public void ShouldReturnErrorWhenHadActiveSubscription() { var payment = new PaypalPayment(_email, "12345678", DateTime.Now, DateTime.Now.AddDays(10), 10, 10, "Wayner corp", _document, _address); _subscription.AddPayment(payment); _student.AddSubscription(_subscription); _student.AddSubscription(_subscription); Assert.IsTrue(_student.Invalid); }
public void ShouldReturnErrorWhenHadActiveSubscription() { var payment = new PayPalPayment("12345678", DateTime.Now, DateTime.Now.AddDays(5), 10, 10, "WAYNE CORP", _document, "Bat Caverna, n.º 0", _email); _subscription.AddPayment(payment); _student.AddSubscription(_subscription); _student.AddSubscription(_subscription); Assert.IsTrue(_student.Invalid); }
public void ActivedSubscription() { var payment = new PayPalPayment("1231asdasAS", DateTime.Now, DateTime.Now.AddDays(5), 10, 10, "Test Payment", _document, _address, _email); _subscription.AddPayment(payment); _student.AddSubscription(_subscription); _student.AddSubscription(_subscription); Assert.IsTrue(_student.Invalid); }
public void ShoudReturnErrorWhenHadActiveSubscription() { var payment = new PaypalPayment("123789", DateTime.Now, DateTime.Now.AddDays(5), 10, 10, "WAYNE CORP", _document, _address, _email); _subscription.AddPayment(payment); _student.AddSubscription(_subscription); _student.AddSubscription(_subscription); Assert.IsTrue(_student.Valid); }
public void ShouldReturnErrorWhenHasActiveSubscription() { var payment = new PaypalPayment("123456", DateTime.Now, DateTime.Now.AddDays(5), 10, 10, _address, _document, "Night's Watch", _email); _subscription.AddPayment(payment); _student.AddSubscription(_subscription); _student.AddSubscription(_subscription); Assert.IsTrue(_student.Invalid); }
public void ShouldReturnErrorWhenAddAnotherSubscriptionWithAnActiveSubscription() { var payment = new PayPalPayment("12345", DateTime.Now, DateTime.Now.AddDays(3), 100, 100, _document, "André", _address, _email); _subscription.AddPayment(payment); _student.AddSubscription(_subscription); _student.AddSubscription(_subscription); Assert.IsTrue(_student.Invalid); }
public void DevoRetornarErroQuandoHouverInscricaoAtiva() { var payment = new PayPalPayment(transactionCode: "1234567", paidDate: DateTime.Now, expireDate: DateTime.Now.AddDays(5), total: 10, totalPaid: 10, "NovaEmpresa", document: _document, address: _adress, email: _email); _subscription.AddPayment(payment); _student.AddSubscription(subscription: _subscription); _student.AddSubscription(subscription: _subscription); Assert.IsTrue(_student.Invalid); }
public void ShouldReturnErrorWhenHadActiveSubscription() { //estamos criando uma assinatra, e é para dar erro não deixar fazer duas assinaturas var payment = new PayPalPayment("12345678", DateTime.Now, DateTime.Now.AddDays(5), 10, 10, "DIANA CORP", _document, _address, _email); _subscription.AddPayment(payment); _student.AddSubscription(_subscription); _student.AddSubscription(_subscription); //Assert.Fail(); Assert.IsTrue(_student.Invalid); }
public void ShouldReturnErrorWhenHadActiveSubscription() { //Cria pagamento var payment = new PayPalPayment("123456789", DateTime.Now, DateTime.Now.AddDays(5), 100, 100, "Guilherme", _document, _address, _email); //Adiciona Pagamento _subscription.AddPayment(payment); //Adiciona inscrição _student.AddSubscripton(_subscription); _student.AddSubscripton(_subscription); Assert.IsTrue(_student.Invalid); }
public void ShouldReturnErrorWhenHadActiveSubscripton() { var payment = new PayPalPayment(DateTime.Now, DateTime.Now.AddDays(5), 10, 10, "Wayne Corp", _document, _address, _email, "12345678"); // add pagamento _subscription.AddPayment(payment); // add duas assinaturas _student.AddSubscription(_subscription); // assinatura valida _student.AddSubscription(_subscription); // gera erro Assert.IsTrue(_student.Invalid); }
public void ShouldReturnErrorWhenHadActiveSubscription() { var payment = new PayPalPayment("123123", DateTime.Now, DateTime.Now.AddDays(3), 20, 20, "Might Guy", _document, _address, _email); _subscription.AddPayment(payment); _student.AddSubscription(_subscription); _student.AddSubscription(_subscription); Assert.IsTrue(_student.Invalid); }
public void DeveRetornarErroQuandoJaTiverUmaAssinaturaAtiva() { //Arrange var payment = new PayPalPayment("123456", DateTime.Now, DateTime.Now.AddDays(5), 10, 10, _document, "Wayne CORP", _address, _email); //Action _subscription.AddPayment(payment); _student.AddSubscription(_subscription); _student.AddSubscription(_subscription); //Assert Assert.IsTrue(_student.Invalid); }
public void AdicionarAssinaturaValida() { var payment = new PayPalPayment(Guid.NewGuid().ToString("n"), DateTime.Now, DateTime.Now.AddDays(3), 10, 10, "Curringa", _document, _address, _email); _subscription.AddPayment(payment); _student.AddSubscription(_subscription); Assert.True(_student.Valid); Assert.True(_subscription.Valid); Assert.True(payment.Valid); Assert.Contains(_subscription, _student.Subscriptions); Assert.Contains(payment, _subscription.Payments); }
public ICommandResult Handle(CreateBoletoSubscriptionCommand command) { // Fail Fast Validations command.Validate(); if (command.Invalid) { AddNotifications(command); return(new CommandResult(false, "Não foi possivel realizar sua assinatura.")); } // Verificar se documento ja esta cadastrado. if (_repository.DocumentExists(command.DocumentNumber)) { AddNotification("Document", "Este CPF já esta em uso"); } // Verificar se email ja esta cadastrado if (_repository.EmailExists(command.Email)) { AddNotification("Email", "Este email ja esta em uso"); } // Gerar os VOs var name = new Name(command.FirstName, command.LastName); var document = new Document(command.DocumentNumber, EDocumentType.CPF); var email = new Email(command.Email); var address = new Address(command.Street, command.AddressNumber, command.Neighborhood, command.City, command.State, command.Country, command.ZipCode); // Gerar as Entidades var student = new Student(name, document, email); var subscription = new Subscription(DateTime.Now.AddMonths(1)); var payment = new BoletoPayment(command.BarCode, command.BoletoNumber, command.PaidDate, command.ExpireDate, command.Total, command.TotalPaid, command.Payer, new Document(command.PayerDocument, command.PayerDocumentType), address, email); // Relacionamentos subscription.AddPayment(payment); student.AddSubscription(subscription); // Aplicar as validações AddNotifications(name, document, email, address, student, subscription, payment); // Checar notificações if (Invalid) { return(new CommandResult(false, "Não foi possivel realizar sua assinatura.")); } // Salvar as informações _repository.CreateSubscription(student); // Enviar email de boas vindas. _emailService.Send(student.Name.ToString(), student.Email.Address, "Boas Vindas", $"Welcome {student.Name.ToString()}, sua assinatura foi criada!"); // Retornar informações. return(new CommandResult(true, "Assinatura realizada com sucesso.")); }
public void ShouldReturnSuccessWhenPaidDateIsInTheFuture() { var email = new Email("*****@*****.**"); var document = new Document("12345678901", EDocumentType.CPF); var address = new Address( street: "Street number three", number: "10000", neighborhood: "A pretty place", city: "Long Beach", state: "Boot lands", country: "United Status", zipCode: "12345" ); var payment = new PayPalPayment( email, transactionCode: "1234567890", paidDate: DateTime.Now.AddDays(3), expireDate: DateTime.Now, total: 100, totalPaid: 100, payer: "Angelo Evangelista", document, address ); var subscription = new Subscription(DateTime.Now.AddMonths(1)); subscription.AddPayment(payment); Assert.IsTrue(subscription.Valid); }
public ICommandResult Handle(CreateBoletoSubscriptionCommand command) { //Fail fast validations command.Validate(); if (command.Invalid) { AddNotifications(command); return(new CommandResult(false, "Não foi possível realizar sua assinatura")); } //verificar se documento já está cadastrado // AddNotifications(new Contract() // ); if (_repository.DocumentExists(command.Document)) { AddNotification("Document", "Este CPF já está em uso"); //AddNotifications(command); //return new CommandResult(false, "Não foi possível realizar sua assinatura"); } //verificar se email já está cadastrado if (_repository.EmailExists(command.Email)) { AddNotification("Email", "Este e-mail já está em uso"); } //gerar os VOs var name = new Name(command.FirstName, command.LastName); var document = new Document(command.Document, EDocumentType.CPF); var email = new Email(command.Email); var address = new Address(command.Street, command.Number, command.Neighborhood, command.City, command.State, command.Country, command.ZipCode); //gerar as entidades var student = new Student(name, document, email); var subscription = new Subscription(DateTime.Now.AddMonths(1)); var payment = new BoletoPayment(command.BarCode, command.BoletoNumber, command.PaidDate, command.ExpireDate, command.Total, command.TotalPaid, command.Payer, new Document(command.PayerDocument, command.PayerDocumentType), address, email); //relacionamentos subscription.AddPayment(payment); student.AddSubscription(subscription); //agrupar as validações AddNotifications(name, document, email, address, student, subscription, payment); //checar as notificacoes if (Invalid) { return(new CommandResult(false, "Não foi possivel realizar a sua assinatura")); } //salvar as informações _repository.CreateSubscription(student); //enviar e-mail de boas vindas _emailService.Send(student.Name.ToString(), student.Email.Address, "Bem vindo ao curso", "Sua assinatura foi criada"); //retornar informações return(new CommandResult(true, "Assinatura realizada com sucesso!")); }
public ICommandResult Handle(CreatePayPalSubscriptionCommand command) { // Fail Fast command.Validate(); if (command.Invalid) { return(new CommandResult(false, "Não foi possível realizar sua assinatura")); } AddNotifications(command); // Verificar se documento já está cadastrado if (_repository.DocumentExists(command.Document)) { AddNotification("Document", "Documeto já está em uso"); } // Verificar se email já está cadastrado if (_repository.EmailExists(command.Email)) { AddNotification("Email", "Email já está em uso"); } // Gerar os VOs var name = new Name(command.FirstName, command.LastName); var document = new Document(command.Document, EDocumentType.CPF); var email = new Email(command.Email); var address = new Address(command.Street, command.Number, command.Neighborhood, command.City, command.State, command.Country, command.ZipCode); // Gerar as Entidades var student = new Student(name, document, email); var subscription = new Subscription(DateTime.Now.AddMonths(1)); var payment = new PayPalPayment( command.PaidDate, command.ExpireDate, command.Payer, new Document(command.PayerDocument, command.PayerDocumentType), command.Total, command.TotalPaid, address, email, command.TransactionCode ); // Relacionamentos subscription.AddPayment(payment); student.AddSubscription(subscription); // Aplicar as Validações AddNotifications(name, document, email, address, student, subscription, payment); // Checar as notificações if (Invalid) { return(new CommandResult(false, "Não foi possível realizar sua assinatura")); } // Salvar as Informações _repository.CreateSubscription(student); // Enviar email de boas vindas _emailService.Send(command.Email, "*****@*****.**", "Bem vindo ao MDR", "Parabéns, agora você faz parte do Time!"); // Retornar informações return(new CommandResult(true, "Assinatura realizada com sucesso")); }
public ICommandResult Handle(CreateBoletoSubscriptionCommand command) { // Fail Fast Validation command.Validate(); if (command.Invalid) { AddNotifications(command); return(new CommandResult(false, "Não foi possivel realizar sua assinatura")); } // Verificar se Documento ja esta cadastrado if (_repository.DocumentsExists(command.Document)) { AddNotification("Document", "Este CPF ja esta em uso"); } // Verificar se E=mail ja esta cadastrado if (_repository.EmailExists(command.Email)) { AddNotification("Email", "Este E-mail ja esta em uso"); } // Gerar os VOs var name = new Name(command.FirstName, command.LastName); var document = new Document(command.Document, EDocumentType.cpf); var email = new Email(command.Email); var address = new Address(command.Street, command.Number, command.Neighborhood, command.City, command.State, command.Country, command.ZipCode); // Gerar as entidades var student = new Student(name, document, email); var subscription = new Subscription(DateTime.Now.AddDays(30)); var payment = new BoletoPayment( command.BarCode, command.BoletoNumber, command.PaidDate, command.ExpireDate, command.Total, command.TotalPaid, command.Payer, new Document(command.PayerDocument, command.PayerDocumentType), address, email ); // Relacionamentos subscription.AddPayment(payment); student.AddSubscription(subscription); // Agrupar as validaçoes AddNotifications(name, document, email, address, student, subscription, payment); // Salvar as Informaçoes _repository.CreateSubscription(student); // Enviar E-mail de boas vindas _emailService.Send(student.Name.ToString(), student.Email.Address, "Bem vindo ao TOMENOS ENTERPRISE", "Sua assinatura foi criada"); // Retornar informações return(new CommandResult(true, "Assinatura realizada com sucesso")); }
private ICommandResult CreateSubscription(CreateSubscriptionCommand command, Payment payment) { command.Validate(); AddNotifications(command.Notifications); if (_studentRepository.EmailExists(command.Email)) { AddNotification("Email", "E-mail já cadastrado."); } if (_studentRepository.DocumentExists(command.Document)) { AddNotification("Document", "Documento já cadastrado."); } GenerateGeneralValueObjects(command); GenerateSubscription(command); subscription.AddPayment(payment); student.AddSubscription(subscription); AddNotifications(student.Notifications); if (Invalid) { return(new CommandResult(false, string.Join(",", Notifications.Select(p => p.Message)))); } _studentRepository.CreateSubscription(student); SendWelcomeEmail(); return(new CommandResult(true, "Assinatura cadastrada com sucesso!")); }
public ICommandResult Handle(CreatePayPalSubscriptionCommand command) { //Verificar se o documento já está cadastrado if (_repository.DocumentExists(command.Document)) { AddNotification("Document", "Este CPF já está em uso."); } //Verificar se o email já está cadastrado if (_repository.EmailExists(command.Email)) { AddNotification("Email", "Este email já está em uso."); } //Gerar os VOs var name = new Name(command.FirstName, command.LastName); var document = new Document(command.Document, EDocumentType.CPF); var email = new Email(command.Email); var address = new Address(command.Street, command.Number, command.Neighborhood, command.City, command.State, command.Country, command.ZipCode); //Gerar as entidades var student = new Student(name, document, email); var subscription = new Subscription(DateTime.Now.AddMonths(1)); //Só muda a implementação do pagamento var payment = new PayPalPayment ( command.TransactionCode, command.PaidDate, command.ExpireDate, command.Total, command.TotalPaid, command.Payer, new Document(command.PayerDocument, command.PaymentDocumentType), address, email ); //Relacionamentos subscription.AddPayment(payment); student.AddSubscription(subscription); //Agrupar as validações AddNotifications(name, document, email, address, student, subscription, payment); //Checar as notificações if (Invalid) { return(new CommandResult(false, "Não foi possível realizar a assinatura")); } //Salvar as informações _repository.CreateSubscription(student); //Enviar email de boas vindas _emailService.Send(student.Name.ToString(), student.Email.Address, "Bem Vindo ao balta.io", "Sua assinatura foi criada."); //Retornar informações return(new CommandResult(true, "Assinatura realizada com sucesso!")); }
public ICommandResult Handle(CreatePayPalSubscriptionCommand command) { if (_studentRepository.DocumentExists(command.Document)) { AddNotification("Document", "Este CPF já está em uso"); } if (_studentRepository.EmailExists(command.Email)) { AddNotification("Email", "Este e-mail já está em uso"); } var name = new Name(command.FirstName, command.LastName); var document = new Document(command.Document, EDocumentType.CPF); var email = new Email(command.Email); var address = new Addres(command.Street, command.Number, command.Neighborhood, command.City, command.State, command.Country, command.ZipCode); var student = new Student(name, document, email); var subscription = new Subscription(DateTime.Now.AddMonths(1)); var payerDocument = new Document(command.PayerDocument, command.PayerDocumentType); var payment = new PayPalPayment(command.TransactionCode, command.PaidDate, command.ExpireDate, command.Total, command.TotalPaid, payerDocument, command.Payer, address, email); subscription.AddPayment(payment); student.AddSubscription(subscription); AddNotifications(name, document, email, address, student, subscription, payment); _studentRepository.CreateSubscription(student); _emailService.Send(student.Name.ToString(), student.Email.Address, "Bem vindo", "Sua assinatura foi criada"); return(new CommandResult(true, "Assinatura Realizada com Sucesso")); }
public ICommandResult Handler(CreateBoletoSubscriptionCommand command) { //Fail Fast Validation command.Validate(); if (command.Invalid) { AddNotifications(command); return(new CommandResult(false, "Não foi possível realizar sua assinatura")); } //Verifica se o documento já esta cadastrado! if (studentyRepository.DocumentExists(command.Document)) { AddNotification("Document", "Este CPF já está em uso"); } if (studentyRepository.EmailExists(command.Email)) { AddNotification("Email", "Este email já está em uso"); } //Entities e V.O. var name = new Name(command.FirstName, command.LastName); var email = new Email(command.Email); var address = new Address(command.Street, command.Number, command.Neighborhood, command.City, command.State, command.Contry, command.ZipCode); var document = new Document(command.Document, EDocumentType.CPF); var student = new Student(name, document, email); var subscription = new Subscription(DateTime.Now.AddMonths(1)); var payment = new BoletoPayment(command.BarCode, command.BoletoNumber, command.PaidDate, command.ExpireDate, command.Total, command.TotalPaid, command.Payer, new Document(command.PayerDocument, command.PayerDocumentType), address, email); //Relacionamentos subscription.AddPayment(payment); student.AddSubscription(subscription); //Agrupa as validações AddNotifications(name, document, address, student, subscription, payment); //Valida if (Invalid) { return(new CommandResult(false, "Não foi possível realizar sua assinatura")); } //Salva as informacoes studentyRepository.CreateSubscription(student); //Envia e-mail de boas vindas emailService.Send(student.Name.ToString(), student.Email.Address, "Bem vindo", "Sua assinatura foi criada!"); //retorna as informações return(new CommandResult(true, "Assinatura realizada com sucesso")); }
public void ShouldReturnErrorWhenHadActiveSubscription() { foreach (var notifications in _student.Name.Notifications) { Debug.WriteLine(notifications.Message); } var payment = new PayPalPayment("12345678", DateTime.Now, DateTime.Now.AddDays(5), 10, 10, "Wayne Corp", _document, _address, _email); _subscription.AddPayment(payment); _student.AddSubscription(_subscription); _student.AddSubscription(_subscription); Assert.IsTrue(_student.Invalid); }
public ICommandResult Handle(CreateBoletoSubscriptionCommand command) { //Fail Fast Validations command.Validate(); if (command.Invalid) { AddNotifications(command); return(new CommandResult(false, "Não foi possível realizar seu cadastro")); } //Verificar se Documento já está cadastrado if (_repository.DocumentExists(command.Document)) { AddNotifications(command); } //Pode ser utilizado o AddNotifications AddNotifications(new Contract() .Requires() .IsNotNullOrEmpty(command.Email, "Cadastro", "E-mail Inválido!") ); //Verificar se Email já está cadastrado if (_repository.EmailExists(command.Email)) { AddNotifications(command); } //Gerar os VOs var name = new Name(command.FirstName, command.LastName); var document = new Document(command.Document, EDocumentType.CPF); var email = new Email(command.Email); var address = new Address(command.Street, command.Number, command.Neightborhood, command.City, command.Country, command.ZipCode); //Gerar as Entidades var student = new Student(name, document, email, address); var subscription = new Subscription(DateTime.Now.AddMonths(1)); var payment = new BoletoPayment(command.PaidDate, command.ExpireDate, command.Total, command.Payer, new Document(command.PayerDocument, command.PayerDocumentType), command.TotalPaid, address, email); //Relacionamentos subscription.AddPayment(payment); student.AddSubscription(subscription); //Agrupar as Validações AddNotifications(name, document, address, student, subscription, payment); //Checar as notificações if (Invalid) { return(new CommandResult(false, "Não foi possível efetivar sua assinatura!")); } //Persistir as informações _repository.CreateSubscription(student); //Enviar e-mail de boas vindas _emailService.Send(student.Name.ToString(), student.Email.Address, "Bem Vindo!", "Sua assinatura foi criada!"); //Retornar informações return(new CommandResult(true, "Assinatura realizada com sucesso!")); }