public void CreateNewUserPaymentThenFindThenDelete()
        {
            var command = new SavePaymentInfoCommand();

            command.UserId                        = Guid.Parse("c9276b76-c56a-43ba-96b5-83b48a5fcce3");
            command.Id                            = Guid.NewGuid();
            command.PaymentInfo                   = new UserPaymentInfo();
            command.PaymentInfo.Token             = "thisisnotalegittoken";
            command.PaymentInfo.UserPaymentInfoId = Guid.NewGuid();

            var userRepo    = new MockUserRepository();
            var paymentRepo = new MockUserPaymentRepository();
            var encryptor   = new RijndaelManagedEncryptor();

            var handler = new PaymentCommandHandler(userRepo, paymentRepo, encryptor);

            handler.Handle(command);

            var paymentInfo = paymentRepo.Get(command.PaymentInfo);

            try
            {
                Assert.IsNotNull(paymentInfo);
                Assert.AreNotEqual(command.PaymentInfo.Token, "thisisnotalegittoken");
            }
            finally
            {
                paymentRepo.Remove(paymentInfo);
            }
        }
Example #2
0
        public HttpResponseMessage Post(SavePaymentInfoCommand command)
        {
            if (command.PaymentInfo == null)
            {
                throw new ArgumentNullException(string.Format(ErrorMessages.MissingRequiredArgumentValue, "command.paymentInfo"));
            }

            command.UserId = Request.GetUserId();
            if (command.PaymentInfo.UserPaymentInfoId == Guid.Empty)
            {
                command.PaymentInfo.UserPaymentInfoId = Guid.NewGuid();
            }

            m_SaveHandler.Handle(command);

            var response = Request.CreateResponse(HttpStatusCode.Created, command.PaymentInfo.UserPaymentInfoId);

            return(response);
        }