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

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

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

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

            ExtensionConfiguration entity = new ExtensionConfiguration();

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

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

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

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

            await repository.Delete(entity.Id);

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

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

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

            await repository.Update(new ExtensionConfiguration());

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

            modifiedRecord.Should().NotBeNull();
        }