Пример #1
0
        public async void Create()
        {
            Mock <ILogger <DeploymentRepository> > loggerMoc = DeploymentRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = DeploymentRepositoryMoc.GetContext();
            var repository = new DeploymentRepository(loggerMoc.Object, context);

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

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

            record.Should().NotBeNull();
        }
Пример #2
0
        public async void Get()
        {
            Mock <ILogger <DeploymentRepository> > loggerMoc = DeploymentRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = DeploymentRepositoryMoc.GetContext();
            var repository = new DeploymentRepository(loggerMoc.Object, context);

            Deployment entity = new Deployment();

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

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

            record.Should().NotBeNull();
        }
Пример #3
0
        public async void Delete()
        {
            Mock <ILogger <DeploymentRepository> > loggerMoc = DeploymentRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = DeploymentRepositoryMoc.GetContext();
            var        repository        = new DeploymentRepository(loggerMoc.Object, context);
            Deployment entity            = new Deployment();

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

            await repository.Delete(entity.Id);

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

            modifiedRecord.Should().BeNull();
        }
Пример #4
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <DeploymentRepository> > loggerMoc = DeploymentRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = DeploymentRepositoryMoc.GetContext();
            var        repository        = new DeploymentRepository(loggerMoc.Object, context);
            Deployment entity            = new Deployment();

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

            await repository.Update(new Deployment());

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

            modifiedRecord.Should().NotBeNull();
        }