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"); }
public void HaveAnHttpPostMethod() { var hasAHttpPostMethod = TestFunctions.MethodHasAttribute(() => controller.Post(), typeof(HttpPostAttribute)); hasAHttpPostMethod.Should().BeTrue(); }