Ejemplo n.º 1
0
        public void ViewRecordDirect()
        {
            // Arrange
            Player player = new Player();

            player.PlayerId = 1;
            Mock <User>        userMock    = new Mock <User>();
            Mock <GameManager> managerMock = new Mock <GameManager>(userMock.Object);

            managerMock.Expect(m => m.GetPlayer(1))
            .Returns(player).AtMostOnce().Verifiable();
            PlayerRecordController controller = new PlayerRecordController(managerMock.Object);

            // Act
            ActionResult result = controller.ViewRecord(1);

            // Assert
            Assert.That(result, Is.TypeOf(typeof(ViewResult)), "Should return a view");
            Assert.That(controller.ModelState.IsValid, "No errors should be returned");
            Assert.That(controller.ViewData["Player"], Is.EqualTo(player), "The Player field should be the player object");

            managerMock.Verify();
        }
Ejemplo n.º 2
0
        public void ViewRecordHistory()
        {
            // Arrange
            Player player = new Player();

            player.PlayerId = 1;
            Mock <User>        userMock    = new Mock <User>();
            Mock <GameManager> managerMock = new Mock <GameManager>(userMock.Object);

            managerMock.Expect(m => m.CurrentPlayer)
            .Returns(player).AtMostOnce().Verifiable();
            PlayerRecordController controller = new PlayerRecordController(managerMock.Object);

            // Act
            ActionResult result = controller.ViewRecordHistory();

            // Assert
            Assert.That(result, Is.TypeOf(typeof(ViewResult)), "Should return a view");
            Assert.That(controller.ModelState.IsValid, "No errors should be returned");
            Assert.That(controller.ViewData["recordType"], Is.InstanceOfType(typeof(SelectList)), "The recordType field should be a SelectList of the record types");

            managerMock.Verify();
        }
Ejemplo n.º 3
0
        public void ListRecords()
        {
            // Arrange
            PlayerTopRecord[] topPlayers = { new PlayerTopRecord(new Player(), Player.RecordType.NetWorth, 0), new PlayerTopRecord(new Player(), Player.RecordType.NetWorth, 1) };
            topPlayers[0].Player.Name = "Player 1";
            topPlayers[1].Player.Name = "Player 2";
            Mock <User>        userMock    = new Mock <User>();
            Mock <GameManager> managerMock = new Mock <GameManager>(userMock.Object);

            managerMock.Expect(m => m.GetTopPlayers(Player.RecordType.NetWorth, 10))
            .Returns(topPlayers).AtMostOnce().Verifiable();
            PlayerRecordController controller = new PlayerRecordController(managerMock.Object);

            // Act
            ActionResult result = controller.ListRecords(Player.RecordType.NetWorth);

            // Assert
            Assert.That(result, Is.TypeOf(typeof(ViewResult)), "Should return a view");
            Assert.That(controller.ModelState.IsValid, "No errors should be returned");
            Assert.That(controller.ViewData["recordType"], Is.TypeOf(typeof(SelectList)), "The recordType field should be a Select object");
            Assert.That(controller.ViewData["TopRecords"], Is.EqualTo(topPlayers), "The TopRecords field should be the array of top player objects");

            managerMock.Verify();
        }