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