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