Ejemplo n.º 1
0
        public static void CompareFederationUpdates(FederationUpdate expected, IList events, bool considerTopicChanges, bool considerPropertyChanges)
        {
            Assert.IsTrue(events.Count > 0, "Did not get any federation update events");

            FederationUpdate got = null;

            for (int i = 0; i < events.Count; i++)
            {
                if (i == 0)
                    got = (FederationUpdate)(events[i]);
                else
                    got.AddUpdatesFrom((FederationUpdate)(events[i]));
            }

            Assert.AreEqual(expected.FederationPropertiesChanged, got.FederationPropertiesChanged, "FederationPropertiesChanged  doesn't match");
            Assert.AreEqual(expected.NamespaceListChanged, got.NamespaceListChanged, "NamespaceListChanged doesn't match");

            if (considerTopicChanges)
            {
                // OK, look to see if/where got and expected topics are different; assert that they're the same
                foreach (AbsoluteTopicName t in expected.CreatedTopics)
                    Assert.IsTrue(got.CreatedTopics.Contains(t), "Missing created topic (" + t.FullnameWithVersion + ") from fired event(s)");
                Assert.AreEqual(expected.CreatedTopics.Count, got.CreatedTopics.Count, "Non-matching number of created topics");

                foreach (AbsoluteTopicName t in expected.UpdatedTopics)
                    Assert.IsTrue(got.UpdatedTopics.Contains(t), "Missing updated topic (" + t.FullnameWithVersion + ") from fired event(s)");
                Assert.AreEqual(expected.UpdatedTopics.Count, got.UpdatedTopics.Count, "Non-matching number of updated topics");

                foreach (AbsoluteTopicName t in expected.DeletedTopics)
                    Assert.IsTrue(got.DeletedTopics.Contains(t),"Missing deleted topic (" + t.FullnameWithVersion + ") from fired event(s)");
                Assert.AreEqual(expected.DeletedTopics.Count, got.DeletedTopics.Count,"Non-matching number of deleted topics");
            }

            if (considerPropertyChanges)
            {
                // Start by looking through the topics to be sure it's the expected set
                foreach (AbsoluteTopicName t in expected.AllTopicsWithChangedProperties)
                    Assert.IsTrue(got.AllTopicsWithChangedProperties.Contains(t), "Missing topic with property update(s) (" + t.FullnameWithVersion + ")");
                Assert.AreEqual(expected.AllTopicsWithChangedProperties.Count, got.AllTopicsWithChangedProperties.Count, "Non-matching number of topics with property updates");

                // OK, we have the right topics; let's check each one for the right set of properties and the right kind of changes
                foreach (AbsoluteTopicName t in expected.AllTopicsWithChangedProperties)
                {
                    // check added properties for the topic
                    ComparePropertyUpdatesForVerb(t, expected.AddedPropertiesForTopic(t), got.AddedPropertiesForTopic(t), "added");
                    ComparePropertyUpdatesForVerb(t, expected.ChangedPropertiesForTopic(t), got.ChangedPropertiesForTopic(t), "changed");
                    ComparePropertyUpdatesForVerb(t, expected.RemovedPropertiesForTopic(t), got.RemovedPropertiesForTopic(t), "removed");
                }
            }
        }