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