public void DeleteMatch_Cheсk_Not_This_Match()
        {
            IMatchListService matchListService = GetMatchListService();

            new Func <Task>(() => matchListService.DeleteMatch("user", "otherId"))
            .ShouldThrow <KeyNotFoundException>();
        }
        public async Task DeleteMatch_Cheсk_Not_This_User()
        {
            IMatchListService matchListService = GetMatchListService();

            await matchListService.CreateMatch("user");

            var matchIds = await matchListService.GetMatches("user", 10, 0);

            var matchId = matchIds.SingleOrDefault().MatchId;

            new Func <Task>(() => matchListService.DeleteMatch("user1", matchId)).ShouldThrow <KeyNotFoundException>();
        }
        public async Task DeleteMatch_Cheсk()
        {
            IMatchListService matchListService = GetMatchListService();

            await matchListService.CreateMatch("user");

            var matchIds = await matchListService.GetMatches("user", 10, 0);

            var matchId = matchIds.SingleOrDefault().MatchId;

            await matchListService.DeleteMatch("user", matchId);

            var matches = await matchListService.GetMatches("user", 10, 0);

            matches.Should().BeNullOrEmpty();
        }
Exemple #4
0
        public async Task <IActionResult> Delete(string id, string returnUrl)
        {
            try
            {
                await _matchListService.DeleteMatch(UserId, id);
            }
            catch (KeyNotFoundException)
            {
                return(NotFound());
            }

            if (string.IsNullOrEmpty(returnUrl))
            {
                return(RedirectToAction(nameof(Index)));
            }
            return(LocalRedirect(returnUrl));
        }