Exemplo n.º 1
0
        public void Transform_CanSerializeMap()
        {
            var map     = new List <IDictionary <string, object> >();
            var mapItem = new Dictionary <string, object>
            {
                { "A", "C" },
                { "B", "D" }
            };

            map.Add(mapItem);
            mapItem = new Dictionary <string, object>
            {
                { "A", "E" },
                { "B", "F" }
            };
            map.Add(mapItem);

            SortedDictionary <string, string> result = CloudStackAPIProxy.Transform(new Dictionary <string, object> {
                { "map", map }
            });

            result.ShouldContainKeyAndValue("map[0].A", "C");
            result.ShouldContainKeyAndValue("map[0].B", "D");
            result.ShouldContainKeyAndValue("map[1].A", "E");
            result.ShouldContainKeyAndValue("map[1].B", "F");
        }
Exemplo n.º 2
0
 public void Transform_NullDoesNotInclude()
 {
     CloudStackAPIProxy.Transform(new Dictionary <string, object> {
         { "foo", null }
     }).ShouldNotContainKey("foo");
     CloudStackAPIProxy.Transform(new Dictionary <string, object> {
         { "foo", (bool?)null }
     }).ShouldNotContainKey("foo");
 }
Exemplo n.º 3
0
        public void Transform_CanSerializeList()
        {
            var list = new List <string>
            {
                "A",
                "B",
                "C D"
            };
            SortedDictionary <string, string> result = CloudStackAPIProxy.Transform(new Dictionary <string, object> {
                { "lst", list }
            });

            result.ShouldContainKeyAndValue("lst", "A,B,C D");
        }
Exemplo n.º 4
0
        public void Transform_ConvertsValuesProperly()
        {
            // https://github.com/exoscale/cs/blob/8ea5b60fb43437309efcf444fc4ad679bc5c37cb/cs/client.py#L122
            var input = new Dictionary <string, object>
            {
                { "a", 1 },
                { "b", "foo" },
                { "c", new [] { "eggs", "spam" }.ToList() },
                { "d", new Dictionary <string, object> {
                      { "key", "value" }
                  } }
            };
            SortedDictionary <string, string> result = CloudStackAPIProxy.Transform(input);

            result.ShouldContainKeyAndValue("a", "1");
            result.ShouldContainKeyAndValue("b", "foo");
            result.ShouldContainKeyAndValue("c", "eggs,spam");
            result.ShouldContainKeyAndValue("d[0].key", "value");
        }
Exemplo n.º 5
0
 public void Transform_CanSerialise_String()
 {
     CloudStackAPIProxy.Transform(new Dictionary <string, object> {
         { "foo", "bar" }
     }).ShouldContainKeyAndValue("foo", "bar");
 }
Exemplo n.º 6
0
 public void Transform_CanSerialise_Guid()
 {
     CloudStackAPIProxy.Transform(new Dictionary <string, object> {
         { "foo", Guid.Empty }
     }).ShouldContainKeyAndValue("foo", "00000000-0000-0000-0000-000000000000");
 }