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