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