Beispiel #1
0
		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);
		}
Beispiel #2
0
		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);
		}
Beispiel #3
0
		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);
		}
Beispiel #4
0
		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);
		}
Beispiel #5
0
		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);
		}
Beispiel #6
0
		public void SetUp()
		{
			turn301 = new Turn(301);
		}
Beispiel #7
0
 protected bool Equals(Turn other)
 {
     return(Throws.SequenceEqual(other.Throws) && ScoreBefore == other.ScoreBefore);
 }
Beispiel #8
0
		protected bool Equals(Turn other)
		{
			return Throws.SequenceEqual(other.Throws) && ScoreBefore == other.ScoreBefore;
		}