コード例 #1
0
            public void ErrorWhenNameIsInvalid()
            {
                var command = new CreateBoletoSubscriptionCommand();

                command.FirstName = "";
                command.Validate();
                Assert.IsTrue(command.Invalid);
            }
コード例 #2
0
        public void ShoulReturnErrorWhenBNameIsInvalid()
        {
            var command = new CreateBoletoSubscriptionCommand();

            command.FirstName = "";
            command.Validate();
            Assert.AreEqual(false, command.IsValid);
        }
コード例 #3
0
        public void ShouldReturnErrorWhenNameIsInvalid()
        {
            var command = new CreateBoletoSubscriptionCommand();

            command.FirstName = "";
            command.Validate();
            Assert.IsFalse(command.Valid);
        }
        public void TestMethod1()
        {
            var command = new CreateBoletoSubscriptionCommand {
                FirstName = ""
            };

            command.Validate();
            Assert.AreEqual(false, command.Valid);
        }
コード例 #5
0
        public void ShoulReturnErrorWhenNameIsInvalid()
        {
            var command = new CreateBoletoSubscriptionCommand();

            command.FirstName = "";

            command.Validate();// método que possui as validações dentro do command
            Assert.AreEqual(true, command.Invalid);
        }
コード例 #6
0
        public void ShouldReturnErrorWhenNameIsInvalid()
        {
            var boletoCommand = new CreateBoletoSubscriptionCommand();

            boletoCommand.FirstName = "";

            boletoCommand.Validate();
            Assert.AreEqual(false, boletoCommand.Valid);
        }
        public void Should_Return_Error_When_Name_Is_Invalid()
        {
            var command = new CreateBoletoSubscriptionCommand();

            command.FirstName = "";

            command.Validate();
            Assert.AreEqual(false, command.Valid);
        }
        public void NameIsInvalid()
        {
            var command = new CreateBoletoSubscriptionCommand();

            command.FirstName = "";

            command.Validate();
            Assert.AreEqual(false, command.Valid);
        }
コード例 #9
0
        public void DeveRetornarErrorQuandoNome_Invalido()
        {
            var command = new CreateBoletoSubscriptionCommand();

            command.FirstName = "";

            command.Validate();
            Assert.AreEqual(false, command.Valid);
        }
コード例 #10
0
        public void ShouldReturnSuccessWhenNameIsValid()
        {
            var command = new CreateBoletoSubscriptionCommand();

            command.FirstName = "Bruce";

            command.Validate();
            Assert.AreEqual(true, command.Valid);
        }
コード例 #11
0
        public void ShouldReturnBadRequestWhenNameIsInvalid()
        {
            var command = new CreateBoletoSubscriptionCommand();

            command.FirstName = "";

            command.Validate();
            Assert.AreEqual(false, command.Valid);
        }
コード例 #12
0
        public void ShouldReturnErrorWhenNameIsTooLong()
        {
            var command = new CreateBoletoSubscriptionCommand();

            command.FirstName = "AndreAndreAndreAndreAndreAndreAndse";

            command.Validate();
            Assert.AreEqual(false, command.Valid);
        }
コード例 #13
0
        public void DevoRetornarErroQuandoNomeEstaInvalido()
        {
            var command = new CreateBoletoSubscriptionCommand();

            command.FirstName = string.Empty;

            command.Validate();
            Assert.IsTrue(command.Invalid);
        }
        public void ShouldReturnErrorNameIsInvalid()
        {
            var command = new CreateBoletoSubscriptionCommand();

            command.FirstName = string.Empty;

            command.Validate();
            Assert.AreEqual(false, command.Valid);
        }
        public void ShouldReturnSuccessWhenHadNoActiveSubscription()
        {
            var command = new CreateBoletoSubscriptionCommand();

            command.FirstName = "";

            command.Validate();
            Assert.AreEqual(false, command.Valid);
        }
コード例 #16
0
        public void ShouldReturnErroWhenNameIsInvalid()
        {
            var command = new CreateBoletoSubscriptionCommand
            {
                FisrtName = ""
            };

            command.Validate();
            Assert.AreEqual(false, command.Valid);
        }
コード例 #17
0
        public void DeveRetornarErroQuandoNomeEhInvalido()
        {
            var command = new CreateBoletoSubscriptionCommand();

            command.FirstName = "";
            command.LastName  = "";

            command.Validate();
            Assert.IsFalse(command.Valid);
        }
        public void ShouldReturnErrorWhenNameIsInvalid()
        {
            //exemplo para validar/ testar a validacao do command, mesmo não sendo necessario esse teste
            var command = new CreateBoletoSubscriptionCommand();

            command.FirstName = "";

            command.Validate();
            Assert.AreEqual(false, command.Valid);
        }
