コード例 #1
0
        public async void Create()
        {
            Mock <ILogger <DeploymentEnvironmentRepository> > loggerMoc = DeploymentEnvironmentRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = DeploymentEnvironmentRepositoryMoc.GetContext();
            var repository = new DeploymentEnvironmentRepository(loggerMoc.Object, context);

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

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

            record.Should().NotBeNull();
        }
コード例 #2
0
        public async void Get()
        {
            Mock <ILogger <DeploymentEnvironmentRepository> > loggerMoc = DeploymentEnvironmentRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = DeploymentEnvironmentRepositoryMoc.GetContext();
            var repository = new DeploymentEnvironmentRepository(loggerMoc.Object, context);

            DeploymentEnvironment entity = new DeploymentEnvironment();

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

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

            record.Should().NotBeNull();
        }
コード例 #3
0
        public async void Delete()
        {
            Mock <ILogger <DeploymentEnvironmentRepository> > loggerMoc = DeploymentEnvironmentRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = DeploymentEnvironmentRepositoryMoc.GetContext();
            var repository = new DeploymentEnvironmentRepository(loggerMoc.Object, context);
            DeploymentEnvironment entity = new DeploymentEnvironment();

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

            await repository.Delete(entity.Id);

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

            modifiedRecord.Should().BeNull();
        }
コード例 #4
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <DeploymentEnvironmentRepository> > loggerMoc = DeploymentEnvironmentRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = DeploymentEnvironmentRepositoryMoc.GetContext();
            var repository = new DeploymentEnvironmentRepository(loggerMoc.Object, context);
            DeploymentEnvironment entity = new DeploymentEnvironment();

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

            await repository.Update(new DeploymentEnvironment());

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

            modifiedRecord.Should().NotBeNull();
        }