public void CannotConvertInvalidJsonToMetadata()
        {
            var badJsonFixture = @"{ NOT JSON";

            var converter = new ComputeItemMetadataPayloadConverter();
            converter.Convert(badJsonFixture);
        }
        public void CannotConvertNonObjectJsonToMetadata()
        {
            var nonObjectJson = @"[]";

            var converter = new ComputeItemMetadataPayloadConverter();
            converter.Convert(nonObjectJson);
        }
        public void CannotConvertJsonPayloadEmptyObjectToMetadata()
        {
            var emptyObjectFixture = @"{ }";

            var converter = new ComputeItemMetadataPayloadConverter();
            converter.Convert(emptyObjectFixture);
        }
        public void CanConvertEmptyMetadataToJson()
        {
            var metadata = new Dictionary<string, string>();

            var converter = new ComputeItemMetadataPayloadConverter();
            var payload = converter.Convert(metadata);

            var jsonObj = JObject.Parse(payload);
            var metadataToken = jsonObj["metadata"];
            Assert.IsNotNull(metadataToken);
            Assert.AreEqual(0, metadataToken.Children().Count());
        }
        public void CanConvertJsonPayloadToMetadata()
        {
            var metadataPayload = @"{
                                        ""metadata"": {
                                            ""item1"": ""value1"",
                                            ""item2"": ""value2""
                                        }
                                    }";

            var converter = new ComputeItemMetadataPayloadConverter();
            var metadata = converter.Convert(metadataPayload);

            Assert.AreEqual(2, metadata.Count);
            Assert.IsTrue(metadata.ContainsKey("item1"));
            Assert.AreEqual("value1",metadata["item1"]);
            Assert.IsTrue(metadata.ContainsKey("item2"));
            Assert.AreEqual("value2", metadata["item2"]);
        }
        public void CanConvertSingleMetadataToJson()
        {
            var metadata = new Dictionary<string, string>() { { "item1", "value1" } };

            var converter = new ComputeItemMetadataPayloadConverter();
            var payload = converter.Convert(metadata);

            var jsonObj = JObject.Parse(payload);
            var metadataToken = jsonObj["metadata"];
            Assert.IsNotNull(metadataToken);
            Assert.AreEqual("value1", metadataToken["item1"]);
        }
 public void CannotConvertNullMetadataToJson()
 {
     IDictionary<string, string> metadata = null;
     var converter = new ComputeItemMetadataPayloadConverter();
     converter.Convert(metadata);
 }