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

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

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

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

            Family entity = new Family();

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

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

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

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

            await repository.Delete(entity.Id);

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

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

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

            await repository.Update(new Family());

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

            modifiedRecord.Should().NotBeNull();
        }