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

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

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

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

            PurchaseOrderHeader entity = new PurchaseOrderHeader();

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

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

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

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

            await repository.Delete(entity.PurchaseOrderID);

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

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

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

            await repository.Update(new PurchaseOrderHeader());

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

            modifiedRecord.Should().NotBeNull();
        }