using Microsoft.Extensions.Logging;

using MongoDB.Driver;

using DataProviders;

namespace CoreTests.FakeServices {
  public class SessionFakeService : ISessionService {

    private readonly ILogger<SessionFakeService> _logger;
    private List<Guid> _sessions;

    public SessionFakeService(
    ILogger<SessionFakeService> logger
    )  {
      _logger = logger;
      _sessions = new List<Guid>();
    }


    public void CommitTransaction(Guid id) {
      _sessions.Remove(id);
    }

    public void DisposeSession(Guid id) {
       _sessions.Remove(id);
    }

    public IClientSessionHandle? GetSession(Guid id) {
      return null;
    }

    public void RollbackTransaction(Guid id) {
      _sessions.Remove(id);
    }

    public Task<Guid> StartSession() {
      return Task.Run(() => {
        var sessionId = Guid.NewGuid();
        _sessions.Add(sessionId);
        return sessionId;
      });
    }

    public void StartTransaction(Guid id) {
      // do nothing
    }
  }
}
