예제 #1
0
        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();
        }
예제 #2
0
        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();
        }
예제 #3
0
        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();
        }
예제 #4
0
        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();
        }