コード例 #1
0
        public void Teardown()
        {
            // Clean-up should not be considered a critical failure that results in a test run failure.  Due
            // to ARM being temperamental, some management operations may be rejected.  Throwing here
            // does not help to ensure resource cleanup.
            //
            // Because resources may be orphaned outside of an observed exception, throwing to raise awareness
            // is not sufficient for all scenarios; since an external process is already needed to manage
            // orphans, there is no benefit to failing the run; allow the test results to be reported.

            try
            {
                if (EventHubsTestEnvironment.Instance.ShouldRemoveNamespaceAfterTestRunCompletion)
                {
                    EventHubScope.DeleteNamespaceAsync(EventHubsTestEnvironment.Instance.EventHubsNamespace).GetAwaiter().GetResult();
                }
            }
            catch
            {
            }

            try
            {
                if (StorageTestEnvironment.Instance.ShouldRemoveStorageAccountAfterTestRunCompletion)
                {
                    StorageScope.DeleteStorageAccountAsync(StorageTestEnvironment.Instance.StorageAccountName).GetAwaiter().GetResult();
                }
            }
            catch
            {
            }
        }