public async void Create() { Mock <ILogger <ApiKeyRepository> > loggerMoc = ApiKeyRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = ApiKeyRepositoryMoc.GetContext(); var repository = new ApiKeyRepository(loggerMoc.Object, context); var entity = new ApiKey(); await repository.Create(entity); var record = await context.Set <ApiKey>().FirstOrDefaultAsync(); record.Should().NotBeNull(); }
public async void Get() { Mock <ILogger <ApiKeyRepository> > loggerMoc = ApiKeyRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = ApiKeyRepositoryMoc.GetContext(); var repository = new ApiKeyRepository(loggerMoc.Object, context); ApiKey entity = new ApiKey(); context.Set <ApiKey>().Add(entity); await context.SaveChangesAsync(); var record = await repository.Get(entity.Id); record.Should().NotBeNull(); }
public async void Delete() { Mock <ILogger <ApiKeyRepository> > loggerMoc = ApiKeyRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = ApiKeyRepositoryMoc.GetContext(); var repository = new ApiKeyRepository(loggerMoc.Object, context); ApiKey entity = new ApiKey(); context.Set <ApiKey>().Add(entity); await context.SaveChangesAsync(); await repository.Delete(entity.Id); ApiKey modifiedRecord = await context.Set <ApiKey>().FirstOrDefaultAsync(); modifiedRecord.Should().BeNull(); }
public async void Update_Entity_Is_Not_Tracked() { Mock <ILogger <ApiKeyRepository> > loggerMoc = ApiKeyRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = ApiKeyRepositoryMoc.GetContext(); var repository = new ApiKeyRepository(loggerMoc.Object, context); ApiKey entity = new ApiKey(); context.Set <ApiKey>().Add(entity); await context.SaveChangesAsync(); await repository.Update(new ApiKey()); var modifiedRecord = context.Set <ApiKey>().FirstOrDefaultAsync(); modifiedRecord.Should().NotBeNull(); }