예제 #1
0
        public async void Create()
        {
            Mock <ILogger <SchemaAPersonRepository> > loggerMoc = SchemaAPersonRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SchemaAPersonRepositoryMoc.GetContext();
            var repository = new SchemaAPersonRepository(loggerMoc.Object, context);

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

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

            record.Should().NotBeNull();
        }
예제 #2
0
        public async void Get()
        {
            Mock <ILogger <SchemaAPersonRepository> > loggerMoc = SchemaAPersonRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SchemaAPersonRepositoryMoc.GetContext();
            var repository = new SchemaAPersonRepository(loggerMoc.Object, context);

            SchemaAPerson entity = new SchemaAPerson();

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

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

            record.Should().NotBeNull();
        }
예제 #3
0
        public async void Delete()
        {
            Mock <ILogger <SchemaAPersonRepository> > loggerMoc = SchemaAPersonRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SchemaAPersonRepositoryMoc.GetContext();
            var           repository     = new SchemaAPersonRepository(loggerMoc.Object, context);
            SchemaAPerson entity         = new SchemaAPerson();

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

            await repository.Delete(entity.Id);

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

            modifiedRecord.Should().BeNull();
        }
예제 #4
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <SchemaAPersonRepository> > loggerMoc = SchemaAPersonRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SchemaAPersonRepositoryMoc.GetContext();
            var           repository     = new SchemaAPersonRepository(loggerMoc.Object, context);
            SchemaAPerson entity         = new SchemaAPerson();

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

            await repository.Update(new SchemaAPerson());

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

            modifiedRecord.Should().NotBeNull();
        }