public void SetValueCornerCaseTest() { ModifiableBobConnectionParametersMock target = new ModifiableBobConnectionParametersMock(); target.SetValue("Host", null, false); Assert.Null(target.GetValue("Host", false)); target.SetValue("Host", "", false); Assert.Equal("", target.GetValue("Host", false)); target.SetValue("Host", " ", false); Assert.Equal(" ", target.GetValue("Host", false)); target.SetValue("User", null, false); Assert.Null(target.GetValue("User", false)); target.SetValue("User", "", false); Assert.Equal("", target.GetValue("User", false)); target.SetValue("User", " ", false); Assert.Equal(" ", target.GetValue("User", false)); target.SetValue("Password", null, false); Assert.Null(target.GetValue("Password", false)); target.SetValue("Password", "", false); Assert.Equal("", target.GetValue("Password", false)); target.SetValue("Password", " ", false); Assert.Equal(" ", target.GetValue("Password", false)); }
public void SetGetValueRoundtripTest(string key, string value, bool allowCustom, string expected = null) { ModifiableBobConnectionParametersMock target = new ModifiableBobConnectionParametersMock() { Host = "------", User = "******", Password = "******" }; target.SetValue(key, value, allowCustom); var result = target.GetValue(key, allowCustom); Assert.Equal(expected ?? value, result ?? ""); }
public void GetValueTest() { ModifiableBobConnectionParametersMock source = new ModifiableBobConnectionParametersMock() { Host = "localhost", Port = null, User = "******", Password = null, MaxReceiveMessageSize = 100500, MaxSendMessageSize = null, ConnectionTimeout = TimeSpan.Parse("12:00:00"), OperationTimeout = null } .WithCustomParam("Custom1", "Value1"); Assert.Equal("localhost", source.GetValue("Host", allowCustomParameters: true)); Assert.Null(source.GetValue("Port", allowCustomParameters: true)); Assert.Equal("localhost", source.GetValue("Address", allowCustomParameters: true)); Assert.Equal("localhost", source.GetValue("Server", allowCustomParameters: true)); Assert.Equal("user", source.GetValue("USER", allowCustomParameters: true)); Assert.Equal("user", source.GetValue("USER ID", allowCustomParameters: true)); Assert.Null(source.GetValue("Password", allowCustomParameters: true)); Assert.Equal("100500", source.GetValue("MaxReceiveMessageSize", allowCustomParameters: true)); Assert.Equal("100500", source.GetValue("MaxReceiveMessageLength", allowCustomParameters: true)); Assert.Null(source.GetValue("MaxSendMessageSize", allowCustomParameters: true)); Assert.Null(source.GetValue("MaxSendMessageLength", allowCustomParameters: true)); Assert.Equal("12:00:00", source.GetValue("ConnectionTimeout", allowCustomParameters: true)); Assert.Equal("12:00:00", source.GetValue("Connect Timeout", allowCustomParameters: true)); Assert.Null(source.GetValue("OperationTimeout", allowCustomParameters: true)); Assert.Equal("Value1", source.GetValue("Custom1", allowCustomParameters: true)); Assert.Throws <ArgumentException>(() => source.GetValue("Custom2", allowCustomParameters: true)); source.Port = 1000; Assert.Equal("localhost", source.GetValue("Host", allowCustomParameters: true)); Assert.Equal("1000", source.GetValue("Port", allowCustomParameters: true)); Assert.Equal("localhost:1000", source.GetValue("Address", allowCustomParameters: true)); }