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