Akka.Cluster.Tests.MetricsGossipSpec.MetricsGossip_must_merge_an_existing_metric_set_for_a_node_and_update_node_ring C# (CSharp) Method

MetricsGossip_must_merge_an_existing_metric_set_for_a_node_and_update_node_ring() private method

        public void MetricsGossip_must_merge_an_existing_metric_set_for_a_node_and_update_node_ring()
        {
            var m1 = new NodeMetrics(new Address("akka.tcp", "sys", "a", 2554), StandardMetrics.NewTimestamp(),
                _collector.Sample().Metrics);
            var m2 = new NodeMetrics(new Address("akka.tcp", "sys", "a", 2555), StandardMetrics.NewTimestamp(),
                _collector.Sample().Metrics);
            var m3 = new NodeMetrics(new Address("akka.tcp", "sys", "a", 2556), StandardMetrics.NewTimestamp(),
                _collector.Sample().Metrics);
            var m2Updated = m2.Copy(metrics: _collector.Sample().Metrics, timestamp: m2.Timestamp + 1000);

            var g1 = MetricsGossip.Empty + m1 + m2;
            var g2 = MetricsGossip.Empty + m3 + m2Updated;
            Assert.True(g1.Nodes.All(x => x.Address == m1.Address || x.Address == m2.Address));

            //should contain nodes 1,3 and the most recent version of 2
            var mergedGossip = g1.Merge(g2);
            XAssert.Equivalent(mergedGossip.Nodes.Select(x => x.Address),
                new[] {m1.Address, m2.Address, m3.Address});
            mergedGossip.NodeMetricsFor(m1.Address).Metrics.ShouldBe(m1.Metrics);
            mergedGossip.NodeMetricsFor(m2.Address).Metrics.ShouldBe(m2Updated.Metrics);
            mergedGossip.NodeMetricsFor(m3.Address).Metrics.ShouldBe(m3.Metrics);
            Assert.True(mergedGossip.Nodes.All(x => x.Metrics.Count > 3));
            mergedGossip.NodeMetricsFor(m2.Address).Timestamp.ShouldBe(m2Updated.Timestamp);
        }