Beispiel #1
0
        public void LoadAllFromString()
        {
            var content = @"apiVersion: v1
kind: Pod
metadata:
  name: foo
---
apiVersion: v1
kind: Namespace
metadata:
  name: ns";

            var types = new Dictionary <String, Type>();

            types.Add("v1/Pod", typeof(V1Pod));
            types.Add("v1/Namespace", typeof(V1Namespace));

            var objs = Yaml.LoadAllFromString(content, types);

            Assert.Equal(2, objs.Count);
            Assert.IsType <V1Pod>(objs[0]);
            Assert.IsType <V1Namespace>(objs[1]);
            Assert.Equal("foo", ((V1Pod)objs[0]).Metadata.Name);
            Assert.Equal("ns", ((V1Namespace)objs[1]).Metadata.Name);
        }
Beispiel #2
0
        public void LoadAllFromString()
        {
            var content = @"apiVersion: v1
kind: Pod
metadata:
  name: foo
---
apiVersion: v1
kind: Namespace
metadata:
  name: ns";

            var objs = Yaml.LoadAllFromString(content);

            Assert.Equal(2, objs.Count);
            Assert.IsType <V1Pod>(objs[0]);
            Assert.IsType <V1Namespace>(objs[1]);
            Assert.Equal("foo", ((V1Pod)objs[0]).Metadata.Name);
            Assert.Equal("ns", ((V1Namespace)objs[1]).Metadata.Name);
        }
Beispiel #3
0
        public void LoadAllFromStringWithAdditionalProperties()
        {
            var content = @"apiVersion: v1
kind: Pod
metadata:
  name: foo
  namespace: ns
  youDontKnow: Me
---
apiVersion: v1
kind: Namespace
metadata:
  name: ns
  youDontKnow: Me";

            var objs = Yaml.LoadAllFromString(content);

            Assert.Equal(2, objs.Count);
            Assert.IsType <V1Pod>(objs[0]);
            Assert.IsType <V1Namespace>(objs[1]);
            Assert.Equal("foo", ((V1Pod)objs[0]).Metadata.Name);
            Assert.Equal("ns", ((V1Pod)objs[0]).Metadata.NamespaceProperty);
            Assert.Equal("ns", ((V1Namespace)objs[1]).Metadata.Name);
        }