Пример #1
0
        public async void Create()
        {
            Mock <ILogger <CultureRepository> > loggerMoc = CultureRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = CultureRepositoryMoc.GetContext();
            var repository = new CultureRepository(loggerMoc.Object, context);

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

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

            record.Should().NotBeNull();
        }
Пример #2
0
        public async void Get()
        {
            Mock <ILogger <CultureRepository> > loggerMoc = CultureRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = CultureRepositoryMoc.GetContext();
            var repository = new CultureRepository(loggerMoc.Object, context);

            Culture entity = new Culture();

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

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

            record.Should().NotBeNull();
        }
Пример #3
0
        public async void Delete()
        {
            Mock <ILogger <CultureRepository> > loggerMoc = CultureRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = CultureRepositoryMoc.GetContext();
            var     repository           = new CultureRepository(loggerMoc.Object, context);
            Culture entity = new Culture();

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

            await repository.Delete(entity.CultureID);

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

            modifiedRecord.Should().BeNull();
        }
Пример #4
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <CultureRepository> > loggerMoc = CultureRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = CultureRepositoryMoc.GetContext();
            var     repository           = new CultureRepository(loggerMoc.Object, context);
            Culture entity = new Culture();

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

            await repository.Update(new Culture());

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

            modifiedRecord.Should().NotBeNull();
        }