Ejemplo n.º 1
0
        public void CannotConvertJsonPayloadWithMissingType()
        {
            var serviceDefPayload = @"{
                                        ""name"": ""Object Storage"",
                                        ""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 OpenStackServiceDefinitionPayloadConverter(new ServiceLocator());

            converter.Convert(serviceDefPayload);
        }
Ejemplo n.º 2
0
        public void CannotConvertNonObjectJsonPayload()
        {
            var serviceDefPayload = @"[]";

            var converter = new OpenStackServiceDefinitionPayloadConverter(new ServiceLocator());

            converter.Convert(serviceDefPayload);
        }
Ejemplo n.º 3
0
        public void CannotConvertJsonPayloadWithEmptyObject()
        {
            var serviceDefPayload = @" { }";

            var converter = new OpenStackServiceDefinitionPayloadConverter(new ServiceLocator());

            converter.Convert(serviceDefPayload);
        }
Ejemplo n.º 4
0
        public void CannotConvertInvalidJsonPayload()
        {
            var serviceDefPayload = @" { NOT JSON";

            var converter = new OpenStackServiceDefinitionPayloadConverter(new ServiceLocator());

            converter.Convert(serviceDefPayload);
        }
Ejemplo n.º 5
0
        public void CannotConvertJsonPayloadWithMissingEndpoints()
        {
            var serviceDefPayload = @"{
                                        ""name"": ""Object Storage"",
                                        ""type"": ""object-store"",
                                    }";

            var converter = new OpenStackServiceDefinitionPayloadConverter(new ServiceLocator());

            converter.Convert(serviceDefPayload);
        }
Ejemplo n.º 6
0
        public void CanConvertJsonPayload()
        {
            var expectedName = "Object Storage";
            var expectedType = "object-store";

            var serviceDefPayload = @" {
                                        ""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 OpenStackServiceDefinitionPayloadConverter(new ServiceLocator());
            var service   = converter.Convert(serviceDefPayload);

            Assert.IsNotNull(service);
            Assert.AreEqual(expectedName, service.Name);
            Assert.AreEqual(expectedType, service.Type);
            Assert.AreEqual(2, service.Endpoints.Count());
        }
        public void CanConvertJsonPayload()
        {
            var expectedName = "Object Storage";
            var expectedType = "object-store";

            var serviceDefPayload = @" {
                                        ""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 OpenStackServiceDefinitionPayloadConverter(new ServiceLocator());
            var service = converter.Convert(serviceDefPayload);

            Assert.IsNotNull(service);
            Assert.AreEqual(expectedName, service.Name);
            Assert.AreEqual(expectedType, service.Type);
            Assert.AreEqual(2, service.Endpoints.Count());
        }
Ejemplo n.º 8
0
        public void CannotConvertWithNullJsonPayload()
        {
            var converter = new OpenStackServiceDefinitionPayloadConverter(new ServiceLocator());

            converter.Convert(null);
        }
        public void CannotConvertJsonPayloadWithMissingType()
        {
            var serviceDefPayload = @"{
                                        ""name"": ""Object Storage"",
                                        ""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 OpenStackServiceDefinitionPayloadConverter(new ServiceLocator());
            converter.Convert(serviceDefPayload);
        }
        public void CannotConvertNonObjectJsonPayload()
        {
            var serviceDefPayload = @"[]";

            var converter = new OpenStackServiceDefinitionPayloadConverter(new ServiceLocator());
            converter.Convert(serviceDefPayload);
        }
        public void CannotConvertInvalidJsonPayload()
        {
            var serviceDefPayload = @" { NOT JSON";

            var converter = new OpenStackServiceDefinitionPayloadConverter(new ServiceLocator());
            converter.Convert(serviceDefPayload);
        }
 public void CannotConvertWithNullJsonPayload()
 {
     var converter = new OpenStackServiceDefinitionPayloadConverter(new ServiceLocator());
     converter.Convert(null);
 }
        public void CannotConvertJsonPayloadWithEmptyObject()
        {
            var serviceDefPayload = @" { }";

            var converter = new OpenStackServiceDefinitionPayloadConverter(new ServiceLocator());
            converter.Convert(serviceDefPayload);
        }
        public void CannotConvertJsonPayloadWithMissingEndpoints()
        {
            var serviceDefPayload = @"{
                                        ""name"": ""Object Storage"",
                                        ""type"": ""object-store"",
                                    }";

            var converter = new OpenStackServiceDefinitionPayloadConverter(new ServiceLocator());
            converter.Convert(serviceDefPayload);
        }