public async Task SystemTestAsync()
        {
            //InMemoryContext.LoadData(source: _masterDBContext, target: _ctx);

            var simContext = new AgentSimulation(DBContext: _masterDBContext, messageHub: new ConsoleHub());

            var simConfig = SimulationCore.Environment.Configuration.Create(args: new object[]
            {
                // set ResultDBString and set SaveToDB true
                new DBConnectionString(value: localresultdb)
                , new SimulationId(value: 1)
                , new SimulationNumber(value: simNr)
                , new SimulationKind(value: SimulationType.None)                                     // implements the used behaviour, if None --> DefaultBehaviour
                , new OrderArrivalRate(value: 0.025)
                , new OrderQuantity(value: 1)
                , new TransitionFactor(value: 3)
                , new EstimatedThroughPut(value: 600)
                , new DebugAgents(value: true)
                , new DebugSystem(value: false)
                , new KpiTimeSpan(value: 480)
                , new Seed(value: 1337)
                , new MinDeliveryTime(value: 1160)
                , new MaxDeliveryTime(value: 1600)
                , new TimePeriodForThrougputCalculation(value: 3840)
                , new SettlingStart(value: 2880)
                , new SimulationEnd(value: 20160)
                , new WorkTimeDeviation(value: 0.2)
                , new SaveToDB(value: false)
            });

            var simulation = await simContext.InitializeSimulation(configuration : simConfig);

            emtpyResultDBbySimulationNumber(simNr: simConfig.GetOption <SimulationNumber>());


            var simWasReady = false;

            if (simulation.IsReady())
            {
                // set for Assert
                simWasReady = true;
                // Start simulation
                var sim = simulation.RunAsync();

                AgentSimulation.Continuation(inbox: simContext.SimulationConfig.Inbox
                                             , sim: simulation
                                             , collectors: new List <IActorRef> {
                    simContext.StorageCollector
                    , simContext.WorkCollector
                    , simContext.ContractCollector
                });
                await sim;
            }

            Assert.True(condition: simWasReady);
        }
        public async Task RunAkkaSimulation(Configuration configuration)
        {
            _configuration = configuration;
            _messageHub.SendToAllClients(msg: "Prepare in Memory model from DB for Simulation: "
                                         + _configuration.GetOption <SimulationId>().Value.ToString()
                                         , msgType: MessageType.info);
            //In-memory database only exists while the connection is open
            //var _inMemory = InMemoryContext.CreateInMemoryContext();
            // InMemoryContext.LoadData(source: _context, target: _inMemory);
            //MasterDBInitializerSimple.DbInitialize(_inMemory);

            _messageHub.SendToAllClients(msg: "Prepare Simulation", msgType: MessageType.info);

            _agentSimulation = new AgentSimulation(DBContext: _context
                                                   , messageHub: _messageHub); // Defines the status output

            var simulation = _agentSimulation.InitializeSimulation(configuration: _configuration).Result;

            SimulationContext = simulation.SimulationContext;


            if (simulation.IsReady())
            {
                _messageHub.SendToAllClients(msg: "Start Simulation ...", msgType: MessageType.info);
                // Start simulation
                var sim = simulation.RunAsync();

                AgentSimulation.Continuation(inbox: _agentSimulation.SimulationConfig.Inbox
                                             , sim: simulation
                                             , collectors: new List <IActorRef> {
                    _agentSimulation.StorageCollector
                    , _agentSimulation.WorkCollector
                    , _agentSimulation.ContractCollector
                });
                await sim;
            }
            _messageHub.EndScheduler();
            _messageHub.EndSimulation(msg: "Simulation Completed."
                                      , simId: _configuration.GetOption <SimulationId>().Value.ToString()
                                      , simNumber: _configuration.GetOption <SimulationNumber>().Value.ToString());
            return;
        }