Esempio n. 1
0
        public void Should_return_false_if_input_contains_not_valid_chars(string value)
        {
            var @namespace = string.Format(Template, value, "RootManageSharedAccessKey", "YourSecret");

            var isValid = ConnectionStringInternal.TryParse(@namespace, out var connectionString);

            Assert.IsFalse(isValid);
            Assert.Null(connectionString);
        }
Esempio n. 2
0
        public void Should_return_true_if_input_follows_namespace_name_rules(string value)
        {
            var @namespace = string.Format(Template, value, "RootManageSharedAccessKey", "YourSecret");

            var isValid = ConnectionStringInternal.TryParse(@namespace, out var connectionString);

            Assert.True(isValid);
            Assert.NotNull(connectionString);
        }
Esempio n. 3
0
        public void Should_not_equal_on_absence_of_sas_in_one()
        {
            ConnectionStringInternal.TryParse("Endpoint=sb://namespacename.servicebus.windows.net", out var connectionString1);
            ConnectionStringInternal.TryParse("Endpoint=sb://namespacename.servicebus.windows.net;SharedAccessKeyName=name;SharedAccessKey=key", out var connectionString2);

            var areEqual = connectionString1.Equals(connectionString2);

            Assert.IsFalse(areEqual);
        }
Esempio n. 4
0
        public void Should_return_false_if_input_does_not_finish_with_a_letter_or_a_number()
        {
            var @namespace = string.Format(Template, "abcdef-", "RootManageSharedAccessKey", "YourSecret");

            var isValid = ConnectionStringInternal.TryParse(@namespace, out var connectionString);

            Assert.IsFalse(isValid);
            Assert.Null(connectionString);
        }
Esempio n. 5
0
        public void Two_connection_strings_are_different_if_one_of_them_is_null()
        {
            var @namespace = string.Format(Template, "namespace", "RootManageSharedAccessKey", "YourSecret");

            var connectionString = new ConnectionStringInternal(@namespace);
            var areEqual         = connectionString.Equals(null);

            Assert.False(areEqual);
        }
Esempio n. 6
0
        public void Should_equal_on_absence_of_sas_in_both()
        {
            ConnectionStringInternal.TryParse("Endpoint=sb://namespacename.servicebus.windows.net", out var connectionString1);
            ConnectionStringInternal.TryParse("Endpoint=sb://namespacename.servicebus.windows.net", out var connectionString2);

            var areEqual = connectionString1.Equals(connectionString2);

            Assert.IsTrue(areEqual);
        }
Esempio n. 7
0
        public void Should_extract_namespace_name_and_shared_access_policy_name_and_shared_access_policy_value()
        {
            var @namespace = string.Format(Template, "namespace", "RootManageSharedAccessKey", "YourSecret");

            var connectionString = new ConnectionStringInternal(@namespace);

            Assert.AreEqual("namespace", connectionString.NamespaceName);
            Assert.AreEqual("RootManageSharedAccessKey", connectionString.SharedAccessPolicyName);
            Assert.AreEqual("YourSecret", connectionString.SharedAccessPolicyValue);
        }
Esempio n. 8
0
        public void Two_connection_strings_are_equal_if_shared_access_policy_values_are_equal_with_case_sensitive_check_and_other_components_are_the_same()
        {
            var namespace1 = string.Format(Template, "namespace", "RootManageSharedAccessKey", "YourSecret");
            var namespace2 = string.Format(Template, "namespace", "RootManageSharedAccessKey", "YourSecret");

            var connectionString1 = new ConnectionStringInternal(namespace1);
            var connectionString2 = new ConnectionStringInternal(namespace2);

            Assert.AreEqual(connectionString1, connectionString2);
        }
Esempio n. 9
0
        public void Two_connection_strings_are_different_if_shared_access_policy_values_are_differentwith_case_sensitive_check(string value1, string value2)
        {
            var namespace1 = string.Format(Template, "namespace", "RootManageSharedAccessKey", value1);
            var namespace2 = string.Format(Template, "namespace", "RootManageSharedAccessKey", value2);

            var connectionString1 = new ConnectionStringInternal(namespace1);
            var connectionString2 = new ConnectionStringInternal(namespace2);

            Assert.AreNotEqual(connectionString1, connectionString2);
        }
Esempio n. 10
0
        public void Two_connection_strings_are_different_if_shared_access_policy_names_are_different()
        {
            var namespace1 = string.Format(Template, "namespace", "RootManageSharedAccessKey1", "YourSecret");
            var namespace2 = string.Format(Template, "namespace", "RootManageSharedAccessKey2", "YourSecret");

            var connectionString1 = new ConnectionStringInternal(namespace1);
            var connectionString2 = new ConnectionStringInternal(namespace2);

            Assert.AreNotEqual(connectionString1, connectionString2);
        }
Esempio n. 11
0
        public void Two_connection_strings_have_the_same_hash_code_if_they_are_equal(string namespaceName1, string namespaceName2, string sharedAccessPolicyName1, string sharedAccessPolicyName2)
        {
            var namespace1 = string.Format(Template, namespaceName1, sharedAccessPolicyName1, "YourSecret");
            var namespace2 = string.Format(Template, namespaceName2, sharedAccessPolicyName2, "YourSecret");

            var connectionString1 = new ConnectionStringInternal(namespace1);
            var connectionString2 = new ConnectionStringInternal(namespace2);

            var hashCode1 = connectionString1.GetHashCode();
            var hashCode2 = connectionString2.GetHashCode();

            Assert.AreEqual(hashCode1, hashCode2);
        }
Esempio n. 12
0
        public void Should_be_able_to_parse_various_domain_names(string connectionStringString)
        {
            ConnectionStringInternal.TryParse(connectionStringString, out var connectionString);

            Assert.AreEqual("namespacename", connectionString.NamespaceName);
        }