public void Deserialize_BadJson() { // Arrange (propertySources array bad!) var environment = @" { 'name': 'testname', 'profiles': ['Production'], 'label': 'testlabel', 'version': 'testversion', 'propertySources': [ { 'name': 'source', 'source': { 'key1': 'value1', 'key2': 10 } } }"; ConfigServerConfigurationProvider provider = new ConfigServerConfigurationProvider(new ConfigServerClientSettings()); Stream stream = TestHelpers.StringToStream(environment); // Act and Assert ConfigEnvironment env = provider.Deserialize(stream); Assert.Null(env); }
public void Deserialize_BadJson() { // Arrange (propertySources array bad!) var environment = @" { ""name"": ""testname"", ""profiles"": [""Production""], ""label"": ""testlabel"", ""version"": ""testversion"", ""propertySources"": [ { ""name"": ""source"", ""source"": { ""key1"": ""value1"", ""key2"": 10 } } }"; ConfigServerConfigurationProvider provider = new ConfigServerConfigurationProvider(new ConfigServerClientSettings()); Stream stream = TestHelpers.StringToStream(environment); // Act and Assert ConfigEnvironment env = provider.Deserialize(stream); Assert.Null(env); }
public void Deserialize_EmptyStream() { // Arrange ConfigServerConfigurationProvider provider = new ConfigServerConfigurationProvider(new ConfigServerClientSettings()); MemoryStream stream = new MemoryStream(); // Act and Assert Assert.Null(provider.Deserialize(stream)); }
public void Deserialize_GoodJson() { // Arrange var environment = @" { 'name': 'testname', 'profiles': ['Production'], 'label': 'testlabel', 'version': 'testversion', 'propertySources': [ { 'name': 'source', 'source': { 'key1': 'value1', 'key2': 10 } } ] }"; IHostingEnvironment envir = new HostingEnvironment(); ConfigServerConfigurationProvider provider = new ConfigServerConfigurationProvider(new ConfigServerClientSettings(), envir); Stream stream = TestHelpers.StringToStream(environment); // Act and Assert ConfigEnvironment env = provider.Deserialize(stream); Assert.NotNull(env); Assert.Equal("testname", env.Name); Assert.NotNull(env.Profiles); Assert.Equal(1, env.Profiles.Count); Assert.Equal("testlabel", env.Label); Assert.Equal("testversion", env.Version); Assert.NotNull(env.PropertySources); Assert.Equal(1, env.PropertySources.Count); Assert.Equal("source", env.PropertySources[0].Name); Assert.NotNull(env.PropertySources[0].Source); Assert.Equal(2, env.PropertySources[0].Source.Count); Assert.Equal("value1", env.PropertySources[0].Source["key1"]); Assert.Equal((long)10, env.PropertySources[0].Source["key2"]); }
public void Deserialize_GoodJson() { // Arrange var environment = @" { ""name"": ""testname"", ""profiles"": [""Production""], ""label"": ""testlabel"", ""version"": ""testversion"", ""propertySources"": [ { ""name"": ""source"", ""source"": { ""key1"": ""value1"", ""key2"": 10 } } ] }"; ConfigServerConfigurationProvider provider = new ConfigServerConfigurationProvider(new ConfigServerClientSettings()); Stream stream = TestHelpers.StringToStream(environment); // Act and Assert ConfigEnvironment env = provider.Deserialize(stream); Assert.NotNull(env); Assert.Equal("testname", env.Name); Assert.NotNull(env.Profiles); Assert.Single(env.Profiles); Assert.Equal("testlabel", env.Label); Assert.Equal("testversion", env.Version); Assert.NotNull(env.PropertySources); Assert.Single(env.PropertySources); Assert.Equal("source", env.PropertySources[0].Name); Assert.NotNull(env.PropertySources[0].Source); Assert.Equal(2, env.PropertySources[0].Source.Count); Assert.Equal("value1", env.PropertySources[0].Source["key1"]); Assert.Equal(10L, env.PropertySources[0].Source["key2"]); }
public void Deserialize_GoodJson() { // Arrange var environment = @" { 'name': 'testname', 'profiles': ['Production'], 'label': 'testlabel', 'version': 'testversion', 'propertySources': [ { 'name': 'source', 'source': { 'key1': 'value1', 'key2': 10 } } ] }"; ConfigServerConfigurationProvider provider = new ConfigServerConfigurationProvider(); Stream stream = ConfigServerTestHelpers.StringToStream(environment); // Act and Assert Environment env = provider.Deserialize(stream); Assert.NotNull(env); Assert.Equal("testname", env.Name); Assert.NotNull(env.Profiles); Assert.Equal(1, env.Profiles.Count); Assert.Equal("testlabel", env.Label); Assert.Equal("testversion", env.Version); Assert.NotNull(env.PropertySources); Assert.Equal(1, env.PropertySources.Count); Assert.Equal("source", env.PropertySources[0].Name); Assert.NotNull(env.PropertySources[0].Source); Assert.Equal(2, env.PropertySources[0].Source.Count); Assert.Equal("value1", env.PropertySources[0].Source["key1"]); Assert.Equal((long)10, env.PropertySources[0].Source["key2"]); }
public void Deserialize_BadJson() { // Arrange (propertySources array bad!) var environment = @" { 'name': 'testname', 'profiles': ['Production'], 'label': 'testlabel', 'version': 'testversion', 'propertySources': [ { 'name': 'source', 'source': { 'key1': 'value1', 'key2': 10 } } }"; ConfigServerConfigurationProvider provider = new ConfigServerConfigurationProvider(); Stream stream = ConfigServerTestHelpers.StringToStream(environment); // Act and Assert Environment env = provider.Deserialize(stream); Assert.Null(env); }
public void Deserialize_EmptyStream() { // Arrange ConfigServerConfigurationProvider provider = new ConfigServerConfigurationProvider(); MemoryStream stream = new MemoryStream(); // Act and Assert Assert.Null(provider.Deserialize(stream)); }