Exemplo n.º 1
0
        public async void All()
        {
            Mock <ILogger <HandlerPipelineStepRepository> > loggerMoc = HandlerPipelineStepRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = HandlerPipelineStepRepositoryMoc.GetContext();
            var repository = new HandlerPipelineStepRepository(loggerMoc.Object, context);
            var records    = await repository.All();

            records.Should().NotBeEmpty();
            records.Count.Should().Be(1);
        }
Exemplo n.º 2
0
        public void DeleteNotFound()
        {
            Mock <ILogger <HandlerPipelineStepRepository> > loggerMoc = HandlerPipelineStepRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = HandlerPipelineStepRepositoryMoc.GetContext();
            var repository = new HandlerPipelineStepRepository(loggerMoc.Object, context);

            Func <Task> delete = async() =>
            {
                await repository.Delete(default(int));
            };

            delete.Should().NotThrow();
        }
        public async void Create()
        {
            Mock <ILogger <HandlerPipelineStepRepository> > loggerMoc = HandlerPipelineStepRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = HandlerPipelineStepRepositoryMoc.GetContext();
            var repository = new HandlerPipelineStepRepository(loggerMoc.Object, context);

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

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

            record.Should().NotBeNull();
        }
Exemplo n.º 4
0
        public async void Create()
        {
            Mock <ILogger <HandlerPipelineStepRepository> > loggerMoc = HandlerPipelineStepRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = HandlerPipelineStepRepositoryMoc.GetContext();
            var repository = new HandlerPipelineStepRepository(loggerMoc.Object, context);

            var entity = new HandlerPipelineStep();

            entity.SetProperties(default(int), 1, 1);
            await repository.Create(entity);

            var records = await context.Set <HandlerPipelineStep>().ToListAsync();

            records.Count.Should().Be(2);
        }
        public async void Get()
        {
            Mock <ILogger <HandlerPipelineStepRepository> > loggerMoc = HandlerPipelineStepRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = HandlerPipelineStepRepositoryMoc.GetContext();
            var repository = new HandlerPipelineStepRepository(loggerMoc.Object, context);

            HandlerPipelineStep entity = new HandlerPipelineStep();

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

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

            record.Should().NotBeNull();
        }
        public async void Delete()
        {
            Mock <ILogger <HandlerPipelineStepRepository> > loggerMoc = HandlerPipelineStepRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = HandlerPipelineStepRepositoryMoc.GetContext();
            var repository             = new HandlerPipelineStepRepository(loggerMoc.Object, context);
            HandlerPipelineStep entity = new HandlerPipelineStep();

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

            await repository.Delete(entity.Id);

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

            modifiedRecord.Should().BeNull();
        }
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <HandlerPipelineStepRepository> > loggerMoc = HandlerPipelineStepRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = HandlerPipelineStepRepositoryMoc.GetContext();
            var repository             = new HandlerPipelineStepRepository(loggerMoc.Object, context);
            HandlerPipelineStep entity = new HandlerPipelineStep();

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

            await repository.Update(new HandlerPipelineStep());

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

            modifiedRecord.Should().NotBeNull();
        }
Exemplo n.º 8
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <HandlerPipelineStepRepository> > loggerMoc = HandlerPipelineStepRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = HandlerPipelineStepRepositoryMoc.GetContext();
            var repository             = new HandlerPipelineStepRepository(loggerMoc.Object, context);
            HandlerPipelineStep entity = new HandlerPipelineStep();

            entity.SetProperties(default(int), 1, 1);
            context.Set <HandlerPipelineStep>().Add(entity);
            await context.SaveChangesAsync();

            context.Entry(entity).State = EntityState.Detached;

            await repository.Update(entity);

            var records = await context.Set <HandlerPipelineStep>().ToListAsync();

            records.Count.Should().Be(2);
        }