public void ToString_should_return_right_string_on_given_collection() { var collection = new TagCollection { { "tag1", "value1" }, { "tag2", "123" }, "tag3" }; collection.ToString().Should().Be("tag1═value1|tag2═123|tag3═true"); }
public void TestTagCollection() { var target = new TagCollection(new[] {"t1", "", ",", "t2"}); Assert.AreEqual("T1,T2", target.ToString()); var deserialized = TagCollection.FromString("T1,T2"); Assert.AreEqual(target.Count, deserialized.Count); Assert.AreEqual(target.First(), deserialized.First()); Assert.AreEqual(target.Last(), deserialized.Last()); Assert.IsNull(TagCollection.FromString(null)); }
public static IApplicationInfoProperties SetReplicaTags([NotNull] this IApplicationInfoProperties properties, [NotNull] string replicaName, ReplicaTagKind replicaTagKind, TagCollection tags) { var propertyKey = new TagsPropertyKey(replicaName, replicaTagKind.ToString()); if (properties.GetReplicaKindTags(propertyKey).Equals(tags)) { return(properties); } return(tags?.Count > 0 ? properties.Set(propertyKey.ToString(), tags.ToString()) : properties.Remove(propertyKey.ToString())); }
public void GetTags_should_not_returns_not_valid_tag_kinds() { IApplicationInfoProperties properties = new TestApplicationInfoProperties(); var replica = "replica"; var otherTags = new TagCollection { { "tag4", "v1" } }; properties = properties.Set(new TagsPropertyKey(replica, "other").ToString(), otherTags.ToString()); properties.GetTags().Should().BeEmpty(); properties.GetReplicaTags(replica).Should().BeEmpty(); var persistentTags = new TagCollection { { "tag", "value" } }; properties = properties.AddReplicaTags(replica, ReplicaTagKind.Persistent, persistentTags); properties.GetTags().Should().BeEquivalentTo(new Dictionary <string, TagCollection> { { replica, persistentTags } }); properties.GetReplicaTags(replica).Should().BeEquivalentTo(persistentTags); }