public async Task CanDeleteImageMetadata() { var metadata = new Dictionary <string, string>() { { "item1", "value1" }, { "item2", "value2" } }; var created = DateTime.UtcNow.Subtract(TimeSpan.FromMinutes(10)); var updated = DateTime.UtcNow.Subtract(TimeSpan.FromMinutes(1)); var imageId = "12345"; var image = new ComputeImage(imageId, "tiny", new Uri("http://testcomputeendpoint.com/v2/1234567890/images/12345"), new Uri("http://testcomputeendpoint.com/1234567890/images/12345"), metadata, "ACTIVE", created, updated, 10, 512, 100); this.simulator.Images.Add(image); var client = new ComputeServiceRestClient(GetValidContext(), this.ServiceLocator); var resp = await client.DeleteImageMetadata(imageId, "item1"); Assert.AreEqual(HttpStatusCode.OK, resp.StatusCode); Assert.AreEqual(1, image.Metadata.Count); Assert.AreEqual("value2", image.Metadata["item2"]); }
private string GenerateImagePayload(ComputeImage image) { var payloadFixture = @"{{ ""image"" : {{ ""name"": ""{0}"", ""status"": ""{1}"", ""updated"": ""{2}"", ""created"": ""{3}"", ""minDisk"": {4}, ""progress"": {5}, ""minRam"": {6}, ""links"": [ {{ ""href"": ""{7}"", ""rel"": ""self"" }}, {{ ""href"": ""{8}"", ""rel"": ""bookmark"" }} ], ""id"": ""{9}"" }} }}"; return(string.Format(payloadFixture, image.Name, image.Status, image.CreateDate, image.LastUpdated, image.MinimumDiskSize, image.UploadProgress, image.MinimumRamSize, image.PublicUri.AbsoluteUri, image.PermanentUri.AbsoluteUri, image.Id)); }
public async Task CanGetImage() { var img1 = new ComputeImage("12345", "image1", new Uri("http://someuri.com/v2/images/12345"), new Uri("http://someuri.com/images/12345"), new Dictionary <string, string>(), "active", DateTime.Now, DateTime.Now, 10, 512, 100); this.ServicePocoClient.GetImageDelegate = (id) => { Assert.AreEqual("12345", id); return(Task.Factory.StartNew(() => img1)); }; var client = new ComputeServiceClient(GetValidCreds(), "Nova", CancellationToken.None, this.ServiceLocator); var image = await client.GetImage("12345"); Assert.IsNotNull(image); Assert.AreEqual(img1, image); }
public async Task CanGetImages() { var img1 = new ComputeImage("12345", "image1", new Uri("http://someuri.com/v2/images/12345"), new Uri("http://someuri.com/images/12345"), new Dictionary <string, string>(), "active", DateTime.Now, DateTime.Now, 10, 512, 100); var img2 = new ComputeImage("23456", "image2", new Uri("http://someuri.com/v2/images/23456"), new Uri("http://someuri.com/images/23456"), new Dictionary <string, string>(), "active", DateTime.Now, DateTime.Now, 10, 512, 100); var images = new List <ComputeImage>() { img1, img2 }; this.ServicePocoClient.GetImagesDelegate = () => Task.Factory.StartNew(() => (IEnumerable <ComputeImage>)images); var client = new ComputeServiceClient(GetValidCreds(), "Nova", CancellationToken.None, this.ServiceLocator); var resp = await client.GetImages(); Assert.IsNotNull(resp); var respImage = resp.ToList(); Assert.AreEqual(2, respImage.Count()); Assert.AreEqual(img1, respImage[0]); Assert.AreEqual(img2, respImage[1]); }