﻿using HaloEzAPI.Abstraction.Enum.Halo5;
using HaloEzAPI.Model.Response.Error;
using NUnit.Framework;

namespace HaloEzAPI.Tests.HaloAPIServiceTests.Stats.Halo5
{
    [TestFixture]
    public class GetMatchesForPlayerTests : BaseHaloAPIServiceTests
    {
        [Test]
        [TestCase("Glitch100", GameMode.Arena)]
        public void Default_DoesNotThrowException(string gamerTag,GameMode gameMode)
        {
            Assert.DoesNotThrow(async () => await HaloApiService.GetMatchesForPlayer(gamerTag, gameMode));
        }

        [Test]
        [TestCase("Glitch100", GameMode.Arena)]
        public async void Default_DoesNotReturnNull(string gamerTag,GameMode gameMode)
        {
            var result = await HaloApiService.GetMatchesForPlayer(gamerTag, gameMode);
            Assert.IsNotNull(result);
        }

        [Test]
        [TestCase("",GameMode.Arena)]
        [TestCase(null,GameMode.Arena)]
        [TestCase("asfasd9f8adf89andfa98sdfa",GameMode.Arena)]
        public void ProvideInvalidGamertag_ThrowsException(string gamerTag,GameMode gameMode)
        {
            Assert.Throws<HaloAPIException>(async () => await HaloApiService.GetMatchesForPlayer(gamerTag, gameMode), CommonErrorMessages.InvalidGamerTag);
        }

        [Test]
        [TestCase("Glitch100")]
        public async void ProvideValidGamertag_GetValidReponse(string gamerTag)
        {
            var result = await HaloApiService.GetMatchesForPlayer(gamerTag, GameMode.All);
            Assert.AreEqual(result.Count,25);
        }

        [Test]
        [TestCase("Glitch100",5,10)]
        [TestCase("Glitch100",6,15)]
        public async void ProvideStartAndCount_GetValidReponse(string gamerTag,int start, int count)
        {
            var result = await HaloApiService.GetMatchesForPlayer(gamerTag, GameMode.All, start, count);
            Assert.AreEqual(result.Count, count);
            Assert.AreEqual(result.Start, start);
        }
    }
}
