예제 #1
0
 public void GetRandomNumberTest()
 {
     foreach (Enums.LotteryType lt in (Enums.LotteryType[])Enum.GetValues(typeof(Enums.LotteryType)))
     {
         var lr  = new LotteryRule(lt);
         var rnd = LotteryHandler.GetRandomNumber(lr);
         Assert.True(rnd > lr.MinNumber && rnd < lr.MaxNumber);
     }
 }
 public ActionResult Create(LotteryRule lotteryrule)
 {
     if (ModelState.IsValid)
     {
         _lotteryruleRepository.InsertOrUpdate(lotteryrule);
         _lotteryruleRepository.Save();
         return RedirectToAction("Index");
     }
     ViewBag.PossibleLotteryPrices = _lotterypriceRepository.All;
     return View();
 }
예제 #3
0
파일: Lottery.cs 프로젝트: route56/route56
        private static void TransformInput(string[] rules, List <LotteryRule> ruleList)
        {
            foreach (string item in rules)
            {
                string[] str = item.Split(':');
                Debug.Assert(str.Length == 2);
                string[] data = str[1].Trim().Split(' ');
                Debug.Assert(data.Length == 4);

                LotteryRule rule = new LotteryRule()
                {
                    Name    = str[0],
                    Choices = Double.Parse(data[0]),
                    Blanks  = Double.Parse(data[1]),
                    Sorted  = data[2].CompareTo("T") == 0,
                    Unique  = data[3].CompareTo("T") == 0
                };

                ruleList.Add(rule);
            }
        }