public async void Create() { Mock <ILogger <BusinessEntityContactRepository> > loggerMoc = BusinessEntityContactRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = BusinessEntityContactRepositoryMoc.GetContext(); var repository = new BusinessEntityContactRepository(loggerMoc.Object, context); var entity = new BusinessEntityContact(); await repository.Create(entity); var record = await context.Set <BusinessEntityContact>().FirstOrDefaultAsync(); record.Should().NotBeNull(); }
public async void Get() { Mock <ILogger <BusinessEntityContactRepository> > loggerMoc = BusinessEntityContactRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = BusinessEntityContactRepositoryMoc.GetContext(); var repository = new BusinessEntityContactRepository(loggerMoc.Object, context); BusinessEntityContact entity = new BusinessEntityContact(); context.Set <BusinessEntityContact>().Add(entity); await context.SaveChangesAsync(); var record = await repository.Get(entity.BusinessEntityID); record.Should().NotBeNull(); }
public async void Delete() { Mock <ILogger <BusinessEntityContactRepository> > loggerMoc = BusinessEntityContactRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = BusinessEntityContactRepositoryMoc.GetContext(); var repository = new BusinessEntityContactRepository(loggerMoc.Object, context); BusinessEntityContact entity = new BusinessEntityContact(); context.Set <BusinessEntityContact>().Add(entity); await context.SaveChangesAsync(); await repository.Delete(entity.BusinessEntityID); BusinessEntityContact modifiedRecord = await context.Set <BusinessEntityContact>().FirstOrDefaultAsync(); modifiedRecord.Should().BeNull(); }
public async void Update_Entity_Is_Not_Tracked() { Mock <ILogger <BusinessEntityContactRepository> > loggerMoc = BusinessEntityContactRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = BusinessEntityContactRepositoryMoc.GetContext(); var repository = new BusinessEntityContactRepository(loggerMoc.Object, context); BusinessEntityContact entity = new BusinessEntityContact(); context.Set <BusinessEntityContact>().Add(entity); await context.SaveChangesAsync(); await repository.Update(new BusinessEntityContact()); var modifiedRecord = context.Set <BusinessEntityContact>().FirstOrDefaultAsync(); modifiedRecord.Should().NotBeNull(); }