GenerateCoupon() публичный Метод

Generates a code for a consumer to use
public GenerateCoupon ( ) : string
Результат string
Пример #1
0
 public void CouponCodeTest()
 {
     for (int index = 0; index < 1000; index++)
     {
         couponUtility = new UserDiscountUtility();
         string CouponCode = couponUtility.GenerateCoupon();
         Assert.IsTrue(CouponCode.Length == 5);
         foreach (char letter in CouponCode)
         {
             Assert.IsTrue(Convert.ToInt32(letter) > 64);
             Assert.IsTrue(Convert.ToInt32(letter) < 91);
         }
     }
 }
Пример #2
0
 /// <summary>
 /// Set fields on all coupon objects
 /// </summary>
 /// <returns></returns>
 public static UserDiscount CreateCoupon()
 {
     UserDiscount coupon = new UserDiscount();
     UserDiscountUtility udc = new UserDiscountUtility();
     coupon.DiscountRate = 20;
     coupon.EndDate = DateTime.Now.AddDays(1);
     coupon.StartDate = DateTime.Now;
     coupon.UserDiscountId = 0;
     coupon.UserId = 10;
     coupon.Reedemed = false;
     coupon.DiscountCode = udc.GenerateCoupon();
     return coupon;
 }