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