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