Ejemplo n.º 1
0
        public void CanParseValidFlavorsJsonPayloadWithMultipleFlavors()
        {
            var validMultipleImagesJsonFixture = @"{{ ""images"": [ {0} ] }}";
            var firstImage = CreateImageSummaryJsonFixtrue("image1", "12345", "http://server.com/images/12345",
                                                           "http://server.com/v2/images/12345");
            var secondImage = CreateImageSummaryJsonFixtrue("image2", "23456", "http://server.com/images/23456",
                                                            "http://server.com/v2/images/23456");

            var validMultipleImagesJson = string.Format(validMultipleImagesJsonFixture,
                                                        string.Join(",", new List <string>()
            {
                firstImage, secondImage
            }));

            var converter = new ComputeImagePayloadConverter();
            var images    = converter.ConvertImages(validMultipleImagesJson).ToList();

            Assert.AreEqual(2, images.Count());
            var img1 =
                images.First(o => string.Equals(o.Name, "image1", StringComparison.InvariantCultureIgnoreCase));
            var img2 =
                images.First(o => string.Equals(o.Name, "image2", StringComparison.InvariantCultureIgnoreCase));

            Assert.IsNotNull(img1);
            Assert.IsNotNull(img2);

            Assert.AreEqual("12345", img1.Id);
            Assert.AreEqual(new Uri("http://server.com/images/12345"), img1.PermanentUri);
            Assert.AreEqual(new Uri("http://server.com/v2/images/12345"), img1.PublicUri);

            Assert.AreEqual("23456", img2.Id);
            Assert.AreEqual(new Uri("http://server.com/images/23456"), img2.PermanentUri);
            Assert.AreEqual(new Uri("http://server.com/v2/images/23456"), img2.PublicUri);
        }
Ejemplo n.º 2
0
        public void CanParseAnEmptyImagesPayload()
        {
            var payload = string.Empty;

            var converter  = new ComputeImagePayloadConverter();
            var containers = converter.ConvertImages(payload).ToList();

            Assert.AreEqual(0, containers.Count());
        }
Ejemplo n.º 3
0
        public void CanParseValidImagesPayloadWithEmptyJsonArray()
        {
            var emptyJsonArray = @"{ ""images"": [ ] }";

            var converter  = new ComputeImagePayloadConverter();
            var containers = converter.ConvertImages(emptyJsonArray).ToList();

            Assert.AreEqual(0, containers.Count());
        }
Ejemplo n.º 4
0
        public void CanConvertValidFlavorsJsonPayloadWithSingleFlavor()
        {
            var validImagesJsonFixture = @"{{ ""images"": [ {0} ] }}";
            var firstImage             = CreateImageSummaryJsonFixtrue("image1", "12345", "http://server.com/images/12345",
                                                                       "http://server.com/v2/images/12345");
            var validImagesJson = string.Format(validImagesJsonFixture, firstImage);

            var converter = new ComputeImagePayloadConverter();
            var images    = converter.ConvertImages(validImagesJson).ToList();

            Assert.AreEqual(1, images.Count());
            var img1 =
                images.First(o => string.Equals(o.Name, "image1", StringComparison.InvariantCultureIgnoreCase));

            Assert.IsNotNull(img1);

            Assert.AreEqual("12345", img1.Id);
            Assert.AreEqual(new Uri("http://server.com/images/12345"), img1.PermanentUri);
            Assert.AreEqual(new Uri("http://server.com/v2/images/12345"), img1.PublicUri);
        }
Ejemplo n.º 5
0
        public void CannotParseInvalidImagesPayload()
        {
            var converter = new ComputeImagePayloadConverter();

            converter.ConvertImages("NOT JSON");
        }
Ejemplo n.º 6
0
        public void CannotParseInvalidImagesJsonPayload()
        {
            var converter = new ComputeImagePayloadConverter();

            converter.ConvertImages("[ { \"SomeAtrib\" }]");
        }
Ejemplo n.º 7
0
        public void CannotParseANullImagesPayload()
        {
            var converter = new ComputeImagePayloadConverter();

            converter.ConvertImages(null);
        }