public void Prisoner_AddScore_roundScore1() { var p = new PrisonersDilemma.Prisoner("P2", new PrisonersDilemma.Defector()); p.AddScore(0); Assert.AreEqual(0, p.RoundScore, "Unexpected Score"); }
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"); }
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"); } }
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"); } }
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); }
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"); }
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"); }
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"); }
public void Prisoner_Name() { var p = new PrisonersDilemma.Prisoner("Cooperator", new PrisonersDilemma.Cooperator()); Assert.AreEqual(p.Name, "Cooperator", "Prisoner name not set correctly"); }