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

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

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

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

            EventRelatedDocument entity = new EventRelatedDocument();

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

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

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

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

            await repository.Delete(entity.Id);

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

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

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

            await repository.Update(new EventRelatedDocument());

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

            modifiedRecord.Should().NotBeNull();
        }