Esempio n. 1
0
        public void TestGetImage()
        {
            IComputeProvider          provider = Bootstrapper.CreateComputeProvider();
            IEnumerable <ServerImage> images   = ListAllImagesWithDetails(provider);

            Assert.IsNotNull(images);
            if (!images.Any())
            {
                Assert.Inconclusive("The test could not proceed because the specified account and/or region does not appear to contain any images.");
            }

            foreach (ServerImage image in images)
            {
                Assert.IsNotNull(image);
                ServerImage details = provider.GetImage(image.Id);
                Assert.AreEqual(image.Created, details.Created);
                Assert.AreEqual(image.DiskConfig, details.DiskConfig);
                Assert.AreEqual(image.Id, details.Id);

                Assert.IsNotNull(details.Links);
                Assert.AreEqual(image.Links.Length, details.Links.Length);
                for (int i = 0; i < image.Links.Length; i++)
                {
                    // this could start to fail if the server reorders links; if that occurs the test should be rewritten to allow it
                    Assert.AreEqual(image.Links[i].Href, details.Links[i].Href);
                    Assert.AreEqual(image.Links[i].Rel, details.Links[i].Rel);
                }

                Assert.AreEqual(image.MinDisk, details.MinDisk);
                Assert.AreEqual(image.MinRAM, details.MinRAM);
                Assert.AreEqual(image.Name, details.Name);

                Assert.IsTrue(details.Progress >= 0 && details.Progress <= 100);

                if (image.Server != null)
                {
                    Assert.IsNotNull(details.Server);
                    Assert.AreEqual(image.Server.Id, details.Server.Id);
                }

                Assert.IsNotNull(details.Status);

                Assert.AreEqual(image.Updated, details.Updated);
            }
        }