/// <summary> /// Initializes a new instance of the <see cref="SimulationEngine"/> class. /// </summary> /// <param name="stationCount">The station count.</param> /// <param name="highwayLength">Length of the highway.</param> /// <param name="replications">The replications.</param> /// <param name="channels">The channels.</param> /// <param name="reserved">The reserved.</param> /// <param name="report">The report.</param> /// <param name="randomFactory">The random factory.</param> /// <param name="replicationFactory">The replication factory.</param> /// <param name="threadCount">The thread count. Create this many parallel threads to run concurrent replications in.</param> public SimulationEngine( uint stationCount, uint highwayLength, uint replications, uint channels, uint reserved, Action <object> report, IRandomFactory randomFactory, IReplicationFactory replicationFactory, uint threadCount ) { if (threadCount == 0) { throw new ArgumentException(Messages.CantRunWithNoWorkerThreads, "threadCount"); } _randomFactory = randomFactory; _replicationFactory = replicationFactory; _threadCount = threadCount; _stationCount = stationCount; _highwayLength = highwayLength; _replications = replications; _channels = channels; _reserved = reserved; _report = report; _bagOfTasks = new Dictionary <uint, Action <uint> >((int)replications); _totalCollectedData = new DataGatherer(0); }
public async Task Setup() { redisOne = new RedisInside.Redis(i => i.LogTo(item => Global.Logger.LogDebug(item)).WithPersistence()); redisTwo = new RedisInside.Redis(i => i.LogTo(item => Global.Logger.LogDebug(item)).WithPersistence()); await Task.Delay(500).ConfigureAwait(false); var config = XDocument.Load(Path.Combine(TestContext.CurrentContext.TestDirectory, @"Config\redis.config")).XmlDeserialize <RedisConfiguration>(); config.Endpoints[0].Port = ((IPEndPoint)redisOne.Endpoint).Port; linkOne = await new ModuleHelper(config).Provider.GetService <IAsyncServiceFactory <IRedisLink> >().GetService(true); config = XDocument.Load(Path.Combine(TestContext.CurrentContext.TestDirectory, @"Config\redis.config")).XmlDeserialize <RedisConfiguration>(); config.Endpoints[0].Port = ((IPEndPoint)redisTwo.Endpoint).Port; var provider = new ModuleHelper(config).Provider; linkTwo = await provider.GetService <IAsyncServiceFactory <IRedisLink> >().GetService(true); factory = provider.GetService <IReplicationFactory>(); linkOne.Multiplexer.Flush(); linkTwo.Multiplexer.Flush(); var data = linkOne.Database.ListRange(key); Assert.AreEqual(0, data.Length); // adding new record linkOne.Database.ListLeftPush(key, "Test"); data = linkOne.Database.ListRange(key); Assert.AreEqual(1, data.Length); // checking nothing in another database data = linkTwo.Database.ListRange(key); Assert.AreEqual(0, data.Length); }