Esempio n. 1
0
        public async void Create()
        {
            Mock <ILogger <WorkerTaskLeaseRepository> > loggerMoc = WorkerTaskLeaseRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = WorkerTaskLeaseRepositoryMoc.GetContext();
            var repository = new WorkerTaskLeaseRepository(loggerMoc.Object, context);

            var entity = new WorkerTaskLease();
            await repository.Create(entity);

            var record = await context.Set <WorkerTaskLease>().FirstOrDefaultAsync();

            record.Should().NotBeNull();
        }
Esempio n. 2
0
        public async void Get()
        {
            Mock <ILogger <WorkerTaskLeaseRepository> > loggerMoc = WorkerTaskLeaseRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = WorkerTaskLeaseRepositoryMoc.GetContext();
            var repository = new WorkerTaskLeaseRepository(loggerMoc.Object, context);

            WorkerTaskLease entity = new WorkerTaskLease();

            context.Set <WorkerTaskLease>().Add(entity);
            await context.SaveChangesAsync();

            var record = await repository.Get(entity.Id);

            record.Should().NotBeNull();
        }
Esempio n. 3
0
        public async void Delete()
        {
            Mock <ILogger <WorkerTaskLeaseRepository> > loggerMoc = WorkerTaskLeaseRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = WorkerTaskLeaseRepositoryMoc.GetContext();
            var             repository   = new WorkerTaskLeaseRepository(loggerMoc.Object, context);
            WorkerTaskLease entity       = new WorkerTaskLease();

            context.Set <WorkerTaskLease>().Add(entity);
            await context.SaveChangesAsync();

            await repository.Delete(entity.Id);

            WorkerTaskLease modifiedRecord = await context.Set <WorkerTaskLease>().FirstOrDefaultAsync();

            modifiedRecord.Should().BeNull();
        }
Esempio n. 4
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <WorkerTaskLeaseRepository> > loggerMoc = WorkerTaskLeaseRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = WorkerTaskLeaseRepositoryMoc.GetContext();
            var             repository   = new WorkerTaskLeaseRepository(loggerMoc.Object, context);
            WorkerTaskLease entity       = new WorkerTaskLease();

            context.Set <WorkerTaskLease>().Add(entity);
            await context.SaveChangesAsync();

            await repository.Update(new WorkerTaskLease());

            var modifiedRecord = context.Set <WorkerTaskLease>().FirstOrDefaultAsync();

            modifiedRecord.Should().NotBeNull();
        }