Example #1
0
        public async void Create()
        {
            Mock <ILogger <SchemaBPersonRepository> > loggerMoc = SchemaBPersonRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SchemaBPersonRepositoryMoc.GetContext();
            var repository = new SchemaBPersonRepository(loggerMoc.Object, context);

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

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

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

            SchemaBPerson entity = new SchemaBPerson();

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

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

            record.Should().NotBeNull();
        }
Example #3
0
        public async void Delete()
        {
            Mock <ILogger <SchemaBPersonRepository> > loggerMoc = SchemaBPersonRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SchemaBPersonRepositoryMoc.GetContext();
            var           repository     = new SchemaBPersonRepository(loggerMoc.Object, context);
            SchemaBPerson entity         = new SchemaBPerson();

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

            await repository.Delete(entity.Id);

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

            modifiedRecord.Should().BeNull();
        }
Example #4
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <SchemaBPersonRepository> > loggerMoc = SchemaBPersonRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SchemaBPersonRepositoryMoc.GetContext();
            var           repository     = new SchemaBPersonRepository(loggerMoc.Object, context);
            SchemaBPerson entity         = new SchemaBPerson();

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

            await repository.Update(new SchemaBPerson());

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

            modifiedRecord.Should().NotBeNull();
        }