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

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

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

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

            Release entity = new Release();

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

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

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

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

            await repository.Delete(entity.Id);

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

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

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

            await repository.Update(new Release());

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

            modifiedRecord.Should().NotBeNull();
        }