public void GetListFromCredentials_ThrowsWhenListNotPossible() { var credentials = new Dictionary <string, Credential>() { { "foo", new Credential() { { "bar", new Credential() { { "bang", new Credential("badabing") } } }, } } }; var tags = new Tags(new string[] { "foo", "bar" }); var scheme = "scheme"; var sif = new TestServiceInfoFactory(tags, scheme); var ex = Assert.Throws <ConnectorException>(() => sif.GetListFromCredentials(credentials, "foo")); Assert.Contains("key=foo", ex.Message); Assert.Contains("value=bar/", ex.Message); }
public void GetUriFromCredentials_ReturnsCorrect() { var credentials = new Dictionary <string, Credential>() { { "uri", new Credential("https://boo:222") } }; var tags = new Tags(new string[] { "foo", "bar" }); var scheme = "scheme"; var sif = new TestServiceInfoFactory(tags, scheme); var uri = sif.GetUriFromCredentials(credentials); Assert.Equal("https://boo:222", uri); credentials = new Dictionary <string, Credential>() { { "url", new Credential("https://boo:222") } }; uri = sif.GetUriFromCredentials(credentials); Assert.Equal("https://boo:222", uri); credentials = new Dictionary <string, Credential>() { }; uri = sif.GetUriFromCredentials(credentials); Assert.Null(uri); }
public void GetHostFromCredentials_ReturnsCorrect() { var credentials = new Dictionary <string, Credential>() { { "host", new Credential("host") } }; var tags = new Tags(new string[] { "foo", "bar" }); var scheme = "scheme"; var sif = new TestServiceInfoFactory(tags, scheme); var host = sif.GetHostFromCredentials(credentials); Assert.Equal("host", host); credentials = new Dictionary <string, Credential>() { { "hostname", new Credential("hostname") } }; host = sif.GetHostFromCredentials(credentials); Assert.Equal("hostname", host); credentials = new Dictionary <string, Credential>() { }; host = sif.GetHostFromCredentials(credentials); Assert.Null(host); }
public void GetIntFromCredentials_ThrowsFormatException() { var credentials = new Dictionary <string, Credential>() { { "key", new Credential("foobar") } }; var tags = new Tags(new string[] { "foo", "bar" }); var scheme = "scheme"; var sif = new TestServiceInfoFactory(tags, scheme); var ex = Assert.Throws <FormatException>(() => sif.GetIntFromCredentials(credentials, "key")); }
public void TagsMatch_DoesntMatch() { var tags = new Tags(new string[] { "foo", "bar" }); var scheme = "scheme"; var sif = new TestServiceInfoFactory(tags, scheme); var service1 = new Service() { Tags = new string[] { "noMatch" } }; Assert.False(sif.TagsMatch(service1)); }
public void LabelStartsWithTag_DoesntMatch() { var tags = new Tags(new string[] { "foo", "bar" }); var scheme = "scheme"; var sif = new TestServiceInfoFactory(tags, scheme); var service1 = new Service() { Tags = new string[] { "noMatch" }, Label = "baby" }; Assert.False(sif.LabelStartsWithTag(service1)); }
public void UriMatchesScheme_Matches() { var tags = new Tags(new string[] { "foo", "bar" }); var scheme = "scheme"; var sif = new TestServiceInfoFactory(tags, scheme); var service1 = new Service() { Tags = new string[] { "noMatch" }, Label = "noMatch", Credentials = new Dictionary <string, Credential>() { { "uri", new Credential("scheme://foo") } } }; Assert.True(sif.UriMatchesScheme(service1)); }
public void GetPortFromCredentials_ReturnsCorrect() { var credentials = new Dictionary <string, Credential>() { { "port", new Credential("123") } }; var tags = new Tags(new string[] { "foo", "bar" }); var scheme = "scheme"; var sif = new TestServiceInfoFactory(tags, scheme); var port = sif.GetPortFromCredentials(credentials); Assert.Equal(123, port); credentials = new Dictionary <string, Credential>() { }; port = sif.GetPortFromCredentials(credentials); Assert.Equal(0, port); }
public void GetPasswordFromCredentials_ReturnsCorrect() { var credentials = new Dictionary <string, Credential>() { { "password", new Credential("password") } }; var tags = new Tags(new string[] { "foo", "bar" }); var scheme = "scheme"; var sif = new TestServiceInfoFactory(tags, scheme); var pwd = sif.GetPasswordFromCredentials(credentials); Assert.Equal("password", pwd); credentials = new Dictionary <string, Credential>() { }; pwd = sif.GetPasswordFromCredentials(credentials); Assert.Null(pwd); }
public void GetListFromCredentials_ReturnsCorrect() { var credentials = new Dictionary <string, Credential>() { { "uris", new Credential() { { "0", new Credential("https://foo:11") }, { "1", new Credential("https://bar:11") } } } }; var tags = new Tags(new string[] { "foo", "bar" }); var scheme = "scheme"; var sif = new TestServiceInfoFactory(tags, scheme); var list = sif.GetListFromCredentials(credentials, "uris"); Assert.NotNull(list); Assert.Equal(2, list.Count); Assert.True(list[0].Equals("https://foo:11") || list[0].Equals("https://bar:11")); Assert.True(list[1].Equals("https://foo:11") || list[1].Equals("https://bar:11")); }