static void Main(string[] args) { Bowling bowl = new Bowling(); Console.WriteLine("Let's start Bowling!!"); try { foreach (var frame in bowl.Frames) { for (int i = 0; i < frame.ThrowList.Count; i++) { Console.WriteLine("Enter number of pins knocked down this turn and press Enter"); var inputThrow = Console.ReadLine(); if (int.TryParse(inputThrow, out int userInput)) { if (ValidateInput(userInput)) { bowl.Roll(userInput, frame); } } } } } catch (Exception ex) { throw ex; } Score(bowl); }
public void SumTest() { lancio[0].FirstSet(3); lancio[0].SecondSet(4); lancio[1].FirstSet(4); lancio[1].SecondSet(6); lancio[2].FirstSet(4); lancio[2].SecondSet(3); lancio[3].FirstSet(5); lancio[3].SecondSet(4); lancio[4].FirstSet(1); lancio[4].SecondSet(0); lancio[5].FirstSet(0); lancio[5].SecondSet(7); lancio[6].FirstSet(10); lancio[7].FirstSet(4); lancio[7].SecondSet(5); lancio[8].FirstSet(6); lancio[8].SecondSet(3); lancio[9].FirstSet(3); lancio[9].SecondSet(3); IBowling bowling = new Bowling(lancio); Assert.That(() => bowling.Score(), Is.EqualTo(88)); }
public void Single_semi_strike() { Bowling bowling = new Bowling(); int score = bowling.CalculeScore("-12/----------------"); Assert.AreEqual(11, score); }
public void Single_scores_should_be_single_added() { Bowling bowling = new Bowling(); int score = bowling.CalculeScore("-1-2----------------"); Assert.AreEqual(3, score); }
public void Semi_strike_with_bowls_after() { Bowling bowling = new Bowling(); int score = bowling.CalculeScore("--2/1---------------"); Assert.AreEqual(12, score); }
public void All_strikes_12_rolls() { Bowling bowling = new Bowling(); int score = bowling.CalculeScore("XXXXXXXXXXXX"); Assert.AreEqual(300, score); }
public void All_single_and_miss_20_rolls() { Bowling bowling = new Bowling(); int score = bowling.CalculeScore("9-9-9-9-9-9-9-9-9-9-"); Assert.AreEqual(90, score); }
public void All_fails_should_be_0() { Bowling bowling = new Bowling(); int score = bowling.CalculeScore("--------------------"); Assert.AreEqual(0, score); }
public void All_semi_strikes_21_rolls() { Bowling bowling = new Bowling(); int score = bowling.CalculeScore("5/5/5/5/5/5/5/5/5/5/5"); Assert.AreEqual(150, score); }
public void return_game_score(string game, int expectedScore) { var bowling = new Bowling(); var score = bowling.CalculateScore(game); Assert.That(score, Is.EqualTo(expectedScore)); }
public void ArgumentException() { IBowling bowling = new Bowling(lancio); lancio[0].FirstSet(3); lancio[0].SecondSet(-8); Assert.That(() => bowling.Score(), Throws.TypeOf <ArgumentException>()); }
public void ThrowNormal_NormalScore() { var b = new Bowling(); b.Throw(5); b.Throw(6); Assert.That(b.GetScore(), Is.EqualTo(11)); }
public void exampleTests() { Bowling bowling = new Bowling(); int[] testArray = new int[] { 1, 2, 3 }; Assert.AreEqual("I I I I\n I I I \n \n ", bowling.BowlingPins(testArray)); testArray = new int[] { 3, 5, 9 }; Assert.AreEqual("I I I\n I I \n I \n I ", bowling.BowlingPins(testArray)); }
public void When_Spare_at_the_end_then_it_scores_26() { Bowling bowling = new Bowling(); // act. int score = bowling.GetScore(new int[] { 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 2, 1, 0, 1, 0, 1, 0, 1, 9, 5 }); // assert. Check.That(score).IsEqualTo(26); }
public void When_Srike_at_the_end_then_it_scores_30() { Bowling bowling = new Bowling(); // act. int score = bowling.GetScore(new int[] { 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 2, 1, 0, 1, 0, 1, 0, 10, 5, 4 }); // assert. Check.That(score).IsEqualTo(30); }
public void When_Spare_and_Other_Rolls_Equal_To_1_then_it_scores_29() { Bowling bowling = new Bowling(); // act. int score = bowling.GetScore(new int[] { 5, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }); // assert. Check.That(score).IsEqualTo(29); }
static void Main(string[] args) { ILancio[] lancio = new ILancio[11]; for (int i = 0; i < lancio.Length; i++) { lancio[i] = new Lancio(); } lancio[0].FirstSet(1); lancio[0].SecondSet(2); lancio[1].FirstSet(10); lancio[1].SecondSet(0); lancio[2].FirstSet(0); lancio[2].SecondSet(10); lancio[3].FirstSet(4); lancio[3].SecondSet(2); lancio[4].FirstSet(0); lancio[4].SecondSet(10); lancio[5].FirstSet(6); lancio[5].SecondSet(2); lancio[6].FirstSet(0); lancio[6].SecondSet(10); lancio[7].FirstSet(6); lancio[7].SecondSet(4); lancio[8].FirstSet(8); lancio[8].SecondSet(2); lancio[9].FirstSet(2); lancio[9].SecondSet(8); lancio[10].FirstSet(8); foreach (var b in lancio) { Console.Write(b.FirstGet() + "/" + b.SecondGet() + " "); } Console.WriteLine(); IBowling bowling = new Bowling(lancio); Console.WriteLine(bowling.Score()); Console.ReadLine(); }
public void ThrowSpare_SpecialScore() { var b = new Bowling(); b.Throw(1); b.Throw(11); // = spare b.Throw(5); // score counts for double? b.Throw(3); // No double score Assert.That(b.GetScore(), Is.EqualTo(1 + 11 + (5 * 2) + 3)); }
public void When_strike_and_all_other_roll_equal_1_then_it_scores_30() { // arrange. Bowling bowling = new Bowling(); // act. int score = bowling.GetScore(new int[] { 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }); // assert. Check.That(score).IsEqualTo(30); }
public void When_all_roll_equal_1_then_it_scores_20() { //arrange Bowling bowling = new Bowling(); //act int score = bowling.GetScore(new int[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }); //assert Check.That(score).IsEqualTo(20); }
private void SubmitButton_OnClick(object sender, RoutedEventArgs e) { var input = textBox.Text; var result = 0; var score = Bowling.TryGetBowlingScore(input, ref result); textBlock.Text = score ? "Score: " + result : "Wrong score!"; }
public void AddToDirectory_ShouldGetCorrectBoolean() { //Arrange Bowling content = new Bowling(); Bowling repository = new Bowling(); //Act bool addResult = repository.AddContentToDirectory(content); //Assert Assert.IsTrue(addResult); }
public void StrikeTest() { lancio[0].FirstSet(3); lancio[0].SecondSet(4); lancio[1].FirstSet(10); lancio[2].FirstSet(4); lancio[2].SecondSet(5); IBowling bowling = new Bowling(lancio); Assert.That(() => bowling.Score(), Is.EqualTo(35)); }
private void button_Click(object sender, RoutedEventArgs e) { var input = textBox.Text; int score = 0; if (Bowling.TryGetBowlingScore(input, ref score)) { textBlock.Text = score.ToString(); } else { textBlock.Text = "ERROR"; } }
private void BowlingOuting() { Bowling bowling = new Bowling(); bowling.TypeOfEvent = "Bowling"; Console.WriteLine("How many people attended this event?"); bowling.NumberOfPeople = int.Parse(Console.ReadLine()); Console.WriteLine("What was the total event cost?"); bowling.EventCost = decimal.Parse(Console.ReadLine()); bowling.CostPerPerson = bowling.EventCost / bowling.NumberOfPeople; Console.WriteLine($"This event cost ${bowling.CostPerPerson}"); Console.WriteLine("When was this event?"); bowling.DateOfEvent = DateTime.Parse(Console.ReadLine()); _outing.AddToOutingList(bowling); }
public void GetByTitle_ShouldReturnCorrectContent() { //Arrange Bowling repo = new Bowling(); Bowling newContent = new Bowling(); repo.AddContentToDirectory(newContent); string title = ""; //Act Bowling searchResult = repo.GetContentByTitle(title); //Assert Assert.AreEqual(searchResult.NameOfEvent, title); }
public void GetDirectory_ShouldReturnCorrectCollection() { //Arrange Bowling content = new Bowling(); Bowling repo = new Bowling(); repo.AddContentToDirectory(content); //Act List <Bowling> contents = repo.GetContents(); bool directoryHasContent = contents.Contains(content); //Assert Assert.IsTrue(directoryHasContent); }
public void UpdateExistingContent_ShouldReturnTrue() { //Arrange Bowling repo = new Bowling(); Bowling oldContent = new Bowling(); repo.AddContentToDirectory(oldContent); Bowling newContent = new Bowling(); //Act bool updateResult = repo.UpdateExistingContent(oldContent.NameOfEvent, newContent); //Assert Assert.IsTrue(updateResult); }
public void DeleteExistingContent_ShouldReturnTrue() { //Arrange Bowling repo = new Bowling(); Bowling content = new Bowling(); repo.AddContentToDirectory(content); //Act Bowling oldContent = repo.GetContentByTitle("Bowling"); bool removeResult = repo.DeleteExistingContent(oldContent); //Assert Assert.IsNull(removeResult); }
public void SetupGameAt(BowlingFrame frame) { _game = new Bowling( new Game { Status = "In Progress" }, new PlayerScore { Frame = frame.Frame, Score = frame.StartingScore, Ball = frame.Ball, Spare = false, }, 0 ); }
public void ShouldHandleSpareCorrectly() { var rounds = new List <(string, string)>() { ("3", "3"), ("4", "4"), ("4", Bowling.SPARE), ("4", "4"), ("4", "4"), ("4", "4"), ("4", "4"), ("4", "4"), ("4", "4"), ("4", "3"), }; var bowling = new Bowling(); var points = bowling.CalculatePoints(rounds); points.Should().Be(83); }
public void ShouldHandleStrikeCorrectly() { var rounds = new List <(string, string)>() { ("3", "3"), ("4", "4"), (Bowling.STRIKE, string.Empty), ("4", "4"), ("4", "4"), ("4", "4"), ("4", "4"), ("4", "4"), ("4", "4"), ("4", "3"), }; var bowling = new Bowling(); var points = bowling.CalculatePoints(rounds); points.Should().Be(87); }
public void ShouldCorrectlySumUpRoundsWithPointInAllShots() { var rounds = new List <(string, string)>() { ("3", "3"), ("4", "4"), ("4", "4"), ("4", "4"), ("4", "4"), ("4", "4"), ("4", "4"), ("4", "4"), ("4", "4"), ("4", "3"), }; var bowling = new Bowling(); var points = bowling.CalculatePoints(rounds); points.Should().Be(77); }
public void ShouldCalculateSpareInTenthRound() { var rounds = new List <(string, string)>() { ("3", "3"), ("4", "4"), ("3", Bowling.SPARE), ("4", "4"), ("4", "4"), ("4", "4"), ("4", "4"), ("4", "4"), ("4", "4"), ("4", Bowling.SPARE), ("4", string.Empty) }; var bowling = new Bowling(); var points = bowling.CalculatePoints(rounds); points.Should().Be(90); }
public void AllSparesWithAnExtraFive() { var rounds = new List <(string, string)>() { ("5", Bowling.SPARE), ("5", Bowling.SPARE), ("5", Bowling.SPARE), ("5", Bowling.SPARE), ("5", Bowling.SPARE), ("5", Bowling.SPARE), ("5", Bowling.SPARE), ("5", Bowling.SPARE), ("5", Bowling.SPARE), ("5", Bowling.SPARE), ("5", string.Empty) }; var bowling = new Bowling(); var points = bowling.CalculatePoints(rounds); points.Should().Be(150); }
public void ShouldHandleAllStrikes() { var rounds = new List <(string, string)>() { (Bowling.STRIKE, string.Empty), (Bowling.STRIKE, string.Empty), (Bowling.STRIKE, string.Empty), (Bowling.STRIKE, string.Empty), (Bowling.STRIKE, string.Empty), (Bowling.STRIKE, string.Empty), (Bowling.STRIKE, string.Empty), (Bowling.STRIKE, string.Empty), (Bowling.STRIKE, string.Empty), (Bowling.STRIKE, string.Empty), ("10", "10") }; var bowling = new Bowling(); var points = bowling.CalculatePoints(rounds); points.Should().Be(300); }
static void Main(string[] args) { var bowling = new Bowling(); while (!bowling.PartieFinie) { try { Console.WriteLine("Frame: {0}", bowling.Frame + 1); Console.WriteLine("Score: {0}", bowling.Score); Console.WriteLine("Lancer: {0}", bowling.LancerDansLaFrame); Console.WriteLine("Quilles:{0}", bowling.Quilles); Console.Write("Nombre de quilles tombees:"); bowling.Lance(int.Parse(Console.ReadLine())); Console.WriteLine(); } catch (FormatException) { Console.WriteLine("FormatIncorrect"); } } Console.WriteLine("Score Final:{0}", bowling.Score); }
public void ApresUnSpareLaPartieEstFinieAuFrame10AvecUnLancerSupplementaire() { var bowling = new Bowling(); foreach (var resultat in Enumerable.Repeat(1, 18)) bowling.Lance(resultat); bowling.Lance(5); bowling.Lance(5); Assert.IsFalse(bowling.PartieFinie); bowling.Lance(1); Assert.IsTrue(bowling.PartieFinie); }
public void ApresUnLancerOnAjouteLeNombreDeQuillesTombeesAuScore() { var bowling = new Bowling(); var currentScore = bowling.Score; bowling.Lance(6); Assert.AreEqual(currentScore + 6, bowling.Score); }
public void ApresUnStrikePartieEstFinieAuBoutDe2LancersSupplementaires() { var bowling = new Bowling(); foreach (var resultat in Enumerable.Repeat(1, 18)) bowling.Lance(resultat); bowling.Lance(10); bowling.Lance(1); Assert.IsFalse(bowling.PartieFinie); bowling.Lance(1); Assert.IsTrue(bowling.PartieFinie); }
public void ApresUnStrikeOnPasseALaFrameSuivante() { var bowling = new Bowling(); var currentFrame = bowling.Frame; bowling.Lance(10); Assert.AreEqual(currentFrame + 1, bowling.Frame); }
public void Setup() { _bowling = new Bowling(); }
public void SiLeLancerDAvantEstUnStrikeEtCeluiAvantUnStrikeOnCompte3FoisLeLancer() { var bowling = new Bowling(); bowling.Lance(10); bowling.Lance(10); var currentScore = bowling.Score; bowling.Lance(6); Assert.AreEqual(currentScore + 6 * 3, bowling.Score); }
public void Setup() { _sut = new Bowling(new EventAggregator()); }
public void ApresPremierLancerOnPeutFaireTomber10moinsXQuilles() { var bowling = new Bowling(); bowling.Lance(6); Assert.AreEqual(4, bowling.Quilles); }
public void LePremierLancerEstUnStrike() { var bowling = new Bowling(); bowling.Lance(10); Assert.AreEqual(Lancer.Strike, bowling.ResultatLancer); }
public void AuPremierLancerOnEstALaFrame0() { var bowling = new Bowling(); Assert.AreEqual(0, bowling.Frame); }
public void LeSecondLancerEstNormalSIlResteDesQuilles() { var bowling = new Bowling(); bowling.Lance(4); bowling.Lance(5); Assert.AreEqual(Lancer.Normal, bowling.ResultatLancer); }
public void PremierLancerPeutFaireTomberAuPlus10Quilles() { var bowling = new Bowling(); Assert.AreEqual(10, bowling.Quilles); }
public void SiDernierFrameSpareApresUnStrikeOnSArrete() { var bowling = new Bowling(); foreach (var resultat in Enumerable.Repeat(1, 18)) bowling.Lance(resultat); bowling.Lance(5); bowling.Lance(5); Assert.IsFalse(bowling.PartieFinie); bowling.Lance(10); Assert.IsTrue(bowling.PartieFinie); }
public void ApresUnLancer0EtUnLancer10OnAUnSpare() { var bowling = new Bowling(); bowling.Lance(0); bowling.Lance(10); Assert.AreEqual(Lancer.Spare, bowling.ResultatLancer); }
public void SiLeLancerDAvantEstUnStrikeOnCompte2FoisLeLancer() { var bowling = new Bowling(); bowling.Lance(10); var currentScore = bowling.Score; bowling.Lance(7); Assert.AreEqual(currentScore + 7 * 2, bowling.Score); }
public FakeGames() { _game = new Bowling(new EventAggregator()); _game.AddPlayer("Kamran"); _game.AddPlayer("Cassie"); }
public void ALaProchaineFrameOnDoitLancer10Quilles() { var bowling = new Bowling(); bowling.Lance(5); bowling.Lance(4); Assert.AreEqual(10, bowling.Quilles); }
public void AuPremierLancerLeScoreEstA0() { var bowling = new Bowling(); Assert.AreEqual(0, bowling.Score); }
public void SiLes2LancerFontTomber10QuillesLeLancerEstUnSpare() { var bowling = new Bowling(); bowling.Lance(6); bowling.Lance(4); Assert.AreEqual(Lancer.Spare, bowling.ResultatLancer); }
public void ApresLaFrame10LaPartieEstFinie() { var bowling = new Bowling(); foreach (var resultat in Enumerable.Repeat(1, 19)) bowling.Lance(resultat); Assert.IsFalse(bowling.PartieFinie); bowling.Lance(1); Assert.IsTrue(bowling.PartieFinie); }
public void AuDebutLaPartieNEstPasFinie() { var bowling = new Bowling(); Assert.IsFalse(bowling.PartieFinie); }
public void LePremierLancerNonStrikeEstNormal() { var bowling = new Bowling(); bowling.Lance(5); Assert.AreEqual(Lancer.Normal, bowling.ResultatLancer); }
public void SiLeLancerDAvantEstUnSpareOnCompte2FoisLeLancer() { var bowling = new Bowling(); bowling.Lance(4); bowling.Lance(6); var currentScore = bowling.Score; bowling.Lance(3); Assert.AreEqual(currentScore + 3 * 2, bowling.Score); }