Exemplo n.º 1
0
        public void Should_serialize_null()
        {
            var serialized   = EnvironmentNodeDataSerializer.Serialize(null);
            var deserialized = EnvironmentNodeDataSerializer.Deserialize(envName, serialized);

            deserialized.Should().BeEquivalentTo(new EnvironmentInfo(envName, null, null));
        }
Exemplo n.º 2
0
        public static byte[] SetEnvironmentProperties(string environment, Func <IEnvironmentInfoProperties, IEnvironmentInfoProperties> update, byte[] bytes)
        {
            var environmentInfo = EnvironmentNodeDataSerializer.Deserialize(environment, bytes);

            var newProperties = update(environmentInfo.Properties);

            return(EnvironmentNodeDataSerializer.Serialize(new EnvironmentInfo(environment, environmentInfo.ParentEnvironment, newProperties)));
        }
Exemplo n.º 3
0
        public async Task <bool> TryCreateEnvironmentAsync(IEnvironmentInfo environmentInfo)
        {
            var createRequest = new CreateRequest(pathHelper.BuildEnvironmentPath(environmentInfo.Environment), CreateMode.Persistent)
            {
                Data = EnvironmentNodeDataSerializer.Serialize(environmentInfo)
            };

            return((await zooKeeperClient.CreateAsync(createRequest).ConfigureAwait(false)).IsSuccessful);
        }
Exemplo n.º 4
0
        protected void CreateEnvironmentNode(string environment, string parent = null, IReadOnlyDictionary <string, string> properties = null)
        {
            var info = new EnvironmentInfo(environment, parent, properties);
            var data = EnvironmentNodeDataSerializer.Serialize(info);

            var path = PathHelper.BuildEnvironmentPath(environment);

            CreateOrUpdate(path, data);
        }
Exemplo n.º 5
0
 public void Should_serialize_and_deserialize(string parent)
 {
     foreach (var properties in TestProperties())
     {
         var info         = new EnvironmentInfo(envName, parent, properties);
         var serialized   = EnvironmentNodeDataSerializer.Serialize(info);
         var deserialized = EnvironmentNodeDataSerializer.Deserialize(envName, serialized);
         deserialized.Should().BeEquivalentTo(info);
     }
 }
Exemplo n.º 6
0
        public static byte[] SetEnvironmentParent(string environment, string newParent, byte[] bytes)
        {
            var environmentInfo = EnvironmentNodeDataSerializer.Deserialize(environment, bytes);

            return(EnvironmentNodeDataSerializer.Serialize(new EnvironmentInfo(environment, newParent, environmentInfo.Properties)));
        }