public void NotBeBust_IfFinishWithDouble()
		{
			var turn2 = new Turn(2);
			var res = turn2.WithAdditionalThrow(new ThrowResult(1, SectionArea.Double));
			Assert.IsTrue(res.Finished);
			Assert.IsFalse(res.Bust);
			Assert.AreEqual(0, res.ScoreAfter);
		}
		public void BeBust_IfRemainsOne()
		{
			var turn2 = new Turn(2);
			var res = turn2.WithAdditionalThrow(new ThrowResult(1, SectionArea.Single));
			Assert.IsTrue(res.Finished);
			Assert.IsTrue(res.Bust);
			Assert.AreEqual(2, res.ScoreAfter);
		}
		public void BeBust_IfLastThrowIsNotDouble()
		{
			var turn2 = new Turn(2);
			turn2 = turn2.WithAdditionalThrow(new ThrowResult(2, SectionArea.Single));
			Assert.IsTrue(turn2.Finished);
			Assert.IsTrue(turn2.Bust);
			Assert.AreEqual(2, turn2.ScoreAfter);
		}
		public void NotBeBust_IfFinishWithDoubleAfterCoubleOfThrows()
		{
			var turn2 = new Turn(4);
			var res = turn2.WithAdditionalThrow(ThrowResult.Outside)
			.WithAdditionalThrow(new ThrowResult(2, SectionArea.Single))
			.WithAdditionalThrow(new ThrowResult(1, SectionArea.Double));
			Assert.IsTrue(res.Finished);
			Assert.IsFalse(res.Bust);
			Assert.AreEqual(0, res.ScoreAfter);
		}
		public void BeSerializable()
		{
			var turn = new Turn(301)
				.WithAdditionalThrow(ThrowResult.Outside)
				.WithAdditionalThrow(ThrowResult.Single(1))
				.WithAdditionalThrow(ThrowResult.Double(2));
			var res = JsonConvert.SerializeObject(turn, new ThrowJsonConverter());
			Assert.AreEqual(@"{""Throws"":[""0"",""1"",""D2""],""ScoreBefore"":301,""ScoreAfter"":296,""Finished"":true,""Bust"":false}", res, res);
			var deserialized = JsonConvert.DeserializeObject<Turn>(res, new ThrowJsonConverter());
			Assert.AreEqual(turn, deserialized);
		}
		public void SetUp()
		{
			turn301 = new Turn(301);
		}
Exemple #7
0
 protected bool Equals(Turn other)
 {
     return(Throws.SequenceEqual(other.Throws) && ScoreBefore == other.ScoreBefore);
 }
Exemple #8
0
		protected bool Equals(Turn other)
		{
			return Throws.SequenceEqual(other.Throws) && ScoreBefore == other.ScoreBefore;
		}