public async void Get() { Mock <ILogger <LinkStatusRepository> > loggerMoc = LinkStatusRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = LinkStatusRepositoryMoc.GetContext(); var repository = new LinkStatusRepository(loggerMoc.Object, context); LinkStatus entity = new LinkStatus(); context.Set <LinkStatus>().Add(entity); await context.SaveChangesAsync(); var record = await repository.Get(entity.Id); record.Should().NotBeNull(); }
public async void Update_Entity_Is_Tracked() { Mock <ILogger <LinkStatusRepository> > loggerMoc = LinkStatusRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = LinkStatusRepositoryMoc.GetContext(); var repository = new LinkStatusRepository(loggerMoc.Object, context); LinkStatus entity = new LinkStatus(); context.Set <LinkStatus>().Add(entity); await context.SaveChangesAsync(); var record = await repository.Get(entity.Id); await repository.Update(record); var modifiedRecord = context.Set <LinkStatus>().FirstOrDefaultAsync(); modifiedRecord.Should().NotBeNull(); }
public async void Update_Entity_Is_Tracked() { Mock <ILogger <LinkStatusRepository> > loggerMoc = LinkStatusRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = LinkStatusRepositoryMoc.GetContext(); var repository = new LinkStatusRepository(loggerMoc.Object, context); LinkStatus entity = new LinkStatus(); entity.SetProperties(default(int), "B"); context.Set <LinkStatus>().Add(entity); await context.SaveChangesAsync(); var record = await repository.Get(entity.Id); await repository.Update(record); var records = await context.Set <LinkStatus>().ToListAsync(); records.Count.Should().Be(2); }