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(); }
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(); }
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(); }
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(); }