Exemple #1
0
        public void TryParse_FailsOnInvalidKeys(string key)
        {
            // Act
            CompositeTableKey tableKey;
            bool result = CompositeTableKey.TryParse(key, out tableKey);

            // Assert
            Assert.False(result);
            Assert.Null(tableKey);
        }
Exemple #2
0
        public void TryParse_SucceedsOnValidKeys(string key, string[] expectedSegments)
        {
            // Act
            CompositeTableKey tableKey;
            bool result = CompositeTableKey.TryParse(key, out tableKey);

            // Assert
            Assert.True(result);
            Assert.Equal(expectedSegments, tableKey.Segments);
        }
        protected virtual CompositeTableKey GetStorageKey(string id)
        {
            if (id == null)
            {
                throw new ArgumentNullException("id");
            }

            CompositeTableKey compositeKey;

            if (!CompositeTableKey.TryParse(id, out compositeKey) || compositeKey.Segments.Count != 2)
            {
                // We have either invalid, no keys, or too many keys
                string error = ASResources.StorageTable_InvalidKey.FormatForUser(id);
                throw new HttpResponseException(this.Request.CreateBadRequestResponse(error));
            }

            return(compositeKey);
        }
        protected virtual CompositeTableKey GetCompositeKey(string id)
        {
            if (id == null)
            {
                throw new ArgumentNullException("id");
            }

            CompositeTableKey compositeKey;

            if (CompositeTableKey.TryParse(id, out compositeKey))
            {
                return(compositeKey);
            }

            string error = EFResources.TableKeys_InvalidKey.FormatForUser(id);

            throw new HttpResponseException(this.Request.CreateNotFoundResponse(error));
        }