示例#1
0
        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();
        }
示例#2
0
        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();
        }
示例#3
0
        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();
        }
示例#4
0
        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();
        }