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