示例#1
0
        public void CreateOrders()
        {
            long currentTime = 0;
            int  orderCount  = 100;

            var dataBase = Dbms.GetNewMasterDataBase(dbName: "Master40");

            var productIds = dataBase.DbContext.Articles.Include(x => x.ArticleType).Where(x => x.ArticleType.Name.Equals("Product")).Select(x => x.Id).ToList();
            var simConfig  = new SimulationCore.Environment.Configuration();

            simConfig.AddOption(new Seed(169));
            simConfig.AddOption(new OrderArrivalRate(0.015));
            simConfig.AddOption(new MinDeliveryTime(1920));
            simConfig.AddOption(new MaxDeliveryTime(2880));
            var _orderGenerator = new SimulationCore.Helper.DistributionProvider.OrderGenerator(simConfig, dataBase.DbContext, productIds);


            for (int i = 0; i < orderCount; i++)
            {
                var order = _orderGenerator.GetNewRandomOrder(time: currentTime);
                currentTime = order.CreationTime;
                if (order.CreationTime > 10080)
                {
                    break;
                }
                dataBase.DbContext.CustomerOrders.Add(order);
            }

            dataBase.DbContext.SaveChanges();
        }
示例#2
0
        public void TestDropNonExistingDatabase()
        {
            ProductionDomainContext productionDomainContext = Dbms.GetNewMasterDataBase().DbContext;

            bool wasDropped = Dbms.DropDatabase("bla",
                                                productionDomainContext.Database.GetDbConnection().ConnectionString);

            Assert.False(wasDropped, "Db could be dropped, although it doesn't exist.");
        }
示例#3
0
        public void AddExistingArticle()
        {
            _contextDataBase = Dbms.GetNewMasterDataBase();

            var _articleCache = new SimulationCore.Types.ArticleCache(connectionString: _contextDataBase.ConnectionString);
            var article       = _articleCache.GetArticleById(id: 10772, transitionFactor: 3);
            var article2      = _articleCache.GetArticleById(id: 10772, transitionFactor: 3);

            Assert.Equal(expected: article2.Name, actual: article.Name);
        }
示例#4
0
        public void AddArticleWithoutOperation()
        {
            _contextDataBase = Dbms.GetNewMasterDataBase();

            InitializeTestModel();
            var _articleCache = new SimulationCore.Types.ArticleCache(connectionString: _contextDataBase.ConnectionString);
            var article       = _articleCache.GetArticleById(id: 10456, transitionFactor: 3);

            Assert.Equal(actual: article.Name, expected: "Wheel");
        }
示例#5
0
        public void TestDropExistingDatabase()
        {
            ProductionDomainContext productionDomainContext = Dbms.GetNewMasterDataBase().DbContext;

            if (productionDomainContext.Database.CanConnect() == false)
            {
                productionDomainContext.Database.EnsureCreated();
            }

            productionDomainContext.Database.CloseConnection();

            bool wasDropped =
                Dbms.DropDatabase(productionDomainContext.Database.GetDbConnection().Database,
                                  productionDomainContext.Database.GetDbConnection().ConnectionString);

            Assert.True(wasDropped, "Db could not be dropped.");
            Assert.False(productionDomainContext.Database.CanConnect(),
                         "Can still connect to database.");
        }
示例#6
0
        public void InitByReadingFromDatabase(string testConfiguration, bool addInitialStockLevels)
        {
            _productionDomainContext        = Dbms.GetNewMasterDataBase().DbContext;
            _productionDomainContextArchive = Dbms.GetNewMasterDataBase(true).DbContext;

            InitDb(testConfiguration, _productionDomainContext, true);
            InitDb(testConfiguration, _productionDomainContextArchive, false);

            _dbMasterDataCache = new DbMasterDataCache(_productionDomainContext);
            // duplicate masterData for archive
            _dbMasterDataCache.Clone(_productionDomainContextArchive);

            _dbTransactionData        = new DbTransactionData(_productionDomainContext);
            _dbTransactionDataArchive = new DbTransactionData(_productionDomainContextArchive);

            if (addInitialStockLevels)
            {
                OpenDemandManager.AddInitialStockLevels(_dbTransactionData);
            }

            _aggregator        = new Aggregator(_dbTransactionData);
            _openDemandManager = new OpenDemandManager();
        }
示例#7
0
 public ArticleCheck()
 {
     DataBase = Dbms.GetNewMasterDataBase();
     MasterDBInitializerTruck.DbInitialize(context: DataBase.DbContext, resourceModelSize: ModelSize.Medium,
                                           setupModelSize: ModelSize.Medium, ModelSize.Small, 3, false);
 }
示例#8
0
        public ArticleCache()
        {
            _contextDataBase = Dbms.GetNewMasterDataBase();

            InitializeTestModel();
        }