Exemple #1
0
        public async Task NormalRead()
        {
            _subSecretStore.ReadAsync(ServiceInstanceKey).Returns(SampleUtils.GetSampleContent(ServiceInstanceSampleFile));

            LocalObjectStore      localObjectStore = CreateLocalObjectStore();
            HealthServiceInstance serviceInstance  = await localObjectStore.ReadAsync <HealthServiceInstance>(ServiceInstanceKey);

            Assert.AreEqual("test", serviceInstance.Id);
            Assert.AreEqual("Test", serviceInstance.Name);
            Assert.AreEqual("description", serviceInstance.Description);
            Assert.AreEqual(new Uri("http://contoso.com"), serviceInstance.HealthServiceUrl);
            Assert.AreEqual(new Uri("http://contoso.com/shell"), serviceInstance.ShellUrl);
        }
        public async Task <T> ReadAsync <T>(string key)
        {
            if (string.IsNullOrEmpty(key))
            {
                throw new ArgumentException(Resources.ObjectStoreParametersEmpty);
            }

            var json = await _secretStore.ReadAsync(key).ConfigureAwait(false);

            if (json == null)
            {
                return(default(T));
            }

            return(JsonConvert.DeserializeObject <T>(json, SerializerSettings));
        }