public void RemoveTags_then_remove_all_tags_should_remove_replica_property_key() { IApplicationInfoProperties properties = new TestApplicationInfoProperties(); var replica1 = "replica1"; var replica1Tags = new TagCollection { { "tag1", "value1" }, { "tag2", "value1" }, "tag3" }; properties = properties.AddReplicaTags(replica1, ReplicaTagKind.Ephemeral, replica1Tags); properties = properties.RemoveReplicaTags(replica1, ReplicaTagKind.Ephemeral, new List <string> { "tag3", "tag1" }); properties.GetTags().Should().BeEquivalentTo(new Dictionary <string, TagCollection> { { replica1, new TagCollection { { "tag2", "value1" } } } }); properties = properties.RemoveReplicaTags(replica1, ReplicaTagKind.Ephemeral, new List <string> { "tag2" }); properties.GetTags().Should().BeEmpty(); }
public void GetTags_should_return_persistent_tags_in_first_priority() { IApplicationInfoProperties properties = new TestApplicationInfoProperties(); var replica = "replica"; var persistentTags = new TagCollection { { "tag4", "v1" } }; properties = properties.AddReplicaTags(replica, ReplicaTagKind.Persistent, persistentTags); var ephemeralTags = new TagCollection { { "tag4", "v2" }, { "tag1", "v1" } }; properties = properties.AddReplicaTags(replica, ReplicaTagKind.Ephemeral, ephemeralTags); var expected = new TagCollection { { "tag4", "v1" }, { "tag1", "v1" } }; properties.GetTags().Should().BeEquivalentTo(new Dictionary <string, TagCollection> { { replica, new TagCollection { { "tag4", "v1" }, { "tag1", "v1" } } } }); properties.GetReplicaTags(replica).Should().BeEquivalentTo(expected); properties = properties.RemoveReplicaTags(replica, ReplicaTagKind.Persistent, new List <string> { "tag4" }); properties.GetTags().Should().BeEquivalentTo(new Dictionary <string, TagCollection> { { replica, ephemeralTags } }); properties.GetReplicaTags(replica).Should().BeEquivalentTo(ephemeralTags); }
public void RemoveTags_should_remove_given_replica_tags() { IApplicationInfoProperties properties = new TestApplicationInfoProperties(); var replica1 = "replica1"; var replica2 = "replica2"; var replica1Tags = new TagCollection { { "tag1", "value1" }, { "tag2", "value1" }, "tag3" }; var replica2Tags = new TagCollection { "tag4", { "tag5", "value3" }, "tag6" }; properties = properties.AddReplicaTags(replica1, ReplicaTagKind.Persistent, replica1Tags); properties = properties.AddReplicaTags(replica2, ReplicaTagKind.Persistent, replica2Tags); properties = properties.RemoveReplicaTags(replica1, ReplicaTagKind.Persistent, new List <string> { "tag3", "tag1" }); properties.GetReplicaTags(replica1).Should().BeEquivalentTo(new TagCollection { { "tag2", "value1" } }); properties.GetReplicaTags(replica2).Should().BeEquivalentTo(replica2Tags); }
public void RemoveTags_should_not_fail_with_empty_property_tags() { IApplicationInfoProperties properties = new TestApplicationInfoProperties(); var replica1 = "replica1"; properties = properties.RemoveReplicaTags(replica1, ReplicaTagKind.Persistent, new List <string> { "tag1", "tag2" }); properties.GetReplicaTags(replica1).Should().BeEmpty(); properties.GetTags().Should().BeEmpty(); }