示例#1
0
        public async void Create()
        {
            Mock <ILogger <CountryRegionRepository> > loggerMoc = CountryRegionRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = CountryRegionRepositoryMoc.GetContext();
            var repository = new CountryRegionRepository(loggerMoc.Object, context);

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

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

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

            CountryRegion entity = new CountryRegion();

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

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

            record.Should().NotBeNull();
        }
示例#3
0
        public async void Delete()
        {
            Mock <ILogger <CountryRegionRepository> > loggerMoc = CountryRegionRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = CountryRegionRepositoryMoc.GetContext();
            var           repository     = new CountryRegionRepository(loggerMoc.Object, context);
            CountryRegion entity         = new CountryRegion();

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

            await repository.Delete(entity.CountryRegionCode);

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

            modifiedRecord.Should().BeNull();
        }
示例#4
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <CountryRegionRepository> > loggerMoc = CountryRegionRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = CountryRegionRepositoryMoc.GetContext();
            var           repository     = new CountryRegionRepository(loggerMoc.Object, context);
            CountryRegion entity         = new CountryRegion();

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

            await repository.Update(new CountryRegion());

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

            modifiedRecord.Should().NotBeNull();
        }