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