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