Example #1
0
        public void Build_SingleNameAndBoolValue_ConnectionString()
        {
            var builder = ConnectionStringBuilder.New();

            builder.With("name", true);

            Assert.That(builder.Build(), Is.EqualTo("name=True"));
        }
Example #2
0
        public void Build_SingleName_ConnectionString()
        {
            var builder = ConnectionStringBuilder.New();

            builder.With("name", null);

            Assert.That(builder.Build(), Is.EqualTo("name"));
        }
Example #3
0
        public void With_ValueThatNeedsToBeEscaped_ConnectionString(string value)
        {
            var builder = ConnectionStringBuilder.New();

            builder.With("name", value);

            Assert.That(builder.Build(), Is.EqualTo($"name='{value}'"));
        }
Example #4
0
        public void Build_MultipleNamesAndValues_ConnectionString()
        {
            var builder =
                ConnectionStringBuilder.New()
                .With("name1", "value1")
                .With("name2", "value2");

            Assert.That(builder.Build(), Is.EqualTo("name1=value1;name2=value2"));
        }
Example #5
0
        public void Build_OverrideExistingNameAndValue_ConnectionString()
        {
            var builder =
                ConnectionStringBuilder.New()
                .With("name", "value")
                .With("Name", "VALUE");

            Assert.That(builder.Build(), Is.EqualTo("name=VALUE"));
        }
Example #6
0
        public void With_ValueHasIllegalCharacters_Throws()
        {
            var builder = ConnectionStringBuilder.New();

            Assert.Throws <ArgumentException>(() => builder.With("name", "value with illegal chars \r\n"));
        }
Example #7
0
        public void With_NameDoesNotStartWithLetter_Throws()
        {
            var builder = ConnectionStringBuilder.New();

            Assert.Throws <ArgumentException>(() => builder.With("1name", ""));
        }