public void ParseConnectionStringIntoTest(string connectionString, ModifiableBobConnectionParametersMock expected) { ModifiableBobConnectionParametersMock target = new ModifiableBobConnectionParametersMock(); BobConnectionStringParser.ParseConnectionStringInto(connectionString, target); Assert.Equal(expected, target); }
public void ParseConnectionStringIntoFormatExceptionTest(string connectionString) { Assert.Throws <FormatException>(() => { ModifiableBobConnectionParametersMock target = new ModifiableBobConnectionParametersMock(); BobConnectionStringParser.ParseConnectionStringInto(connectionString, target); }); }
public void ParseToStringRoundtripTest(string connectionString, ModifiableBobConnectionParametersMock data) { Assert.NotNull(connectionString); var stringRep = data.ToString(includePassword: true); var parsed = new ModifiableBobConnectionParametersMock(); BobConnectionStringParser.ParseConnectionStringInto(stringRep, parsed); Assert.Equal(data, parsed); }
/// <summary> /// <see cref="BobConnectionParametersBuilder"/> constructor from connection string /// </summary> /// <param name="connectionString">Connection string</param> public BobConnectionParametersBuilder(string connectionString) { if (connectionString == null) { throw new ArgumentNullException(nameof(connectionString)); } _customParameters = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); Host = string.Empty; BobConnectionStringParser.ParseConnectionStringInto(connectionString, this); }
public void BobConnectionStringParsingTest(string connectionString, ExpectedParsingResults parsingData) { if (parsingData.FormatException) { Assert.Throws <FormatException>(() => { BobConnectionStringParser.ParseConnectionStringIntoKeyValues(connectionString); }); } else { var parsedRes = BobConnectionStringParser.ParseConnectionStringIntoKeyValues(connectionString); Assert.Equal(parsingData.Pairs, parsedRes); } }