public async Task ReturnErrorObject_GivenNoRunningGameIsFound() { var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.NameIdentifier, "SomeValueHere"), new Claim(ClaimTypes.Name, "*****@*****.**") // other required and custom claims }, "BasicAuth")); var mockPhases = new List <Phase>().AsQueryable().BuildMockDbSet(); var dataContext = new Mock <DataContext>(); dataContext.SetupGet(x => x.Phases).Returns(mockPhases.Object); var requestContext = new RequestContext(); var gameApiServiceLogger = GetMockLogger <GameApiService>().Object; var gameApiService = new Mock <GameApiService>(dataContext.Object, gameApiServiceLogger, requestContext) { CallBase = true }.Object; var requestLoggingService = new RequestLoggingService(requestContext, dataContext.Object); var logger = GetMockLogger <JoinController>().Object; var modController = new JoinController(requestContext, gameApiService, requestLoggingService, logger); modController.ControllerContext = new ControllerContext(); modController.ControllerContext.HttpContext = new DefaultHttpContext { User = user }; var response = await modController.Post(); response.StatusCode.Should().Be(200); var result = (JoinResponse)response.Value; result.Err.Should().NotBeNull(); result.Err.Description.Should().Be("Game is not running"); }
/// <summary> /// Configuration of app /// </summary> public void Configuration(IAppBuilder app) { JoinController.Configure(app); MasterController.Configure(app); VotingController.Configure(app); PlayController.Configure(app); }
public JoinControllerShould() { var dataContext = new Mock <DataContext>(); var requestContext = new RequestContext(); var gameApiServiceLogger = new Mock <ILogger <GameApiService> >().Object; var gameApiService = new Mock <GameApiService>(dataContext.Object, gameApiServiceLogger, requestContext); var requestLoggingService = new RequestLoggingService(requestContext, dataContext.Object); var logger = Mock.Of <ILogger <JoinController> >(); controller = new JoinController(requestContext, gameApiService.Object, requestLoggingService, logger); }