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

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

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

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

            BusinessEntity entity = new BusinessEntity();

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

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

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

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

            await repository.Delete(entity.BusinessEntityID);

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

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

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

            await repository.Update(new BusinessEntity());

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

            modifiedRecord.Should().NotBeNull();
        }