public void ShoudReturnErrorWhenHadSubscriptionHasNoPayment()
        {
            var name     = new Name("Bruce", "Wayne");
            var document = new Domain.ValueObjects.Document("58941728029", EDocumentType.CPF);
            var email    = new Email("*****@*****.**");
            var student  = new Student(name, document, email);

            Assert.Fail();
        }
 public StudentTests()
 {
     _name         = new Name("Bruce", "Wayne");
     _document     = new Domain.ValueObjects.Document("58941728029", EDocumentType.CPF);
     _email        = new Email("*****@*****.**");
     _address      = new Address("Rua 1", "1234", "Bairro Teste", "Rio", "RJ", "BR", "23333333");
     _student      = new Student(_name, _document, _email);
     _subscription = new Subscription(null);
 }
Beispiel #3
0
        public ICommandResult Handle(CreateBoletoSubscriptionCommand command)
        {
            command.Validate();
            if (command.Invalid)
            {
                AddNotifications(command);
                return(new CommandResult(false, "Não foi possível realizar sua assinatura."));
            }

            if (_repository.DocumentExists(command.Document))
            {
                AddNotification("Document", "Este cpf já está em uso.");
            }

            if (_repository.DocumentExists(command.Email))
            {
                AddNotification("Email", "Este e-mail já está em uso.");
            }


            var name     = new Name("Bruce", "Wayne");
            var document = new Domain.ValueObjects.Document("58941728029", EDocumentType.CPF);
            var email    = new Email("*****@*****.**");
            var address  = new Address(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 payment      = new BoletoPayment(command.BarCode, command.BoletoNumber, command.Number, command.PaidDate, command.ExpireDate, command.Total, command.TotalPaid,
                                                 address, new Document(command.PayerDocument, command.PayerDocumentType), command.Owner, email);

            subscription.AddPayment(payment);
            student.AddSubscription(subscription);

            AddNotifications(name, document, email, address, student, subscription, payment);

            _repository.CreateSubscription(student);

            _emailService.Send(student.Name.ToString(), student.Email.Address, "Bem vindo", "Sua assinatura foi criada.");

            return(new CommandResult(true, "Assinatura realizada com sucesso"));
        }