예제 #1
0
        public async Task AddActivityLog_InvokeRepository_AsOnce()
        {
            var logType         = ActivityLogType.Login;
            var userId          = "13";
            var activityLogList = new List <ActivityLog>();

            _logRepo.When(c => c.InsertAsync(Arg.Any <ActivityLog>()))
            .Do(c => activityLogList.Add(c.ArgAt <ActivityLog>(0)));

            var activityLog = new ActivityLog
            {
                IpAddress       = "127.0.0.0",
                UserId          = userId,
                ActivityLogType = logType
            };

            var logService = new LogService(_logRepo);
            await logService.AddActivityLog(logType, userId);

            Assert.Single(activityLogList);
            Assert.Equal(activityLog.UserId, activityLogList.First().UserId);
            Assert.Equal(activityLog.ActivityLogType, activityLogList.First().ActivityLogType);
        }