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