public void CannotConvertNonObjectJsonPayload() { var serviceDefPayload = @"[]"; var converter = new OpenStackServiceCatalogPayloadConverter(new ServiceLocator()); converter.Convert(serviceDefPayload); }
public void CannotConvertInvalidJsonPayload() { var serviceDefPayload = @" { NOT JSON"; var converter = new OpenStackServiceCatalogPayloadConverter(new ServiceLocator()); converter.Convert(serviceDefPayload); }
public void CannotConvertJsonPayloadWithEmptyObject() { var serviceDefPayload = @" { }"; var converter = new OpenStackServiceCatalogPayloadConverter(new ServiceLocator()); converter.Convert(serviceDefPayload); }
public void CannotConvertJsonPayloadWithMissingCatalog() { var serviceCatalogPayload = @"{ ""access"": { }}"; var converter = new OpenStackServiceCatalogPayloadConverter(new ServiceLocator()); converter.Convert(serviceCatalogPayload); }
public void CanConvertJsonPayload() { var expectedName = "Object Storage"; var expectedType = "object-store"; var serviceCatalogPayload = @"{ ""access"": { ""serviceCatalog"":[{ ""name"": ""Object Storage"", ""type"": ""object-store"", ""endpoints"": [ { ""tenantId"": ""10244656540440"", ""publicURL"": ""https://region-a.geo-1.objects.hpcloudsvc.com/v1/10244656540440"", ""region"": ""region-a.geo-1"", ""versionId"": ""1.0"", ""versionInfo"": ""https://region-a.geo-1.objects.hpcloudsvc.com/v1.0/"", ""versionList"": ""https://region-a.geo-1.objects.hpcloudsvc.com"" }, { ""tenantId"": ""10244656540440"", ""publicURL"": ""https://region-b.geo-1.objects.hpcloudsvc.com:443/v1/10244656540440"", ""region"": ""region-b.geo-1"", ""versionId"": ""1"", ""versionInfo"": ""https://region-b.geo-1.objects.hpcloudsvc.com:443/v1/"", ""versionList"": ""https://region-b.geo-1.objects.hpcloudsvc.com:443"" } ] }]}}"; var converter = new OpenStackServiceCatalogPayloadConverter(new ServiceLocator()); var serviceDefs = converter.Convert(serviceCatalogPayload).ToList(); Assert.AreEqual(1, serviceDefs.Count()); var service = serviceDefs.First(i => i.Name == expectedName); Assert.IsNotNull(service); Assert.AreEqual(expectedName, service.Name); Assert.AreEqual(expectedType, service.Type); Assert.AreEqual(2, service.Endpoints.Count()); }
public void CannotConvertWithNullJsonPayload() { var converter = new OpenStackServiceCatalogPayloadConverter(new ServiceLocator()); converter.Convert(null); }