public void CanParseValidFlavorsJsonPayloadWithMultipleFlavors()
        {
            var validMultipleFlavorsJsonFixture = @"{{ ""flavors"": [ {0} ] }}";
            var firstFlavor = CreateFlavorSummaryJsonFixtrue("m1.tiny", "1", "http://server.com/flavors/1",
                                                             "http://server.com/v2/flavors/1");
            var secondFlavor = CreateFlavorSummaryJsonFixtrue("m1.small", "2", "http://server.com/flavors/2",
                                                              "http://server.com/v2/flavors/2");

            var validMultipleFlavorsJson = string.Format(validMultipleFlavorsJsonFixture,
                                                         string.Join(",", new List <string>()
            {
                firstFlavor, secondFlavor
            }));

            var converter = new ComputeFlavorPayloadConverter();
            var flavors   = converter.ConvertFlavors(validMultipleFlavorsJson).ToList();

            Assert.AreEqual(2, flavors.Count());
            var flv1 =
                flavors.First(o => string.Equals(o.Name, "m1.tiny", StringComparison.InvariantCultureIgnoreCase));
            var flv2 =
                flavors.First(o => string.Equals(o.Name, "m1.small", StringComparison.InvariantCultureIgnoreCase));

            Assert.IsNotNull(flv1);
            Assert.IsNotNull(flv2);

            Assert.AreEqual("1", flv1.Id);
            Assert.AreEqual(new Uri("http://server.com/flavors/1"), flv1.PermanentUri);
            Assert.AreEqual(new Uri("http://server.com/v2/flavors/1"), flv1.PublicUri);

            Assert.AreEqual("2", flv2.Id);
            Assert.AreEqual(new Uri("http://server.com/flavors/2"), flv2.PermanentUri);
            Assert.AreEqual(new Uri("http://server.com/v2/flavors/2"), flv2.PublicUri);
        }
        public void CanParseAnEmptyFlavorsPayload()
        {
            var payload = string.Empty;

            var converter  = new ComputeFlavorPayloadConverter();
            var containers = converter.ConvertFlavors(payload).ToList();

            Assert.AreEqual(0, containers.Count());
        }
        public void CanParseValidFlavorsPayloadWithEmptyJsonArray()
        {
            var emptyJsonArray = @"{ ""flavors"": [ ] }";

            var converter  = new ComputeFlavorPayloadConverter();
            var containers = converter.ConvertFlavors(emptyJsonArray).ToList();

            Assert.AreEqual(0, containers.Count());
        }
 public void CannotParseInvalidFlavorsPayload()
 {
     var converter = new ComputeFlavorPayloadConverter();
     converter.ConvertFlavors("NOT JSON");
 }
 public void CannotParseInvalidFlavorsJsonPayload()
 {
     var converter = new ComputeFlavorPayloadConverter();
     converter.ConvertFlavors("[ { \"SomeAtrib\" }]");
 }
 public void CannotParseANullFlavorsPayload()
 {
     var converter = new ComputeFlavorPayloadConverter();
     converter.ConvertFlavors(null);
 }
        public void CanParseAnEmptyFlavorsPayload()
        {
            var payload = string.Empty;

            var converter = new ComputeFlavorPayloadConverter();
            var containers = converter.ConvertFlavors(payload).ToList();

            Assert.AreEqual(0, containers.Count());
        }
        public void CanParseValidFlavorsPayloadWithEmptyJsonArray()
        {
            var emptyJsonArray = @"{ ""flavors"": [ ] }";

            var converter = new ComputeFlavorPayloadConverter();
            var containers = converter.ConvertFlavors(emptyJsonArray).ToList();

            Assert.AreEqual(0, containers.Count());
        }
        public void CanConvertValidFlavorsJsonPayloadWithSingleFlavor()
        {
            var validFlavorsJsonFixture = @"{{ ""flavors"": [ {0} ] }}";
            var firstFlavor = CreateFlavorSummaryJsonFixtrue("m1.tiny", "1", "http://server.com/flavors/1",
                "http://server.com/v2/flavors/1");
            var validMultipleFlavorsJson = string.Format(validFlavorsJsonFixture, firstFlavor);

            var converter = new ComputeFlavorPayloadConverter();
            var flavors = converter.ConvertFlavors(validMultipleFlavorsJson).ToList();

            Assert.AreEqual(1, flavors.Count());
            var flv1 =
                flavors.First(o => string.Equals(o.Name, "m1.tiny", StringComparison.InvariantCultureIgnoreCase));
           
            Assert.IsNotNull(flv1);

            Assert.AreEqual("1", flv1.Id);
            Assert.AreEqual(new Uri("http://server.com/flavors/1"), flv1.PermanentUri);
            Assert.AreEqual(new Uri("http://server.com/v2/flavors/1"), flv1.PublicUri);
        }
        public void CannotParseInvalidFlavorsPayload()
        {
            var converter = new ComputeFlavorPayloadConverter();

            converter.ConvertFlavors("NOT JSON");
        }
        public void CannotParseInvalidFlavorsJsonPayload()
        {
            var converter = new ComputeFlavorPayloadConverter();

            converter.ConvertFlavors("[ { \"SomeAtrib\" }]");
        }
        public void CannotParseANullFlavorsPayload()
        {
            var converter = new ComputeFlavorPayloadConverter();

            converter.ConvertFlavors(null);
        }