コード例 #1
0
        public void Map_Test()
        {
            //Arange
            var transferLog = new TransferUserActivity
            {
                Date = new DateTime(1, 1, 1),
                Description = "test",
                EntityState = EntityState.Unchanged,
                LogId = 1,
                UserId = 1,
                UserName = "******"
            };

            var log = new UserActivity
            {
                Date = new DateTime(1, 1, 1),
                Description = "test",
                EntityState = EntityState.Unchanged,
                LogId = 1,
                UserId = 1,
                UserName = "******"
            };

            var comperableDomainLog = new ComperableDomainLog()
            {
                Date = new DateTime(1, 1, 1),
                Description = "test",
                EntityState = EntityState.Unchanged,
                LogId = 1,
                UserId = 1,
                UserName = "******"
            };

            var comperableTransferLog = new ComperableTransferLog()
            {
                Date = new DateTime(1, 1, 1),
                Description = "test",
                EntityState = EntityState.Unchanged,
                LogId = 1,
                UserId = 1,
                UserName = "******"
            };

            var mapper = new UserActivityMapper();
            //Act
            var actualTransfer = mapper.Map(log);
            var actualDomain = mapper.Map(transferLog);

            //Assert
            Assert.That(actualDomain,
                Is.EqualTo(comperableDomainLog));
            Assert.That(actualTransfer,
                Is.EqualTo(comperableTransferLog));
        }
コード例 #2
0
        public async Task SaveActivityAsync(UserActivity log)
        {
            if (log == null)
            {
                throw new ArgumentNullException("log");
            }

            using (_diagnosticContext = _diagnosticFactory.Create())
            {
                _diagnosticContext.UserActivities
                    .Add(log);

                await _diagnosticContext.SaveChangesAsync();
            }
        }
コード例 #3
0
 public TransferUserActivity Map(UserActivity log)
 {
     if (log == null)
     {
         throw new ArgumentNullException("log");
     }
     return new TransferUserActivity
     {
         Date = log.Date,
         Description = log.Description,
         LogId = log.LogId,
         UserId = log.UserId,
         UserName = log.UserName,
         UserRoleName = log.UserRoleName,
         EntityState = EntityState.Unchanged
     };
 }