public PSStorageInsight(StorageInsight storageInsight, string resourceGroupName, string workspaceName)
        {
            if (storageInsight == null)
            {
                throw new ArgumentNullException("storageInsight");
            }

            this.ResourceGroupName = resourceGroupName;
            this.WorkspaceName = workspaceName;
            this.Name = storageInsight.Name;
            this.ResourceId = storageInsight.Id;

            if (storageInsight.Properties != null)
            {
                this.StorageAccountResourceId = storageInsight.Properties.StorageAccount != null ? storageInsight.Properties.StorageAccount.Id : null;
                this.Tables = storageInsight.Properties.Tables.ToList();
                this.Containers = storageInsight.Properties.Containers.ToList();
                this.State = storageInsight.Properties.Status != null ? storageInsight.Properties.Status.State : null;
            }
        }
Пример #2
0
        /// <summary>
        /// Validates a storage insight matches the expected properties.  Throws assertion exceptions if validation fails.
        /// </summary>
        /// <param name="expected">Expected storage insight</param>
        /// <param name="actual">Actual storage insight</param>
        internal static void ValidateStorageInsight(StorageInsight expected, StorageInsight actual)
        {
            Assert.NotNull(actual);
            Assert.NotNull(actual.Id);
            Assert.Equal(expected.Name, actual.Name);
            Assert.Equal(StorageInsightResourceType, actual.Type);
            if (expected.Tags != null)
            {
                Assert.Equal(expected.Tags.Count, actual.Tags.Count);
                foreach (var tag in expected.Tags)
                {
                    Assert.True(actual.Tags.Contains(tag));
                }
            }
            else
            {
                Assert.Null(actual.Tags);
            }

            Assert.NotNull(actual.Properties);
            Assert.Equal("OK", actual.Properties.Status.State);
            Assert.Equal(expected.Properties.StorageAccount.Id, actual.Properties.StorageAccount.Id);
            Assert.Null(actual.Properties.StorageAccount.Key);

            if (expected.Properties.Containers != null)
            {
                Assert.Equal(expected.Properties.Containers.Count, actual.Properties.Containers.Count);
                foreach (var container in expected.Properties.Containers)
                {
                    Assert.Contains(container, actual.Properties.Containers);
                }
            }
            else
            {
                Assert.Empty(actual.Properties.Containers);
            }

            if (expected.Properties.Tables != null)
            {
                Assert.Equal(expected.Properties.Tables.Count, actual.Properties.Tables.Count);

                foreach (var table in expected.Properties.Tables)
                {
                    Assert.Contains(table, actual.Properties.Tables);
                }   
            }
            else
            {
                Assert.Empty(actual.Properties.Tables);
            }
        }