Exemplo n.º 1
0
        public void ClusterItemsSortingTest()
        {
            var value1 = "Object1";
            var value2 = "Object2";

            using (var cluster = new RangedCluster <object>())
            {
                cluster.Add(int.MinValue, value2);
                cluster.Add(int.MaxValue, value1);
                cluster.Add(int.MaxValue, new object());
                cluster.Add(0, new object());

                Assert.Equal(cluster.First().Value, value1);
                Assert.Equal(cluster.Last().Value, value2);
            }
        }
Exemplo n.º 2
0
        public async Task MultithreadClusterItemsSortingTest()
        {
            var tasks = new List <Task>();

            using (var cluster = new RangedCluster <int>())
            {
                for (var i = 0; i < 25; i++)
                {
                    var    tempI  = i;
                    Action action = () => _workWithClusterData(cluster, tempI);
                    tasks.Add(Task.Factory.StartNew(action));
                }

                await Task.WhenAll(tasks.ToArray());

                Assert.Equal(0, cluster.First().Value);
            }
        }