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