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

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

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

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

            SchemaVersions entity = new SchemaVersions();

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

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

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

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

            await repository.Delete(entity.Id);

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

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

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

            await repository.Update(new SchemaVersions());

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

            modifiedRecord.Should().NotBeNull();
        }