public void HubContextService_TestGetInitialDataNoUserNoActiveGame() { var session = new Session(); var requestSession = new Mock<ICurrentRequestSession>(); requestSession.Setup(x => x.Session).Returns((Session)session); var mockHubContext = new MockHubContext("connection #5"); mockHubContext.Client<IHubClient>("connection #5").Setup(x => x.setUsername(It.Is<string>(y => y.Equals("none")))).Verifiable(); var activeGame = new Mock<IActiveGoGame>(); activeGame.Setup(x => x.Game).Returns((GoGame)null); var goService = new Mock<IGoService>(); var hubGoService = new GameOfGoHubService(mockHubContext.Object, requestSession.Object, activeGame.Object, goService.Object, null); hubGoService.GetInitialData(); mockHubContext.VerifyClients(); }
public void HubContextService_TestGetInitialDataWithUserWithActiveGame() { var session = new Session(); session.User = new User(); session.User.Username = "******"; var requestSession = new Mock<ICurrentRequestSession>(); requestSession.Setup(x => x.Session).Returns((Session)session); var mockHubContext = new MockHubContext("connection #5"); mockHubContext.Client<IHubClient>("connection #5").Setup(x => x.setUsername(It.Is<string>(y => y.Equals("White Player")))).Verifiable(); IActiveGoGame activeGame; CreateActiveGame(session.User, null, "96cc91ebea4740aaa91099dd0ca4272a", out activeGame); mockHubContext.Groups.Setup(x => x.Add(It.Is<string>(y => y.Equals("connection #5")), It.Is<string>(z => z.Equals("96cc91ebea4740aaa91099dd0ca4272a")))).Verifiable(); mockHubContext.Client<IHubClient>("96cc91ebea4740aaa91099dd0ca4272a").Setup(x => x.updateGame(It.Is<object>(y => true))).Verifiable(); var goService = new Mock<IGoService>(); var hubGoService = new GameOfGoHubService(mockHubContext.Object, requestSession.Object, activeGame, goService.Object, null); hubGoService.GetInitialData(); mockHubContext.VerifyClients(); mockHubContext.Groups.VerifyAll(); }