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