public void CreateCouponTest()
        {
            var coupon = new Coupon()
            {
                Code        = "_test_coupon_" + DateTime.Now.Ticks,
                Name        = "Coupon Teste Unitario",
                Description = "Descrição do coupon de teste",
                Discount    = new CouponDiscount()
                {
                    Value = 1000,
                    Type  = DiscountType.AMOUNT
                },
                Status   = Coupon.CouponStatus.ACTIVE,
                Duration = new CouponDuration()
                {
                    Type        = CouponDuration.DurationType.REPEATING,
                    Occurrences = 2
                },
                MaxRedemptions = 100,
                ExpirationDate = MoipDate.FromDate(DateTime.Now.Date.AddDays(10))
            };

            var retorno = assinaturasClient.CreateCoupon(coupon);

            Assert.AreEqual(coupon.Code, retorno.Code);
        }
Exemple #2
0
        public void FromDateTest()
        {
            var dateTest = new DateTime(2015, 01, 20, 10, 20, 30);
            var moipDate = MoipDate.FromDate(dateTest);

            Assert.AreEqual(dateTest.Year, moipDate.Year);
            Assert.AreEqual(dateTest.Month, moipDate.Month);
            Assert.AreEqual(dateTest.Day, moipDate.Day);
            Assert.AreEqual(dateTest.Hour, moipDate.Hour);
            Assert.AreEqual(dateTest.Minute, moipDate.Minute);
            Assert.AreEqual(dateTest.Second, moipDate.Second);
        }
Exemple #3
0
        public void ToDateTest()
        {
            var dateTest = new DateTime(2015, 01, 20, 10, 20, 30);
            var moipDate = new MoipDate()
            {
                Year   = dateTest.Year,
                Month  = dateTest.Month,
                Day    = dateTest.Day,
                Hour   = dateTest.Hour,
                Minute = dateTest.Minute,
                Second = dateTest.Second
            };

            Assert.AreEqual(moipDate.ToDate(), dateTest);
        }
        public void UpdateSubscriptionTest()
        {
            var firstActive = GetSubscriptions().Subscriptions.FirstOrDefault(x => x.Status != Subscription.SubscriptionStatus.CANCELED);

            if (firstActive == null)
            {
                throw new AssertInconclusiveException("Nenhum plano diferente de cancelado foi encontrado na conta moip");
            }

            var random  = new Random().Next(2, 30);
            var newDate = DateTime.Now.AddDays(random).Date;

            firstActive.NextInvoiceDate = MoipDate.FromDate(newDate);
            assinaturasClient.UpdateSubscription(firstActive.Code, firstActive);

            var subscription = assinaturasClient.GetSubscription(firstActive.Code);

            Assert.AreEqual(newDate, subscription.NextInvoiceDate.ToDate());
        }