예제 #1
0
        public void GetParentResourceNameFromResourceUri_EmptyResourceUri_ThrowsArgumentException()
        {
            // Arrange
            var resourceUri = string.Empty;
            var sqlDatabaseDiscoveryQuery = new SqlDatabaseDiscoveryQuery();

            // Act & Assert
            Assert.Throws <ArgumentException>(() => sqlDatabaseDiscoveryQuery.GetParentResourceNameFromResourceUri(SqlDatabaseDiscoveryQuery.ServerSectionInResourceUri, resourceUri));
        }
예제 #2
0
        public void GetParentResourceNameFromResourceUri_NoResourceUri_ThrowsArgumentException()
        {
            // Arrange
            string resourceUri = null;
            var    sqlDatabaseDiscoveryQuery = new SqlDatabaseDiscoveryQuery();

            // Act & Assert
            // ReSharper disable once ExpressionIsAlwaysNull
            Assert.Throws <ArgumentException>(() => sqlDatabaseDiscoveryQuery.GetParentResourceNameFromResourceUri(SqlDatabaseDiscoveryQuery.ServerSectionInResourceUri, resourceUri));
        }
예제 #3
0
        public void GetParentResourceNameFromResourceUri_ValidResourceUri_GetsServerName()
        {
            // Arrange
            var serverName  = _faker.Name.FirstName();
            var resourceUri = $"/subscriptions/0f9d7fea-99e8-4768-8672-06a28514f77e/resourceGroups/promitor/providers/Microsoft.Sql/servers/{serverName}/databases/promitor-3";
            var sqlDatabaseDiscoveryQuery = new SqlDatabaseDiscoveryQuery();

            // Act
            var foundServerName = sqlDatabaseDiscoveryQuery.GetParentResourceNameFromResourceUri(SqlDatabaseDiscoveryQuery.ServerSectionInResourceUri, resourceUri);

            // Assert
            Assert.Equal(serverName, foundServerName);
        }