Example #1
0
        public async void All()
        {
            Mock <ILogger <PipelineStepStepRequirementRepository> > loggerMoc = PipelineStepStepRequirementRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = PipelineStepStepRequirementRepositoryMoc.GetContext();
            var repository = new PipelineStepStepRequirementRepository(loggerMoc.Object, context);
            var records    = await repository.All();

            records.Should().NotBeEmpty();
            records.Count.Should().Be(1);
        }
        public async void Create()
        {
            Mock <ILogger <PipelineStepStepRequirementRepository> > loggerMoc = PipelineStepStepRequirementRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = PipelineStepStepRequirementRepositoryMoc.GetContext();
            var repository = new PipelineStepStepRequirementRepository(loggerMoc.Object, context);

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

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

            record.Should().NotBeNull();
        }
Example #3
0
        public void DeleteNotFound()
        {
            Mock <ILogger <PipelineStepStepRequirementRepository> > loggerMoc = PipelineStepStepRequirementRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = PipelineStepStepRequirementRepositoryMoc.GetContext();
            var repository = new PipelineStepStepRequirementRepository(loggerMoc.Object, context);

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

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

            PipelineStepStepRequirement entity = new PipelineStepStepRequirement();

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

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

            record.Should().NotBeNull();
        }
Example #5
0
        public async void Create()
        {
            Mock <ILogger <PipelineStepStepRequirementRepository> > loggerMoc = PipelineStepStepRequirementRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = PipelineStepStepRequirementRepositoryMoc.GetContext();
            var repository = new PipelineStepStepRequirementRepository(loggerMoc.Object, context);

            var entity = new PipelineStepStepRequirement();

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

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

            records.Count.Should().Be(2);
        }
        public async void Delete()
        {
            Mock <ILogger <PipelineStepStepRequirementRepository> > loggerMoc = PipelineStepStepRequirementRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = PipelineStepStepRequirementRepositoryMoc.GetContext();
            var repository = new PipelineStepStepRequirementRepository(loggerMoc.Object, context);
            PipelineStepStepRequirement entity = new PipelineStepStepRequirement();

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

            await repository.Delete(entity.Id);

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

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

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

            await repository.Update(new PipelineStepStepRequirement());

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

            modifiedRecord.Should().NotBeNull();
        }
Example #8
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <PipelineStepStepRequirementRepository> > loggerMoc = PipelineStepStepRequirementRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = PipelineStepStepRequirementRepositoryMoc.GetContext();
            var repository = new PipelineStepStepRequirementRepository(loggerMoc.Object, context);
            PipelineStepStepRequirement entity = new PipelineStepStepRequirement();

            entity.SetProperties(default(int), "B", 1, true);
            context.Set <PipelineStepStepRequirement>().Add(entity);
            await context.SaveChangesAsync();

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

            await repository.Update(entity);

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

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