Пример #1
0
        public void PaymentWithInvalidUserIdTest()
        {
            var           createDate = DateTime.UtcNow;
            const decimal payment    = 56.76m;
            var           paycode    = LibLogic.Helpers.SiteInfo.MonthlyPaymentId;

            var pay = new LibLogic.Payments.Payment(-1);

            pay.SaveUserPayment(payment, createDate, paycode);
        }
Пример #2
0
        public void IsAdminExpiredOldPaymentsTest()
        {
            var createDate = DateTime.UtcNow.AddMonths(-3);
            var payment    = 56.76m;
            var paycode    = LibLogic.Helpers.SiteInfo.MonthlyPaymentId;

            var pay = new LibLogic.Payments.Payment(this.userid);

            pay.SaveUserPayment(payment, createDate, paycode);


            Assert.That(pay.IsExpired(), Is.False);
        }
Пример #3
0
        public void IsExpiredNewPaymentsTest()
        {
            // Beta account should never be expired
            var createDate = DateTime.UtcNow;
            var payment    = 56.76m;
            var paycode    = LibLogic.Helpers.SiteInfo.MonthlyPaymentId;

            var pay = new LibLogic.Payments.Payment(this.userid);

            pay.SaveUserPayment(payment, createDate, paycode);


            Assert.That(pay.IsExpired(), Is.False);
        }
Пример #4
0
        public void HistoryTest()
        {
            var createDate = DateTime.UtcNow;
            var payment    = 56.76m;
            var paycode    = LibLogic.Helpers.SiteInfo.MonthlyPaymentId;

            var pay = new LibLogic.Payments.Payment(this.userid);


            for (int i = 0; i < 1000; i++)
            {
                pay.SaveUserPayment(payment, createDate.AddMonths(i), paycode);
                Assert.That(pay.History().Count(), Is.EqualTo(i + 1));
            }
        }
Пример #5
0
        public void GenerateCertHappyPath()
        {
            var pay = new LibLogic.Payments.Payment(this.userid);

            pay.SaveUserPayment(5, DateTime.UtcNow, LibLogic.Helpers.SiteInfo.MonthlyPaymentId);

            using (var sshClient = new LibLogic.Ssh.FakeSsh(LibLogic.Ssh.FakeSsh.TestingScenerios.OpenVpnHappyPath))
                using (var sshRevokeClient = new LibLogic.Ssh.FakeSsh(LibLogic.Ssh.FakeSsh.TestingScenerios.OpenVpnHappyPath))
                    using (var sftpClient = new LibLogic.Ssh.FakeSftp())
                    {
                        var vpn = new LibLogic.OpenVpn.CertsOpenVpnGenerateCommand(this.userid, this.vpnseverid,
                                                                                   sshClient, sshRevokeClient, sftpClient);

                        vpn.Execute();
                    }
        }
Пример #6
0
        public void ExpireYearlyPaymentTest()
        {
            var createDate = DateTime.UtcNow;
            var payment    = 56.76m;
            var paycode    = LibLogic.Helpers.SiteInfo.YearlyPaymentId;

            var pay = new LibLogic.Payments.Payment(this.userid);

            pay.SaveUserPayment(payment, createDate, paycode);
            DateTime expireDate = createDate.AddYears(1).AddDays(1);

            Assert.That(pay.ExpireDate().Year, Is.EqualTo(expireDate.Year));
            Assert.That(pay.ExpireDate().Month, Is.EqualTo(expireDate.Month));
            Assert.That(pay.ExpireDate().Day, Is.EqualTo(expireDate.Day));
            Assert.That(pay.ExpireDate().Hour, Is.EqualTo(expireDate.Hour));
            Assert.That(pay.ExpireDate().Minute, Is.EqualTo(expireDate.Minute));
            Assert.That(pay.ExpireDate().Second, Is.EqualTo(expireDate.Second));
        }
Пример #7
0
        public void ValidPaymentTest()
        {
            var           createDate = DateTime.UtcNow;
            const decimal payment    = 56.76m;
            var           paycode    = LibLogic.Helpers.SiteInfo.MonthlyPaymentId;

            var pay = new LibLogic.Payments.Payment(this.userid);

            pay.SaveUserPayment(payment, createDate, paycode);

            using (var cn = LibLogic.Setup.DbFactory)
            {
                cn.Open();
                var data = cn.Query <LibPoco.UserPayments>("SELECT * FROM UserPayments WHERE UserId = @UserId AND AmountPaid=@amount AND " +
                                                           "CreateTime=@CreateTime AND LookupPaymentTypeId=@payid",
                                                           new { UserId = userid, amount = payment, CreateTime = createDate, payid = paycode });


                Assert.That(data.Count(), Is.EqualTo(1));
            }
        }