コード例 #1
0
        public void AddTagsFromException_SingleExceptionNoConflict_UnencryptedTagsAreSame()
        {
            var exception = new RequestException("", unencrypted: new Tags {
                { "ut1", "v1" }, { "ut2", "v2" }
            }).ThrowAndCatch();

            var encryptedTags   = exception.GetEncryptedTagsAndExtendedProperties();
            var unencryptedTags = exception.GetUnencryptedTags();

            CollectionAssert.IsEmpty(encryptedTags.Select(_ => _.Key));
            CollectionAssert.AreEquivalent(new[] { "ut1", "ut2" }, unencryptedTags.Select(_ => _.Key));
        }
コード例 #2
0
        public void AddTagsFromException_SingleExceptionWithConflict_MixedTagsAreMergedAndEncrypted()
        {
            var exception = new RequestException("", null, new Tags {
                { "et1", "v1" }, { "mix2", "v2" }
            }, new Tags {
                { "ut1", "v1" }, { "mix2", "v3" }
            }).ThrowAndCatch();

            var allTags = exception.GetEncryptedTagsAndExtendedProperties().Concat(exception.GetUnencryptedTags()).FormatTagsWithoutTypeSuffix().MergeDuplicateTags();

            CollectionAssert.AreEquivalent(new Tags {
                { "tags.et1", "v1" }, { "tags.ut1", "v1" }, { "tags.mix2", "v2\nv3" }
            }, allTags);
        }
コード例 #3
0
        public void AddTagsFromException_MultipleExceptionsWithConflict_UnencryptedSameKeyTagsAreMerged()
        {
            var innerException = new EnvironmentException("", unencrypted: new Tags {
                { "ut1", "v1b" }, { "ut3", "v3" }
            }).ThrowAndCatch();
            var exception = new RequestException("", innerException, unencrypted: new Tags {
                { "ut1", "v1a" }, { "ut2", "v2" }
            }).ThrowAndCatch();

            var unencryptedTags = exception.GetUnencryptedTags().FormatTagsWithoutTypeSuffix().MergeDuplicateTags();

            CollectionAssert.IsEmpty(exception.GetEncryptedTagsAndExtendedProperties());
            CollectionAssert.AreEquivalent(new Tags {
                { "tags.ut1", "v1a\nv1b" }, { "tags.ut2", "v2" }, { "tags.ut3", "v3" }
            }, unencryptedTags);
        }
コード例 #4
0
        public void AddTagsFromException_MultipleExceptionsWithConflict_MixedTagsAreMergedAndEncrypted()
        {
            var innerException = new EnvironmentException("", null, new Tags {
                { "et1", "v1b" }, { "mix1", "v2" }
            }, new Tags {
                { "ut1", "v1b" }, { "mix1", "v4" }
            }).ThrowAndCatch();
            var exception = new RequestException("", innerException, new Tags {
                { "et1", "v1a" }, { "mix1", "v1" }
            }, new Tags {
                { "ut1", "v1a" }, { "mix1", "v3" }
            }).ThrowAndCatch();

            var encryptedTags = exception.GetEncryptedTagsAndExtendedProperties().FormatTagsWithoutTypeSuffix().MergeDuplicateTags();
            var allTags       = exception.GetEncryptedTagsAndExtendedProperties().Concat(exception.GetUnencryptedTags()).FormatTagsWithoutTypeSuffix().MergeDuplicateTags();

            CollectionAssert.AreEquivalent(new[] { "tags.et1", "tags.mix1" }, encryptedTags.Select(_ => _.Key));
            CollectionAssert.AreEquivalent(new Tags {
                { "tags.et1", "v1a\nv1b" }, { "tags.ut1", "v1a\nv1b" }, { "tags.mix1", "v1\nv2\nv3\nv4" }
            }, allTags);
        }