예제 #1
0
파일: Prisoner.cs 프로젝트: skytribe/Day5
        public void Prisoner_AddScore_roundScore1()
        {
            var p = new PrisonersDilemma.Prisoner("P2", new PrisonersDilemma.Defector());

            p.AddScore(0);
            Assert.AreEqual(0, p.RoundScore, "Unexpected Score");
        }
예제 #2
0
파일: Prisoner.cs 프로젝트: skytribe/Day5
        public void Prisoner_AddScore_CumulativeScore5()
        {
            var p = new PrisonersDilemma.Prisoner("P2", new PrisonersDilemma.Defector());

            p.AddScore(1);
            p.AddScore(0);
            Assert.AreEqual(1, p.TotalScore, "Unexpected Score");
        }
예제 #3
0
파일: Prisoner.cs 프로젝트: skytribe/Day5
 public void Prisoner_Strategy_Null()
 {
     try
     {
         var p = new PrisonersDilemma.Prisoner("P1", null);
         Assert.Fail("Expected exception did not occur");
     }
     catch (NullReferenceException)
     { }
     catch
     {
         Assert.Fail("Expected exception did not occur");
     }
 }
예제 #4
0
파일: Prisoner.cs 프로젝트: skytribe/Day5
 public void Prisoner_Name_Blank()
 {
     try
     {
         var p = new PrisonersDilemma.Prisoner("", new PrisonersDilemma.Cooperator());
         Assert.Fail("Expected exception did not occur");
     }
     catch (ArgumentNullException)
     { }
     catch
     {
         Assert.Fail("Expected exception did not occur");
     }
 }
예제 #5
0
파일: Score.cs 프로젝트: skytribe/Day5
        public void Score_BothCooperator()
        {
            var p1 = new PrisonersDilemma.Prisoner("p1", new PrisonersDilemma.Cooperator());
            var p2 = new PrisonersDilemma.Prisoner("p2", new PrisonersDilemma.Cooperator());

            //Set the prisoners Last Choices
            p1.LastChoice = PrisonersDilemma.StrategyChoice.Cooperate;
            p2.LastChoice = PrisonersDilemma.StrategyChoice.Cooperate;

            PrisonersDilemma.Score.DetermineResult(p1, p2);

            Assert.AreEqual(p1.RoundScore, 1);
            Assert.AreEqual(p2.RoundScore, 1);
        }
예제 #6
0
파일: Prisoner.cs 프로젝트: skytribe/Day5
        public void Prisoner_Strategy_Interface_IDPStrategy()
        {
            var p = new PrisonersDilemma.Prisoner("P2", new PrisonersDilemma.Defector());

            Assert.IsInstanceOfType(p.Strategy, typeof(PrisonersDilemma.IPDStrategy), "Type is not interface IPDStrategy");
        }
예제 #7
0
파일: Prisoner.cs 프로젝트: skytribe/Day5
        public void Prisoner_Strategy_Defector()
        {
            var p = new PrisonersDilemma.Prisoner("P2", new PrisonersDilemma.Defector());

            Assert.IsInstanceOfType(p.Strategy, typeof(PrisonersDilemma.Defector), "Type is not defector");
        }
예제 #8
0
파일: Prisoner.cs 프로젝트: skytribe/Day5
        public void Prisoner_Strategy_Cooperate()
        {
            var p = new PrisonersDilemma.Prisoner("P1", new PrisonersDilemma.Cooperator());

            Assert.IsInstanceOfType(p.Strategy, typeof(PrisonersDilemma.Cooperator), "Type is not cooperator");
        }
예제 #9
0
파일: Prisoner.cs 프로젝트: skytribe/Day5
        public void Prisoner_Name()
        {
            var p = new PrisonersDilemma.Prisoner("Cooperator", new PrisonersDilemma.Cooperator());

            Assert.AreEqual(p.Name, "Cooperator", "Prisoner name not set correctly");
        }