public void RegisterNewClient_CorrectData_Success(string _email, string _firstName, string _lastName, string _password, bool _receiveNewsletterEmail, string _newsletterEmail)
        {
            DatabaseQueryProcessor.Erase();
            Shared.FillTheDatabase();

            var registerNewClient = new RegisterNewClientCommand
            {
                email     = _email,
                firstName = _firstName,
                lastName  = _lastName,
                password  = _password,
                receiveNewsletterEmail = _receiveNewsletterEmail,
                newsletterEmail        = _newsletterEmail
            };

            var handler = new RegisterNewClientCommandHandler();
            var result  = (SuccessInfoDto)handler.Handle(registerNewClient);

            var newClient = DatabaseQueryProcessor.GetClient(_email, PasswordEncryptor.encryptSha256(_password));

            DatabaseQueryProcessor.Erase();

            Assert.IsNotNull(newClient);
            Assert.IsTrue(result.isSuccess);
            Assert.AreEqual(_firstName, newClient.firstName);
            Assert.AreEqual(_lastName, newClient.lastName);
            Assert.AreEqual(_newsletterEmail, newClient.newsletterEmail);
        }
Exemplo n.º 2
0
        public void UpdatePersonalData_ChangePassword_Success(string _email, string _firstName, string _lastName, bool _changePassword, string _newPassword, bool _receiveNewsletterEmail, string _newsletterEmail)
        {
            DatabaseQueryProcessor.Erase();
            Shared.FillTheDatabase();

            int clientId         = 0;
            var testSessionToken = SessionRepository.StartNewSession(clientId);

            var updatePersonalDataCommand = new UpdatePersonalDataCommand
            {
                sessionToken           = testSessionToken,
                email                  = _email,
                firstName              = _firstName,
                lastName               = _lastName,
                changePassword         = _changePassword,
                newPassword            = _newPassword,
                receiveNewsletterEmail = _receiveNewsletterEmail,
                newsletterEmail        = _newsletterEmail
            };

            var handler = new UpdatePersonalDataCommandHandler();
            var result  = (PersonalDataDto)handler.Handle(updatePersonalDataCommand);

            var foundClient = DatabaseQueryProcessor.GetClient(_email, PasswordEncryptor.encryptSha256(_newPassword));

            DatabaseQueryProcessor.Erase();
            SessionRepository.RemoveSession(testSessionToken);

            Assert.IsNotNull(result);
            Assert.AreEqual(_email, result.email);
            Assert.AreEqual(_firstName, result.firstName);
            Assert.AreEqual(_lastName, result.lastName);
            Assert.AreEqual(_newsletterEmail, result.newsletterEmail);
            Assert.IsNotNull(foundClient);
        }
Exemplo n.º 3
0
        public override void Build(int clientId)
        {
            var client = DatabaseQueryProcessor.GetClient(clientId);

            header  = "Dear " + client.firstName + ", \n";
            content = "We are glad that you have joined Coffeeland community! If you have any questions do not hesitate to contact us.\n";
            footer  = "Best regards,\n"
                      + "Jane Doe \n"
                      + "Customer Service Coordinator";
            subject = "Welcome in CoffeeLand " + client.firstName + "!";

            body.Append(header);
            body.AppendLine();
            body.Append(content);
            body.AppendLine();
            body.Append(footer);

            SetSubject(subject);
            SetBody();
            AddReceiver(client.firstName, client.email);
        }
Exemplo n.º 4
0
        public IResult Handle(SignInCommand command)
        {
            var foundClient = DatabaseQueryProcessor.GetClient(command.email, PasswordEncryptor.encryptSha256(command.password));

            if (foundClient == null)
            {
                return(new SignInInfoDto()
                {
                    isSuccess = false,
                    sessionToken = null
                });
            }

            var sessionToken = SessionRepository.StartNewSession(foundClient.clientId);

            return(new SignInInfoDto()
            {
                isSuccess = true,
                sessionToken = sessionToken
            });
        }
Exemplo n.º 5
0
        public override void Build(int clientId)
        {
            var client = DatabaseQueryProcessor.GetClient(clientId);

            header  = "Dear " + client.firstName + ", \n";
            content = "Unfortunatelly your payment was not successfull. Please try again or contact support.";

            footer = "Best regards,\n"
                     + "John Doe \n"
                     + "Head of Sales";
            subject = "CoffeeLand - your payment was not successfull";

            body.Append(header);
            body.AppendLine();
            body.Append(content);
            body.AppendLine();
            body.Append(footer);

            SetSubject(subject);
            SetBody();
            AddReceiver(client.firstName, client.email);
        }
        public override void Build(int clientId)
        {
            var client = DatabaseQueryProcessor.GetClient(clientId);

            header  = "Dear " + client.firstName + ", \n";
            content = "we have just received your payment, you can check details of your order status on Orders page of your MyAccount."
                      + "The standard shipping takes 3-7 buissness days. Due to the nature of pre-order sales and often in-demand products, shipping delays may occur."
                      + "We will do our best to contact you regarding your shipment as soon as possible with an updated timeline.";
            footer = "Best regards,\n"
                     + "John Doe \n"
                     + "Head of Sales";
            subject = "CoffeeLand - we have received your payment";

            body.Append(header);
            body.AppendLine();
            body.Append(content);
            body.AppendLine();
            body.Append(footer);

            SetSubject(subject);
            SetBody();
            AddReceiver(client.firstName, client.email);
        }
Exemplo n.º 7
0
        public override void Build(int clientId)
        {
            var client = DatabaseQueryProcessor.GetClient(clientId);

            header  = "Dear " + client.firstName + ", \n";
            content = "Thank you for your trust! \n We are still waiting for your payment but do not worry"
                      + " - we'll inform you about everything as soon as possible. You can check the details and status of the transaction at your Orders page.\n ";

            footer = "Best regards!\n"
                     + "John Doe \n"
                     + "Head of Sales";
            subject = "CoffeeLand - order placement!";

            body.Append(header);
            body.AppendLine();
            body.Append(content);
            body.AppendLine();
            body.Append(footer);

            SetSubject(subject);
            SetBody();
            AddReceiver(client.firstName, client.email);
        }