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 Update_Entity_Is_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(); var record = await repository.Get(entity.Id); await repository.Update(record); var modifiedRecord = context.Set <CompositePrimaryKey>().FirstOrDefaultAsync(); modifiedRecord.Should().NotBeNull(); }