public async Task CreateNewGameTest() { var mockRandom = new Moq.Mock <Random>(); mockRandom.Setup(rand => rand.Next(1, 10000)).Returns(() => 1234); //Random Number Generator returns 1234 var randomGenerator = new RandomGenerator(mockRandom.Object); var mockCache = new Mock <IMemoryCache>(); mockCache.Setup (cache => cache.CreateEntry( It.IsAny <object>() )) .Returns(Mock.Of <ICacheEntry>()); var mockConfig = new Mock <IOptions <BattleshipConfiguration> >(); var mockEngine = new Mock <GameEngine>(mockConfig.Object); var controller = new BattleShipController(mockCache.Object, mockConfig.Object, mockEngine.Object, randomGenerator); var result = controller.GetNewGame(); var viewResult = Assert.IsType <ActionResult <GameStateResponse> >(result); Assert.True(compareObjectJsons(new GameStateResponse(1234), result.Value)); }