示例#1
0
        public async void Create()
        {
            Mock <ILogger <ProductModelIllustrationRepository> > loggerMoc = ProductModelIllustrationRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = ProductModelIllustrationRepositoryMoc.GetContext();
            var repository = new ProductModelIllustrationRepository(loggerMoc.Object, context);

            var entity = new ProductModelIllustration();
            await repository.Create(entity);

            var record = await context.Set <ProductModelIllustration>().FirstOrDefaultAsync();

            record.Should().NotBeNull();
        }
示例#2
0
        public async void Get()
        {
            Mock <ILogger <ProductModelIllustrationRepository> > loggerMoc = ProductModelIllustrationRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = ProductModelIllustrationRepositoryMoc.GetContext();
            var repository = new ProductModelIllustrationRepository(loggerMoc.Object, context);

            ProductModelIllustration entity = new ProductModelIllustration();

            context.Set <ProductModelIllustration>().Add(entity);
            await context.SaveChangesAsync();

            var record = await repository.Get(entity.ProductModelID);

            record.Should().NotBeNull();
        }
示例#3
0
        public async void Delete()
        {
            Mock <ILogger <ProductModelIllustrationRepository> > loggerMoc = ProductModelIllustrationRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = ProductModelIllustrationRepositoryMoc.GetContext();
            var repository = new ProductModelIllustrationRepository(loggerMoc.Object, context);
            ProductModelIllustration entity = new ProductModelIllustration();

            context.Set <ProductModelIllustration>().Add(entity);
            await context.SaveChangesAsync();

            await repository.Delete(entity.ProductModelID);

            ProductModelIllustration modifiedRecord = await context.Set <ProductModelIllustration>().FirstOrDefaultAsync();

            modifiedRecord.Should().BeNull();
        }
示例#4
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <ProductModelIllustrationRepository> > loggerMoc = ProductModelIllustrationRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = ProductModelIllustrationRepositoryMoc.GetContext();
            var repository = new ProductModelIllustrationRepository(loggerMoc.Object, context);
            ProductModelIllustration entity = new ProductModelIllustration();

            context.Set <ProductModelIllustration>().Add(entity);
            await context.SaveChangesAsync();

            await repository.Update(new ProductModelIllustration());

            var modifiedRecord = context.Set <ProductModelIllustration>().FirstOrDefaultAsync();

            modifiedRecord.Should().NotBeNull();
        }