Exemplo n.º 1
0
        public AuditTests()
        {
            DbContextOptions <FakeDbContext> mockOptions = new DbContextOptionsBuilder <FakeDbContext>()
                                                           .UseInMemoryDatabase(Guid.NewGuid().ToString()).Options;

            _gspSession = A.Fake <IGspSession>();

            _dateTimeService = A.Fake <IDateTimeService>();

            _auditService = new AuditService(A.Fake <ILogger <AuditService> >(), _dateTimeService, _gspSession);

            _context = new FakeDbContext(mockOptions, _gspSession, _auditService);

            _fixture = new Fixture();

            _accountModel = _fixture.Create <GspUserAccountModel>();
        }
 private static void ProcessAuditableEntity(EntityEntry <AuditableEntity> auditableEntity, GspUserAccountModel userAccountModel, DateTime currentDate)
 {
     if (auditableEntity.State == EntityState.Added)
     {
         auditableEntity.Entity.SetCreatedInfo(userAccountModel.Id, currentDate);
     }
     else
     {
         auditableEntity.Entity.SetUpdatedInfo(userAccountModel.Id, currentDate);
     }
 }