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

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

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

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

            Mutex entity = new Mutex();

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

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

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

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

            await repository.Delete(entity.Id);

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

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

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

            await repository.Update(new Mutex());

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

            modifiedRecord.Should().NotBeNull();
        }