public void GetAllGames_GetAllIsCalledAndAndJsonResultIsCorrect() { // Arrange var expectedGames = new List <GameDataModel> { new GameDataModel { Id = 1, Name = "BBB", Key = "k1" }, new GameDataModel { Id = 2, Name = "ZZZ", Key = "k2" }, new GameDataModel { Id = 3, Name = "AAA", Key = "k3" }, }; var mock = new Mock <IGameRepository>(); mock.Setup(m => m.GetAll()).Returns(expectedGames); var controller = new GamesController(mock.Object); // Act var result = controller.GetAllGames() as JsonResult; // Assert Assert.IsNotNull(result); mock.Verify(a => a.GetAll(), Times.Once); Assert.AreEqual(expectedGames, result.Data); }
public void GetGames_ReturnsOkResult() { //Act var okResult = _controller.GetAllGames(); //Assert Assert.Equal(3, okResult.Count()); }