using NUnit.Framework;
using Sentinel.UnitTests.Helpers;

namespace Sentinel.UnitTests.Sentinel;

[TestFixture]
public class LogBadRequestUnitTests : SentinelTestBase
{
    [SetUp]
    public override async Task Setup()
    {
        await base.Setup();
    }

    [Test]
    public async Task LogBadRequest_WhenCalled_PassesCorrectInformationToRepository()
    {
        //Arrange
        FakeController fakeController = FakeController.CreateFakeController();

        //Act
        await Sentinel.LogBadRequest(fakeController, default);

        //Assert
        Assert.That(SentinelRepository.FailedAccessAttempts.Count, Is.EqualTo(1));

        Assert.That(SentinelRepository.FailedAccessAttempts[0].IPAddress, Is.EqualTo("143.24.20.36"));
        Assert.That(SentinelRepository.FailedAccessAttempts[0].AttemptedTime, Is.EqualTo(_fakeClock.GetNow));
    }
}