private LoggingContext CreateContext()
        {
            DbContextOptions <LoggingContext> options = new DbContextOptionsBuilder <LoggingContext>()
                                                        .UseInMemoryDatabase(databaseName: "LoggingRepository")
                                                        .Options;
            LoggingContext context = new LoggingContext(options);

            repo = new LogInfoRepository(context);
            return(context);
        }
        private void CreateDisconnectedDatabase()
        {
            DbContextOptions <LoggingContext> options = new DbContextOptionsBuilder <LoggingContext>()
                                                        .UseInMemoryDatabase(databaseName: "UserRepositoryTest")
                                                        .Options;
            Mock <LoggingContext> contextMock = new Mock <LoggingContext>(options);
            Mock <DbException>    toThrow     = new Mock <DbException>();

            contextMock.Setup(c => c.Logs).Throws(toThrow.Object);
            repo = new LogInfoRepository(contextMock.Object);
        }
Exemplo n.º 3
0
        public void Initialize()
        {
            aLog = new LogInfo()
            {
                Id       = 1,
                Date     = DateTime.Now,
                LogType  = LogType.LOGIN,
                Message  = "Logged using API",
                Username = "******"
            };
            logRepo = new Mock <ILogInfoRepository>().Object;
            Mock.Get(logRepo).Setup(l => l.Get(aLog.Id)).Throws(new LogNotFoundException());
            Mock.Get(logRepo).Setup(l => l.GetAll()).Returns(new List <LogInfo>());
            Mock.Get(logRepo).Setup(l => l.Exists(aLog.Id)).Returns(false);
            Mock.Get(logRepo).Setup(l => l.Delete(aLog.Id)).Callback(DeleteALog);
            Mock.Get(logRepo).Setup(l => l.Add(It.IsAny <LogInfo>())).Returns(aLog).Callback(AddALog);
            Mock <IAuthenticationService> auth = new Mock <IAuthenticationService>();

            logger = new LoggerService(logRepo, auth.Object);
        }
Exemplo n.º 4
0
 public LogInfoService(ILogInfoRepository logInfoRepository)
 {
     _logInfoRepository = logInfoRepository;
 }
 public LoggerService(ILogInfoRepository logRepo, IAuthenticationService authService)
 {
     this.logRepo  = logRepo;
     authenticator = authService;
 }
Exemplo n.º 6
0
 public LogInfoService(ILogInfoRepository repository) : base(repository)
 {
     this._repository = repository;
 }
Exemplo n.º 7
0
 public LogInfoService(ILogInfoRepository logInfoRepository, IActionContextAccessor actionContext)
 {
     _logInfoRepository = logInfoRepository;
     _actionContext     = actionContext;
 }
Exemplo n.º 8
0
 public AuthenticationService(IUserRepository aRepo, ILogInfoRepository aLogger)
 {
     users  = aRepo;
     logger = aLogger;
     mapper = new UserDtoMapper();
 }
 public LogInfoController(ILogInfoRepository logInfoRepository)
 {
     m_logInfoRepository = (logInfoRepository != null) ? logInfoRepository : throw new ArgumentNullException();
 }
Exemplo n.º 10
0
 public LogInfoController(LogInfoService logInfoService, ILogInfoRepository logInfoRepository)
 {
     LogInfoService    = logInfoService;
     LogInfoRepository = logInfoRepository;
 }