コード例 #19
0
ファイル: CommandTests.cs プロジェクト: EversonJean/Payment
        public void CommandInvalidReturn()
        {
            var command = new CreateBoletoSubscriptionCommand()
            {
                FirstName = "", LastName = ""
            };

            command.Validate();
            Assert.AreEqual(false, command.Valid);
        }
コード例 #20
0
        public void SholdReturnErrorWhenNameIsValid()
        {
            var command = new CreateBoletoSubscriptionCommand {
                FirstName = _firstname,
                LastName  = _lastname
            };

            command.Validate();
            Assert.AreEqual(true, command.Valid);
        }
コード例 #21
0
        public ICommandResult Handle(CreateBoletoSubscriptionCommand command)
        {
            command.Validate();
            if (!command.IsValid)
            {
                AddNotifications(command);
                return(new CommandResult(false, "Não foi possível realizar sua assinatura"));
            }

            if (_repository.DocumentExists(command.Document))
            {
                AddNotification("Document", "O número do documento já está em uso");
            }

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

            var name     = new Name(command.FirstName, command.LastName);
            var document = new Document(command.Document, Enums.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);

            var student      = new Student(name, document, email);
            var subscription = new Subscription(DateTime.Now.AddMonths(1));
            var payment      = new BoletoPayment(command.PaidDate,
                                                 command.ExpireDate,
                                                 command.Total,
                                                 command.TotalPaid,
                                                 command.Payer,
                                                 new Document(command.PayerDocument, command.PayerDocumentType),
                                                 address,
                                                 email,
                                                 command.BarCode,
                                                 command.BoletoNumber);

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

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

            if (!IsValid)
            {
                return(new CommandResult(false, "Erro ao criar assinatura"));
            }

            _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"));
        }
コード例 #22
0
        public void ShouldReturnErrorWhenNameIsInvalid()
        {
            //Given
            var command = new CreateBoletoSubscriptionCommand();

            command.FirstName = "";

            //When
            command.Validate();

            //Then
            Assert.False(command.Valid);
        }
コード例 #23
0
        public void ShouldReturnErrorWhenDocumentExists()
        {
            //Arrange
            var command = new CreateBoletoSubscriptionCommand();

            command.FirstName = "";

            //Act
            command.Validate();

            //Assert
            Assert.IsTrue(command.Invalid);
        }
コード例 #24
0
        public ICommandResult Handle(CreateBoletoSubscriptionCommand command)
        {
            command.Validate();

            if (!command.IsValid)
            {
                AddNotifications(command);
                return(new CommandResult(false, "Não foi possível realizar o seu cadastro"));
            }

            if (_repository.DocumentExists(command.Document))
            {
                AddNotification("Document", "Document already exists.");
            }


            if (_repository.EmailExists(command.Email))
            {
                AddNotification("Email", "E-mail already exists");
            }

            var name     = new Name(command.FirstName, command.LastName);
            var document = new Document(command.PayerDocument, command.PayerDocumentType);
            var email    = new Email(command.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.PaidDate, command.ExpireDate, command.Total, command.TotalPaid, command.Payer, document, address, email);

            subscription.AddPayment(payment);

            student.AddSubscription(subscription);

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

            if (!IsValid)
            {
                return(new CommandResult(false, "It is not possible to complete the subscription"));
            }

            _repository.CreateSubscription(student);

            _emailService.Send(student.Name.ToString(), student.Email.Address, "Welcome to the network.", "Your registered had been completed successfully.");

            return(new CommandResult(true, "Subscription registered successfully."));
        }
コード例 #25
0
        public ICommandResult Handle(CreateBoletoSubscriptionCommand command)
        {
            // Fail Fast Validations
            command.Validate();
            if (command.IsValid)
            {
                AddNotifications(command);
                return(new CommandResult(false, "Não foi possível realizar sua assinatura"));
            }

            // Verificar se Documento já está cadastrado
            if (_repository.DocumentExists(command.Document))
            {
                AddNotification("Document", "Este CPF já está em uso");
            }

            // Verificar se E-mail 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 notificações
            if (IsValid)//Invalid
            {
                return(new CommandResult(false, "Não foi possível realizar 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 balta.io", "Sua assinatura foi criada");

            // Retornar informações
            return(new CommandResult(true, "Assinatura realizada com sucesso"));
        }