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