コード例 #1
0
        public async void Create()
        {
            Mock <ILogger <SalesTerritoryHistoryRepository> > loggerMoc = SalesTerritoryHistoryRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SalesTerritoryHistoryRepositoryMoc.GetContext();
            var repository = new SalesTerritoryHistoryRepository(loggerMoc.Object, context);

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

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

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

            SalesTerritoryHistory entity = new SalesTerritoryHistory();

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

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

            record.Should().NotBeNull();
        }
コード例 #3
0
        public async void Delete()
        {
            Mock <ILogger <SalesTerritoryHistoryRepository> > loggerMoc = SalesTerritoryHistoryRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SalesTerritoryHistoryRepositoryMoc.GetContext();
            var repository = new SalesTerritoryHistoryRepository(loggerMoc.Object, context);
            SalesTerritoryHistory entity = new SalesTerritoryHistory();

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

            await repository.Delete(entity.BusinessEntityID);

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

            modifiedRecord.Should().BeNull();
        }
コード例 #4
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <SalesTerritoryHistoryRepository> > loggerMoc = SalesTerritoryHistoryRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SalesTerritoryHistoryRepositoryMoc.GetContext();
            var repository = new SalesTerritoryHistoryRepository(loggerMoc.Object, context);
            SalesTerritoryHistory entity = new SalesTerritoryHistory();

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

            await repository.Update(new SalesTerritoryHistory());

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

            modifiedRecord.Should().NotBeNull();
        }