public async Task ShouldBeHttpStatusCodeOk() { // Arrange var userId = new UserId(); var playerId = new PlayerId(); var authentication = new LeagueOfLegendsGameAuthentication( playerId, new LeagueOfLegendsGameAuthenticationFactor( 1, string.Empty, 2, string.Empty)); var summoner = new Summoner { AccountId = playerId, ProfileIconId = authentication.Factor.CurrentSummonerProfileIconId }; var request = new LeagueOfLegendsRequest("SwagYoloMlg"); var factory = TestHost.WithClaimsFromDefaultAuthentication(new Claim(JwtClaimTypes.Subject, userId.ToString())) .WithWebHostBuilder( builder => builder.ConfigureTestContainer <ContainerBuilder>( container => { var mockLeagueOfLegendsService = new Mock <ILeagueOfLegendsService>(); mockLeagueOfLegendsService .Setup(leagueOfLegendsService => leagueOfLegendsService.Summoner.GetSummonerByNameAsync(It.IsAny <Region>(), request.SummonerName)) .ReturnsAsync(summoner) .Verifiable(); container.RegisterInstance(mockLeagueOfLegendsService.Object).As <ILeagueOfLegendsService>().SingleInstance(); })); _httpClient = factory.CreateClient(); factory.Server.CleanupDbContext(); // Act using var response = await this.ExecuteAsync(Game.LeagueOfLegends, request); // Assert response.EnsureSuccessStatusCode(); response.StatusCode.Should().Be(HttpStatusCode.OK); }
private async Task <HttpResponseMessage> ExecuteAsync(Game game, LeagueOfLegendsRequest request) { return(await _httpClient.PostAsJsonAsync($"api/games/{game}/authentications", request)); }