protected void btnArvo_Click(object sender, EventArgs e) { BLLotto Lotto = new BLLotto(ddLotot.SelectedValue); int rivimaara = 1; try { rivimaara = int.Parse(txtRivimaara.Text); lblError.Text = ""; } catch { lblError.Text = "Vain numerot sallittu"; return; } // Rajoitetaan 100 riviin ettei mennä älyttömyyksiin. rivimaara = Math.Min(rivimaara, 100); List <String> rivit = new List <string>(); for (int i = 0; i < rivimaara; i++) { rivit.Add(Lotto.Draw()); } lbRivit.DataSource = rivit; lbRivit.DataBind(); }
protected void btnDraw_Click(object sender, EventArgs e) { try { lblMessages.Text = ""; int numbersToDraw = (drpLottoType.Text == "Lotto") ? 7 : 6; int largestValue = (drpLottoType.Text == "Lotto") ? 39 : 48; BLLotto lotto = new BLLotto(); if (int.Parse(txtRows.Text) > 0) { for (int i = 0; i < int.Parse(txtRows.Text); i++) { lblMessages.Text += string.Join(", ", lotto.DrawLotto(numbersToDraw, largestValue)) + "<br />"; } } else { lblMessages.Text = "Rows to draw must be greater than 0."; } } catch (Exception ex) { lblMessages.Text = ex.Message; } }
public void DrawLottoArrayTest() { lotto = new BLLotto(); var array = lotto.DrawLottoArray(7, 39); Assert.IsInstanceOfType(array, typeof(int[]), "Output should be an int array."); Assert.AreEqual(array.Length, 7, "Arrays lenght's do not match."); }
public void ReadLottoNumbersTest() { lotto = new BLLotto(); string path = "Lottorivit" + lotto.GetWeekNumber() + ".txt"; int[] test = lotto.ReadLottoNumbers("1 2 3 4 5 6 8"); Assert.IsTrue(File.Exists(path), "File does not exist."); Assert.AreEqual(test[0], 6, "Results should be equal"); }
public void WriteLottoNumbersTest() { lotto = new BLLotto(); string path = "Lottorivit" + lotto.GetWeekNumber() + ".txt"; string input = "Row 1: 1, 2, 3, 4, 5, 6, 7"; string correctRow = "1 2 3 4 5 6 7"; lotto.WriteLottoNumbers(input); Assert.IsTrue(File.Exists(path), "File does not exist."); Assert.IsTrue((File.ReadAllText(path).Contains(correctRow)), "File does not include the written row."); }
protected void btnProfit_Click(object sender, EventArgs e) { try { lblResult.Text = String.Empty; BLLotto lotto = new BLLotto(); for (int i = 0; i < int.Parse(txtRows.Text); i++) { lblResult.Text += lotto.draw(ddlLotto.Text) + "<br/>"; } } catch (Exception ex) { lblResult.Text = ex.Message; } }
protected void btnGetNumbers_Click(object sender, EventArgs e) { try { BLLotto lotto = new BLLotto(); List <int> list; list = lotto.Lottery(Int32.Parse(rblMode.SelectedValue)); foreach (var item in list) { tbResults.Text += " " + item.ToString(); } tbResults.Text += "\n"; } catch (Exception ex) { tbResults.Text = ex.Message; } }
protected void btnArvo_Click(object sender, EventArgs e) { int lkmRivit = 0; try { lkmRivit = Int32.Parse(txtLkmRivit.Text); } catch (Exception) { // do nothing... } if (lkmRivit > 0) { divRivit.InnerHtml = ""; if (ddTyyppi.SelectedValue == "suomi") { for (int i = 0; i < lkmRivit; i++) { var numerot = BLLotto.arvoSuomi(); var rivit = string.Join(", ", numerot); divRivit.InnerHtml += rivit; divRivit.InnerHtml += "<br />"; } } else if (ddTyyppi.SelectedValue == "viking") { for (int i = 0; i < lkmRivit; i++) { var numerot = BLLotto.arvoViking(); var rivit = string.Join(", ", numerot); divRivit.InnerHtml += rivit; divRivit.InnerHtml += "<br />"; } } } else { divRivit.InnerHtml = "Rivien lkm -kenttään kelpaa vain positiiviset numerot."; } }
public void DrawGameTest() { lotto = new BLLotto(); int inputLotto = 7; int inputVikingLotto = 6; int inputEurojackpot = 7; string outputLotto = lotto.DrawGame("Lotto", 1); string outputVikingLotto = lotto.DrawGame("Viking Lotto", 1); string outputEurojackpot = lotto.DrawGame("Eurojackpot", 1); var resultLotto = outputLotto.SkipWhile(c => c != ':').Count(x => Char.IsNumber(x)); var resultVikingLotto = outputVikingLotto.SkipWhile(c => c != ':').Count(x => Char.IsNumber(x)); var resultEurojackpot = outputEurojackpot.SkipWhile(c => c != ':').Count(x => Char.IsNumber(x)); Assert.AreEqual(inputLotto, resultLotto, "Input and output must be same."); Assert.AreEqual(inputVikingLotto, resultVikingLotto, "Input and output must be same."); Assert.AreEqual(inputEurojackpot, resultEurojackpot, "Input and output must be same."); }
protected void btnGetLottoNumbers_Click(object sender, EventArgs e) { try { lblDrawnLottoNumbers.Text = String.Empty; BLLotto lotto = new BLLotto(); if (int.Parse(txtRowAmount.Text) > 0) { for (int i = 0; i < int.Parse(txtRowAmount.Text); i++) { lblDrawnLottoNumbers.Text += lotto.drawGame(ddLottoTypes.Text) + "<br/>"; } lblMessage.Text = "Arvonta onnistui!"; } else { lblMessage.Text = "Liian vähän rivejä valittu."; } } catch (Exception ex) { lblMessage.Text = ex.Message; } }