public void SubscriptionSet_derive_with_same_version_returns_existing_Set() { XDoc setDoc1 = new XDoc("subscription-set") .Attr("max-failures", 1) .Attr("version", 10) .Elem("uri.owner", "http://owner") .Start("subscription") .Attr("id", "456") .Elem("channel", "http://chanel") .Start("recipient").Attr("auth-token", "xyz").Elem("uri", "http://recipient").End() .End(); PubSubSubscriptionSet set1 = new PubSubSubscriptionSet(setDoc1); Assert.AreEqual(10, set1.Version); XDoc setDoc2 = new XDoc("subscription-set") .Attr("max-failures", 1) .Attr("version", 15) .Elem("uri.owner", "http://owner") .Start("subscription") .Attr("id", "456") .Elem("channel", "http://chanel") .Start("recipient").Attr("auth-token", "xyz").Elem("uri", "http://recipient").End() .End(); PubSubSubscriptionSet set2 = set1.Derive(setDoc2); Assert.AreEqual(15, set2.Version); Assert.AreNotSame(set1, set2); XDoc setDoc3 = new XDoc("subscription-set") .Attr("max-failures", 1) .Attr("version", 15) .Elem("uri.owner", "http://owner") .Start("subscription") .Attr("id", "456") .Elem("channel", "http://chanel") .Start("recipient").Attr("auth-token", "xyz").Elem("uri", "http://recipient").End() .End(); PubSubSubscriptionSet set3 = set2.Derive(setDoc3); Assert.AreEqual(15, set3.Version); Assert.AreSame(set2, set3); }
public void SubscriptionSet_derive_with_newer_version_always_creates_new_set() { var setDoc1 = new XDoc("subscription-set") .Attr("max-failures", 1) .Attr("version", 10) .Elem("uri.owner", "http://owner") .Start("subscription") .Attr("id", "456") .Elem("channel", "http://chanel") .Start("recipient").Attr("auth-token", "xyz").Elem("uri", "http://recipient").End() .End(); var set1 = new PubSubSubscriptionSet(setDoc1, "abc", "def"); var setDoc2 = new XDoc("subscription-set") .Attr("max-failures", 1) .Attr("version", 11) .Elem("uri.owner", "http://owner") .Start("subscription") .Attr("id", "456") .Elem("channel", "http://chanel") .Start("recipient").Attr("auth-token", "xyz").Elem("uri", "http://recipient").End() .End(); var set2 = set1.Derive(setDoc2, null); Assert.AreEqual(10, set1.Version); Assert.AreEqual(11, set2.Version); Assert.AreNotSame(set1, set2); Assert.AreEqual(set1.AccessKey, set2.AccessKey); }
public void SubscriptionSet_derive_with_no_version_always_creates_new_set() { XDoc setDoc1 = new XDoc("subscription-set") .Attr("max-failures", 1) .Attr("version", 10) .Elem("uri.owner", "http://owner") .Start("subscription") .Attr("id", "456") .Elem("channel", "http://chanel") .Start("recipient").Attr("auth-token", "xyz").Elem("uri", "http://recipient").End() .End(); PubSubSubscriptionSet set1 = new PubSubSubscriptionSet(setDoc1); Assert.AreEqual(10, set1.Version); XDoc setDoc2 = new XDoc("subscription-set") .Attr("max-failures", 1) .Elem("uri.owner", "http://owner") .Start("subscription") .Attr("id", "456") .Elem("channel", "http://chanel") .Start("recipient").Attr("auth-token", "xyz").Elem("uri", "http://recipient").End() .End(); PubSubSubscriptionSet set2 = set1.Derive(setDoc2); Assert.IsFalse(set2.Version.HasValue); Assert.AreNotSame(set1, set2); }
public void SubscriptionSet_derive_with_access_key_changes_accesskey() { var setDoc1 = new XDoc("subscription-set") .Attr("max-failures", 1) .Elem("uri.owner", "http://owner") .Start("subscription") .Attr("id", "456") .Elem("channel", "http://chanel") .Start("recipient").Attr("auth-token", "xyz").Elem("uri", "http://recipient").End() .End(); var set1 = new PubSubSubscriptionSet(setDoc1, "abc", "def"); var set2 = set1.Derive(setDoc1, "bob"); Assert.AreNotSame(set1, set2); Assert.AreNotEqual(set1.AccessKey, set2.AccessKey); }