public void TestPurchaseQuantityIsAMultipleOfPackSize() { IZppSimulator zppSimulator = new global::Master40.SimulationMrp.impl.ZppSimulator(); zppSimulator.StartTestCycle(); IDbMasterDataCache dbMasterDataCache = ZppConfiguration.CacheManager.GetMasterDataCache(); IDbTransactionData persistedTransactionData = ZppConfiguration.CacheManager.ReloadTransactionData(); List <T_PurchaseOrderPart> tPurchaseOrderParts = persistedTransactionData .PurchaseOrderPartGetAll().GetAllAs <T_PurchaseOrderPart>(); foreach (var tPurchaseOrderPart in tPurchaseOrderParts) { M_ArticleToBusinessPartner articleToBusinessPartner = dbMasterDataCache.M_ArticleToBusinessPartnerGetAllByArticleId( new Id(tPurchaseOrderPart.ArticleId))[0]; Quantity multiplier = new Quantity(1); while (multiplier.GetValue() * articleToBusinessPartner.PackSize < tPurchaseOrderPart.Quantity) { multiplier.IncrementBy(new Quantity(1)); } Quantity expectedPurchaseQuantity = new Quantity(multiplier.GetValue() * articleToBusinessPartner.PackSize); Assert.True(tPurchaseOrderPart.GetQuantity().Equals(expectedPurchaseQuantity), $"Quantity of PurchaseOrderPart ({tPurchaseOrderPart}) ist not a multiple of packSize."); } }
public void TestEveryOperationHasNeededMaterialAtStart(string testConfigurationFileName ) { InitTestScenario(testConfigurationFileName); IZppSimulator zppSimulator = new global::Master40.SimulationMrp.impl.ZppSimulator(); // TODO: set to true once dbPersist() has an acceptable time zppSimulator.StartTestCycle(false); // TODO: replace this by ReloadTransactionData() once shouldPersist is enabled IDbTransactionData dbTransactionData = global::Zpp.ZppConfiguration.CacheManager.GetDbTransactionData(); IAggregator aggregator = global::Zpp.ZppConfiguration.CacheManager.GetAggregator(); foreach (var operation in dbTransactionData.ProductionOrderOperationGetAll()) { Demands productionOrderBoms = aggregator.GetProductionOrderBomsBy(operation); foreach (var productionOrderBom in productionOrderBoms) { foreach (var stockExchangeProvider in aggregator.GetAllChildProvidersOf( productionOrderBom)) { Assert.True(operation.GetStartTime() >= stockExchangeProvider.GetEndTimeBackward().GetValue()); } } } }
private void InitThisTest(string testConfiguration) { InitTestScenario(testConfiguration); IZppSimulator zppSimulator = new global::Master40.SimulationMrp.impl.ZppSimulator(); zppSimulator.StartTestCycle(); }
public void TestTrackingOfObjects() { IZppSimulator zppSimulator = new global::Master40.SimulationMrp.impl.ZppSimulator(); zppSimulator.StartTestCycle(); string usedIdsFileName = IdGenerator.WriteToFile(); Assert.True(File.Exists(usedIdsFileName), $"Tracking created object hasn't worked: File '{usedIdsFileName}' was not created."); }
protected void InitThisTest(string testConfiguration) { InitTestScenario(testConfiguration); IZppSimulator zppSimulator = new global::Master40.SimulationMrp.impl.ZppSimulator(); // TODO: set to true once dbPersist() has an acceptable time and and enable ReloadTransactionData zppSimulator.StartPerformanceStudy(false); // IDbTransactionData dbTransactionData = // ZppConfiguration.CacheManager.ReloadTransactionData(); }
private void ExecutePerformanceStudy(string testConfigurationFileName, bool shouldPersist) { PerformanceMonitor performanceMonitor = new PerformanceMonitor(InstanceToTrack.Global); // int maxPossibleCops = int.MaxValue / 100; int maxPossibleCops = 1000; ZppConfiguration.CacheManager.ReadInTestConfiguration(testConfigurationFileName); ICentralPlanningConfiguration testConfiguration = ZppConfiguration.CacheManager.GetTestConfiguration(); int customerOrderCount = ZppConfiguration.CacheManager.GetTestConfiguration() .CustomerOrderPartQuantity; int customerOrderCountOriginal = customerOrderCount; int elapsedMinutes = 0; int cycles = testConfiguration.SimulationMaximumDuration / testConfiguration.SimulationInterval; string performanceLogLastCycles = "["; // n cycles here each cycle create & plan configured CustomerOrderPart while (customerOrderCount <= maxPossibleCops && elapsedMinutes < 5) { InitThisTest(testConfigurationFileName); IZppSimulator zppSimulator = new global::Master40.SimulationMrp.impl.ZppSimulator(); performanceMonitor.Start(); zppSimulator.StartPerformanceStudy(shouldPersist); performanceMonitor.Stop(); if (performanceLogLastCycles.Length > 1) { performanceLogLastCycles += ","; } performanceLogLastCycles += "{" + performanceMonitor.ToString(); long currentMemoryUsage = Process.GetCurrentProcess().WorkingSet64; performanceLogLastCycles += $"\"CurrentMemoryUsage\": \"{currentMemoryUsage}\"" + Environment.NewLine; performanceLogLastCycles += "}" + Environment.NewLine; customerOrderCount += customerOrderCountOriginal; testConfiguration.CustomerOrderPartQuantity = customerOrderCount; } // just for correct log name customerOrderCount -= customerOrderCountOriginal; testConfiguration.CustomerOrderPartQuantity = customerOrderCount; performanceLogLastCycles += "]"; string logType = $"_{testConfiguration.Name}_cycles_{cycles}_COs_{testConfiguration.CustomerOrderPartQuantity}_lastCycles"; ; DebuggingTools.WritePerformanceLog(performanceLogLastCycles, logType); }
public void TestMasterDataIsNotChangedByMrpRun() { List <int> countsMasterDataBefore = CountMasterData(); IZppSimulator zppSimulator = new global::Master40.SimulationMrp.impl.ZppSimulator(); zppSimulator.StartTestCycle(); // check certain constraints are not violated // masterData entities in db must not change within an MrpRun List <int> countsMasterDataAfter = CountMasterData(); Assert.True(countsMasterDataBefore.SequenceEqual(countsMasterDataAfter), $"MasterData has changed, which should not be modified by MrpRun: " + $"\nBefore: {String.Join(", ", countsMasterDataBefore)}" + $"\nAfter: {String.Join(", ", countsMasterDataAfter)}"); }
public void TestAllDemandsAreSatisfiedWithinProviderTable() { IZppSimulator zppSimulator = new global::Master40.SimulationMrp.impl.ZppSimulator(); zppSimulator.StartTestCycle(); IDbTransactionData dbTransactionData = ZppConfiguration.CacheManager.ReloadTransactionData(); Demands demands = dbTransactionData.DemandsGetAll(); Providers providers = dbTransactionData.ProvidersGetAll(); Demands unsatisfiedDemands = providers.CalculateUnsatisfiedDemands(demands); foreach (var unsatisfiedDemand in unsatisfiedDemands) { Assert.True(false, $"The demand {unsatisfiedDemand} should be satisfied, but it is NOT."); } }
public void TestAllDemandsAreInDemandToProviderTable() { IZppSimulator zppSimulator = new global::Master40.SimulationMrp.impl.ZppSimulator(); zppSimulator.StartTestCycle(); IDbTransactionData dbTransactionData = ZppConfiguration.CacheManager.ReloadTransactionData(); Demands allDbDemands = dbTransactionData.DemandsGetAll(); LinkDemandAndProviderTable demandToProviderTable = dbTransactionData.DemandToProviderGetAll(); foreach (var demand in allDbDemands) { bool isInDemandToProviderTable = demandToProviderTable.Contains(demand); Assert.True(isInDemandToProviderTable, $"Demand {demand} is NOT in demandToProviderTable."); } }
public void TestEveryQuantityOnArrowIsPositive() { IZppSimulator zppSimulator = new global::Master40.SimulationMrp.impl.ZppSimulator(); zppSimulator.StartTestCycle(); IDbTransactionData dbTransactionData = ZppConfiguration.CacheManager.ReloadTransactionData(); List <ILinkDemandAndProvider> demandAndProviderLinks = new List <ILinkDemandAndProvider>(); demandAndProviderLinks.AddRange(dbTransactionData.DemandToProviderGetAll()); demandAndProviderLinks.AddRange(dbTransactionData.ProviderToDemandGetAll()); foreach (var demandAndProviderLink in demandAndProviderLinks) { Assert.False( demandAndProviderLink.GetQuantity().IsNegative() || demandAndProviderLink.GetQuantity().IsNull(), $"A quantity on arrow ({demandAndProviderLink}) cannot be negative or null."); } }
public void TestParentsDueTimeIsGreaterThanOrEqualToChildsDueTime( string testConfigurationFileName) { // init InitTestScenario(testConfigurationFileName); IZppSimulator zppSimulator = new global::Master40.SimulationMrp.impl.ZppSimulator(); // TODO: set to true once dbPersist() has an acceptable time zppSimulator.StartTestCycle(false); // TODO: replace this by ReloadTransactionData() once shouldPersist is enabled global::Zpp.ZppConfiguration.CacheManager.GetDbTransactionData(); OrderOperationGraph orderOperationGraph = new OrderOperationGraph(); foreach (var graphNode in orderOperationGraph.GetNodes()) { INode node = graphNode.GetNode(); INodes successors = orderOperationGraph.GetSuccessorNodes(node); if (successors != null) { foreach (var successor in successors) { if (node.GetEntity().GetType() == typeof(CustomerOrderPart)) { continue; } Assert.True( node.GetEntity().GetStartTimeBackward() .IsGreaterThanOrEqualTo(successor.GetEntity().GetEndTimeBackward()), "Parent's StartTimeBackward must be greater or equal to than child's EndTimeBackward."); } } } }