public async Task CantModifyUserOnInterceptionsWhenDisabledByTypeAsync() { const string user = "******"; var entity = new CustomerWithTimeStamp(); var options = new RepositoryOptionsBuilder() .UseInMemoryDatabase() .UseInterceptor(new TestRepositoryTimeStampInterceptor(user)) .Options; var repo = new Repository <CustomerWithTimeStamp>(options) { InterceptorsEnabled = true }; repo.InterceptorTypesDisabled.Add(typeof(TestRepositoryTimeStampInterceptor), true); Assert.Null(entity.CreateTime); Assert.Null(entity.ModTime); Assert.Null(entity.CreateUser); Assert.Null(entity.ModUser); await repo.AddAsync(entity); Assert.Null(entity.CreateTime); Assert.Null(entity.ModTime); Assert.Null(entity.CreateUser); Assert.Null(entity.ModUser); }
public void CantModifyUserOnInterceptionsWhenDisabled() { const string user = "******"; var entity = new CustomerWithTimeStamp(); var options = new RepositoryOptionsBuilder() .UseInMemoryDatabase() .UseInterceptor(new TestRepositoryTimeStampInterceptor(user)) .Options; var repo = new Repository <CustomerWithTimeStamp>(options) { InterceptorsEnabled = false }; Assert.Null(entity.CreateTime); Assert.Null(entity.ModTime); Assert.Null(entity.CreateUser); Assert.Null(entity.ModUser); repo.Add(entity); Assert.Null(entity.CreateTime); Assert.Null(entity.ModTime); Assert.Null(entity.CreateUser); Assert.Null(entity.ModUser); }
public async Task CanModifyUserOnInterceptionsAsync() { const string user = "******"; var entity = new CustomerWithTimeStamp(); var options = new RepositoryOptionsBuilder() .UseInMemoryDatabase() .UseInterceptor(new TestRepositoryTimeStampInterceptor(user)) .Options; var repo = new Repository <CustomerWithTimeStamp>(options); Assert.Null(entity.CreateTime); Assert.Null(entity.ModTime); Assert.Null(entity.CreateUser); Assert.Null(entity.ModUser); await repo.AddAsync(entity); Assert.NotNull(entity.CreateTime); Assert.NotNull(entity.ModTime); Assert.Equal(user, entity.CreateUser); Assert.Equal(user, entity.ModUser); }