예제 #1
0
        public async Task CreateLogSavesToDatabase()
        {
            // Arrange
            TestStartUp startUp    = new TestStartUp();
            var         db         = startUp.GetDbContext();
            var         logService = new LogService(db);

            // Act
            await logService.CreateLogAsync("username", LogType.AddNewSubtitles, "additionalinformation");

            // Assert
            Assert.True(db.Logs.Any(l => l.UserName == "username" &&
                                    l.Type == LogType.AddNewSubtitles &&
                                    l.AdditionalInformation == "additionalinformation"));
        }
예제 #2
0
        public void Dispose()
        {
            this.timer.Stop();
            var ms  = this.timer.ElapsedMilliseconds;
            var log = new Log();

            log.LogAction       = message;
            log.LogDate         = DateTime.Now;
            log.LogIpaddress    = httpContextAccessor.HttpContext.Connection?.RemoteIpAddress.ToString();
            log.LogPerfTime     = ms.ToString();
            log.LogExcuteStatus = "Success";
            log.LogUserName     = curUser;
            Task.Run(async() => await service.CreateLogAsync(log));
            // log the performance timing with the Logging library of your choice
            // Example:
            // Logger.Write(
            //     string.Format("{0} - Elapsed Milliseconds: {1}", this._message, ms)
            // );
        }