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(); }
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."); }
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); }
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"); }
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."); }
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(); }
public ArticleCheck() { DataBase = Dbms.GetNewMasterDataBase(); MasterDBInitializerTruck.DbInitialize(context: DataBase.DbContext, resourceModelSize: ModelSize.Medium, setupModelSize: ModelSize.Medium, ModelSize.Small, 3, false); }
public ArticleCache() { _contextDataBase = Dbms.GetNewMasterDataBase(); InitializeTestModel(); }